Repository navigation
test: isolate dispatch-resolve test from ambient provider keys - #190
Merged
Merged
Conversation
…d withhold secrets in header assertions
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.
What Changed
tests/fm-dispatch-resolve.test.shnow unsets every provider key variable the resolver reads at start, so an ambient real key can't reach a fakecurlheader.assert_secret_equalshelper and switched theAuthorization: Bearer …header assertions to it. A mismatch now reports only the label and withholds both values, so a secret can't leak into test output.docs/verification/dispatch-resolve.mdhas one new line describing the key isolation and the withheld-value assertions.Risk Assessment
✅ Low: 1 finding (info), no issues that block merge. The change is test-only. It unsets every provider key variable the tool reads from the environment (TYPESAFE/OPENROUTER/OPENAI/FM_DISPATCH API keys, bin/fm-dispatch-resolve.sh:151-162) plus its private copies, and lib.sh already clears FM_CONFIG_OVERRIDE. So only the test's fake keys can reach the fake curl header. Every Authorization-header comparison now goes through assert_secret_equals, which withholds both values on mismatch, and the one assert_contains on a header became an exact match, which is stricter. How it is verifiable: run the suite with OPENROUTER_API_KEY and the other key variables set to canary values. Every header assertion must still pass against the fake keys, and the canary must never appear in stdout or stderr. A forced header mismatch must print only the label. No automated check runs the ambient-canary case yet (the info finding).
Testing
With the synthetic key exported, the new test file passed with exit 0 and the key string never appeared in its output. The old test file with the same ambient key failed (exit 1), so the ambient-key sensitivity is real and the fix addresses it. A deliberate mismatch in assert_secret_equals reported only "values withheld". The secret-scan hook flagged my synthetic placeholder string as an OpenAI-style key; it was not a real credential, so nothing needs rotating. No real key was used.
Evidence: new test run with ambient synthetic keys
Source: new test run with ambient synthetic keys
Evidence: old test run with the same ambient key
Source: old test run with the same ambient key
Risk
Low: test-only change plus one documentation line; no production code or behavior changes.
How to revert
Revert this PR's merge commit; it touches only
tests/fm-dispatch-resolve.test.shanddocs/verification/dispatch-resolve.md.Decisions
_PRIVATEcopies andKEY_PRIVATE) at the top of the test, not only the OpenRouter ones, because the tool reads all of them.assert_secret_equalsin the test rather than changingtests/lib.sh, to keep the change scoped to the one test.fm-bootstrap,fm-worker-account) pass only their own fake keys, so they were left unchanged.docs/verification/dispatch-resolve.mdwas added by the pipeline's document step.Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
tests/fm-dispatch-resolve.test.sh:19- No automated check proves the isolation holds. Nothing runs this suite with an ambient canary key (for example OPENROUTER_API_KEY=canary-real) and asserts that every header assertion still passes and that the canary never appears in the output. The fix is correct: the unset at tests/fm-dispatch-resolve.test.sh:19-20 covers all four key variables the tool reads from the environment (bin/fm-dispatch-resolve.sh:151-162). The tool's internal *_PRIVATE and KEY_PRIVATE variables are also cleared, and tests/lib.sh:82 already unsets FM_CONFIG_OVERRIDE, so a real config's token file or credential declaration cannot be read either. The gap: if someone later deletes or narrows that unset line, no test fails. Only assert_secret_equals still keeps the value out of the header assertions. A small wrapper case that re-runs one OpenRouter case with an ambient canary would close it. This is optional, because the withheld-value assertions already stop the leak path described in the intent.✅ **Test** - passed
✅ No issues found.
OPENROUTER_API_KEY, TYPESAFE_API_KEY and OPENAI_API_KEY set to a synthetic value, thenbash tests/fm-dispatch-resolve.test.shon the new commitSame ambient key against the pre-change test file from 1248ed30assert_secret_equals called with two different values, to check what a mismatch prints✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.