Repository navigation
fix(cbio): resolve the live lane's vendor material from an injected source - #192
Merged
shroominic merged 2 commits intoSep 18, 2026
Merged
Conversation
…ants The vendor GS1 stream key, link credential, and authentication prompt were plaintext constants in packages/cgm_cbio/lib/src/cbio_crypto.dart. The repository is public, the file is on the 0.4.0 release aggregate, and the Secret Scan job is red on the same lane for a fixture derived from it. Remove the constants and make the material an explicit input: * cbio_credentials.dart adds CbioCredentials (validated, immutable, redacting toString), CbioCredentialSource, CbioMapCredentialSource, CbioDefineCredentialSource, and the fail-closed CbioCredentialUnavailable. * cbioRc4Keystream, maskCbioFrame, unmaskCbioFrame, and every builder in cbio_vendor_frames.dart now take the key and material as required arguments, so a caller that has not resolved material cannot compile a call. * the device harness reads the material from the process environment or --dart-define and aborts with vendor-material-missing before touching radio. * tests use clearly synthetic fixtures; the real-material checks skip unless the values are injected. * .gitleaks.toml adds a rule for this exact class of literal and a narrow allowlist for synthetic fixtures only. Refs #164 (cherry picked from commit 7fa477c)
…ource The live session still called the pre-redaction crypto API: `maskCbioFrame`, `unmaskCbioFrame`, and every masked builder defaulted to compiled constants, and the session read its link credential from `CbioCompiledAuthMaterialProvider`. Those defaults are gone, so the lane has to resolve the material explicitly. - `CbioGlucoseSession` takes a `CbioCredentialSource` and resolves it once per session, before the transport is touched. An unconfigured build fails closed with `cbio.auth.material` and a configuration status text instead of opening a link it could never authenticate or unmask. - Every mask, unmask, and masked builder receives the resolved key explicitly, and the authentication frame receives the resolved material. - `CbioSensorDriver` exposes its source and a `canAuthenticate` predicate. - The app's platform registry registers the GS1 driver only when the build supplied the material, so a plain build does not offer a sensor it cannot read. The capture harness reads the material from the environment or `--dart-define` and reports `vendor-material-missing` when it is absent. Tests: cgm_cbio 81 passed (2 skipped), openhealth 480 passed; `flutter analyze` clean in both, including `openhealth/integration_test`.
This was referenced Sep 18, 2026
shroominic
added a commit
that referenced
this pull request
Sep 18, 2026
Absorbs feature/cbio-gs1-app-live at 05785b0, which carries the redacted credential API (#166 verbatim as a7c21bc) and the live lane's adoption of an injected CbioCredentialSource (PR #192, issue #191). Conflict resolution: - packages/cgm_cbio/README.md: union. The aggregate's FF31 reply-decode paragraph (#132) and the lane's new injected-material section are both kept; neither lineage had the other. - packages/cgm_cbio/test/cbio_crypto_test.dart: take the lane's version. It supersedes the masked-vector fixture from #148 by removing the published vectors entirely and testing the mask with synthetic material.
shroominic
added a commit
that referenced
this pull request
Sep 18, 2026
…andidate Reverts the merge of fix/cbio-archive-unit-claim (#168). #168 removes CbioRawGlucoseRecord.derivedMilligramsPerDecilitre and .derivedMillimolesPerLitre and leaves only an explicitly unitless rawCurrentScaled. The app-live surface still fills CgmReading.valueMgdl from the removed mg/dL accessor, so the merge leaves six analyzer errors in cgm_cbio and, fixing them, would change the number the live surface renders. That is a unit-reference decision on the product surface, not a mechanical merge, and it is the owner's to make. The lane needs an adoption change (as #192 was for #166) before this can land. Recorded as excluded in the PR body.
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #191.
The defect
The live lane resolved its vendor material from compiled defaults:
CbioCompiledAuthMaterialProviderfor the link credential and the defaultedcbioVendorStreamKeyfor every mask and unmask.fix/cbio-credential-redaction(#166) removes both, so the lane stopped compiling against the redacted API.
This branch adopts that API. It is two commits:
0d3f763- fix(cbio): require injected vendor material instead of compiled constants #166 verbatim, cherry-picked from7fa477confix/cbio-credential-redaction.9e2105a- the adoption itself.The cherry-pick is included so the branch compiles and passes on its own. Once
#166 lands, this PR's diff reduces to the second commit; both pieces are
byte-identical to the branch that is already open.
RED
Both runs are on
0d3f763- the lane tip with #166 applied and nothing else.Seven
key:errors in the session, eleven in its tests, and one in the captureharness.
GREEN
Same two commands on this branch:
+81 ~2: All tests passed!andNo issues found!.The fix
CbioGlucoseSessiontakes aCbioCredentialSource(defaultCbioDefineCredentialSource) and resolves it once per session, before thetransport is touched. An unconfigured build fails closed with
cbio.auth.material, a configuration status text, zero connects, zerowrites, and no subscription - the fail-open compiled default is gone.
_streamKeygetter feeds everymaskCbioFrame,unmaskCbioFrame, andmasked builder; the authentication frame additionally takes the resolved
material. No call site can reach a mask without the key.CbioSensorDriverexposes its source and acanAuthenticatepredicate.cbioCredentials.isConfigured, so a plain build does not offer a sensor itcan only fail to read. The capture harness reads the material from the
environment or
--dart-defineand reportsvendor-material-missingbeforetouching the radio, exactly as fix(cbio): require injected vendor material instead of compiled constants #166's authenticated harness does.
Decisions to review
isConfiguredexists on the redaction branch for thiscall site, but it changes the default build:
registeredDriverIdsis{aidex}instead of{aidex, cbio}when no material is supplied. Thealternative is to keep registering the driver and let the session fail at
connect with the new configuration text. I chose the gate because a listed
sensor that can never be read is a dead end; say the word and I will invert
it.
connect, not inside_authenticate. That is what makes "no link is opened" true for thefail-closed case, and it is one read per session either way.
_failgained an optionalstatusTextso the configuration failure doesnot render as "Connection failed". The failure code and every other caller
are unchanged.
Tests added
resolves the material once per session- a counting source asserts oneread()across a doubleinitialize().fails closed before the radio when the build carries none- asserts thetransport was never asked to connect, no write was sent, and the snapshot
carries
cbio.auth.material.a driver reports whether its build can authenticate at allanda driver without material fails closed before any writeon the driver.(
CGMTESTKEY000000/CGMTESTMATERIAL1) through aCbioStaticCredentialSource, so no test depends on a compiled constant.og_demo_flag_testasserts the registry contents per configuration instead ofa hard-coded
{aidex, cbio}.Verification
cd packages/cgm_cbio && flutter test- exit 0,+81 ~2: All tests passed!(
17db5b4:+75; fix(cbio): require injected vendor material instead of compiled constants #166 adds its own crypto tests, this branch adds four)cd openhealth && flutter test- exit 0,+480: All tests passed!(
17db5b4:+480)flutter analyze-No issues found!in both, plusflutter analyze integration_testinopenhealthdart formaton every line this branch adds - no change. The two test filesand three app files keep exactly the pre-existing drift hunks they had at
17db5b4; the formatter lanes own those.CGMTEST…strings and thematerial is read from the environment at run time.