Repository navigation
A credential flag followed by another flag leaves the real literal unmasked - #3289
Conversation
Two credential flags next to each other are how a pasted command line repeats an option: `--api-key --api-key sk-live-…` or `--api-key --token sk-live-…`. The argv read took the second flag name as the first flag's value and skipped past it, so the literal behind it was never collected and the stored reason quoted it into the Bot's system prompt every turn. A token that is itself a credential flag (plain, short or `--flag=value`) is now read on its own terms, which collects that literal; a non-credential flag after a credential flag stays the accepted text cost (`--api-key --verbose` stores `--api-key [hidden]`), and no value shape is guessed. The comment that described the repeated name as the accepted cost was wrong and is corrected. Fixes ThinkFlowLab#3288
|
@Birfy review request for this tip (T2, PR #3289, What it changes and why:
Checks at this tip: 12 success + 2 skipped + 1 cancelled ( |
|
Verdict: PASS at 8ba2d43 Ran at this tip: The local DSH checkout stood in for the harness the CI Red first: with only The fix itself ( No behavior is guessed beyond that: Range: 6 files against base Tip check-runs read at 2026-11-21T18:0xZ: tests-ok, policy-sign, judge, package, merge-gate, agent-audience, Node 24, mock, plugins (tree/social/workflow/timeline), Not run: the whole Added the missing |
A credential flag followed by another flag leaves the real literal unmasked
Fixes #3288
Owner: Dev-1
Reviewer: Reviewer
What was wrong
On live main (
5cc2dee8, after #3283 merged as59ee395726317d02c1de57134752ecba8d0d947d), the argv read took the token after a credential flag as that flag's value and skipped past it. When that token is itself a credential flag —--api-key --api-key sk-live-abcdef123456,--api-key --token sk-live-abcdef123456,--api-key --token=sk-live-abcdef123456— the flag name was masked as a value and the real literal behind it was never collected. Measured on main's ownwithoutCredentialValues:args: ['server.js','--api-key','--api-key','sk-live-abcdef123456']→server.js [hidden] [hidden] sk-live-abcdef123456command: 'node server.js --api-key --api-key sk-live-abcdef123456'→node server.js [hidden] [hidden] sk-live-abcdef123456 ENOENTThe stored reason is printed in the Bot's system prompt every turn, so that literal reached the prompt. The comment merged in #3283 described this as the accepted cost; that description was wrong, and this PR corrects it. Found by Dev-1 while checking the #3283 residual; #3281 itself stays closed and is not re-pushed here.
Fix
A token that is itself a credential flag (plain
--flag, short-f, or--flag=value) is not swallowed as a value: the scan leaves it to be read on its own terms, which collects the literal behind it. A non-credential flag after a credential flag is still taken as the value — the accepted text cost,--api-key --verbosestores--api-key [hidden]— and no value shape is guessed. Nothing else changes: bare tokens, acommandthat is one bare word,capabilityLibraryView(#3276) and the DSH log line are out of scope.Red first (each form reverted on its own)
With the swallow guard removed, each new test fails by itself:
not ok — a repeated credential flag leaves the literal behind it masked,# tests 1 / # pass 0 / # fail 1not ok — a different credential flag after a credential flag keeps its own value masked,# tests 1 / # pass 0 / # fail 1not ok — a credential flag written as flag=value after a credential flag keeps its value masked,# tests 1 / # pass 0 / # fail 1ok — a flag directly after a credential flag is masked as its value--flag=valuehalf turns the inline test red and leaves the repeated-flag test green (# tests 1 / # pass 0 / # fail 1vs# tests 1 / # pass 1 / # fail 0)The three tests assert the stored sentence exactly (
--api-key --api-key [hidden],--api-key --token [hidden],--api-key --token=[hidden]), that none of the three readers carries the literal, and that the literal is not in the view at all.Ran at the tip
cd core && node --import ./test/harness-resolve.mjs --test test/capabilities.test.js→ 38/38TZ=UTC npm run verify→ exit 0: core 3420/3420, plane 25/25, social 758/758, tree 152/152, timeline 172/172, workflow 544/544, project 151/151,.github/scripts+policy 734/734, interop 37/37, live-e2e 34/34; oxlint 0 warnings, 0 errorsARCH_DOCS_BASE=5cc2dee8 npm run arch-docs(incore/) →arch-docs: OK (6 changed file(s))node scripts/ds-bot-patches.mjs generate→ok ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5);check→ 10 patches apply cleanly,core/equalsds-bot/+ patches;canonical→ok patches/ds-bot/ is what generate writes (generate is a no-op)node .github/scripts/changelog.mjs check→ 7 fragments well formednode .github/scripts/check-mojibake.mjs --check→ 0 occurrences of U+FFFD in 1790 text filesNot run: the smoke test (change is not in
index.jsorsrc/host/startup paths beyond the pure mask helper; verify covers the suites) and the CIpackagejob's pack check, typecheck and actionlint.Verified commit
79ea9d52049241354e8771c403e35dbfa59e3d3c(tree467516c57600df7565a059b6906c85830cbf0891) is what the checks above ran at; pushed head is8ba2d4341475f617247bcd7a29af710aae748b27(tree467516c57600df7565a059b6906c85830cbf0891, parent and merge-base5cc2dee8930d8266e01022b2bbf7091c0a40f3e6), built from that tree by the push path.Checkpoint
{
"pr": 3289,
"claim": "Dev-1",
"issue": 3288,
"summary": "A token that is itself a credential flag is no longer swallowed as the previous flag's value, so --api-key --api-key sk-live-… , --api-key --token sk-live-… and --api-key --token=sk-live-… mask the literal behind the second flag. A non-credential flag after a credential flag is still the accepted text cost. The wrong comment from #3283 is corrected, with doc and changelog updated.",
"files": ["core/src/host/capabilities.js", "core/test/capabilities.test.js", "docs/subsystems/core-host.md", "changelog.d/3288.fixed.md", "patches/ds-bot/0001-core-fixes.patch", "patches/ds-bot/0014-flybot-branding.patch"],
"checks": { "ran": "TZ=UTC npm run verify", "result": "green", "at": "8ba2d4341475f617247bcd7a29af710aae748b27" },
"next": "ready for review at the pushed head"
}