Skip to content

Mask a capability's inline command line and dash-prefixed credential values - #3283

Merged
Birfy merged 1 commit into
mainfrom
dev/3281-mask-a-capability-s-inline-command-line
Nov 21, 2026
Merged

Birfy merged 1 commit into
mainfrom
dev/3281-mask-a-capability-s-inline-command-line

Conversation

@Birfy

@Birfy Birfy commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Written-by: Dev
Owner: Dev
Reviewer: Reviewer
Claim-Id: 01a19417f4864994854adea79c10ba39
Base: 202fcc6
Fixes #3281

What changed

  • core/src/host/capabilities.js: a command containing a space or a tab is split and read with the same flag / --flag=value / NAME=value rules as args; the token after a credential-looking flag is its value even when it begins with -. A single bare-token command stays unmasked (unchanged limit).
  • core/test/capabilities.test.js: two red-first groups (inline command line, dash-prefixed value), the accepted-cost case, and a <6 test that now uses a credential-name flag with exactly five characters.
  • docs/subsystems/core-host.md and changelog.d/3281.fixed.md.

Accepted text cost

--api-key --verbose stores --api-key [hidden], and --api-key --api-key sk-live-… masks the second --api-key as a value too. The stored reason is still one line, at most 300 characters, masked before the cut; Accept: application/json, 401 bad credentials, the sig/hmac/pass list, the whole-segment pat/sig/pass match and longest-value-first order are unchanged.

Verification at the tip

Tip SHA: 44eed15

Ran at this tip:

$ cd core && node --test test/capabilities.test.js
# tip: 35 pass, 0 fail
$ cp /tmp/3281_base_capabilities.js core/src/host/capabilities.js   # main's blob 112c42b3, red check
$ cd core && node --test test/capabilities.test.js
# base: 3 fail (33, 34, 35); the tip file is restored after and re-run green
$ node i3281-impl/tipcmp.mjs
# every changed file's blob sha equals the tip tree

Red first at the base: cd core && node --test test/capabilities.test.js -> 3 failures (inline command, dash value, followed flag). Green at the tip: same command -> 35 pass, 0 fail.
Mutation check: deleting value.length >= 6 turns the <6 test red (test 30); the line was restored.
node scripts/ds-bot-patches.mjs check -> ok core/ equals ds-bot/ + patches/ds-bot/. node core/scripts/build-client.mjs --check -> green.

Not run: npm run lint / arch-docs (this box has no oxlint and no git), ds-bot-patches.mjs generate|canonical (both need git; the two hunks were rebuilt by hand and check validates them), and the full core suite under test/harness-resolve.mjs (no dev/harness install; its 168 failures are environmental ERR_MODULE_NOT_FOUND for @deepseek-ai/* and jsdom, unrelated to this diff). CI runs them at the tip.

Test-quality items from #3279

  • The warn/log face is a construction, not a real-path verification: the surface tests replace ctx.logger.warn with a collector, so they assert the value handed to the logger, not a line written into the real DSH log sink.
  • The <6 skip is pinned with a credential-name flag (--api-key) and exactly five characters (abcde); deleting the length filter makes that test red (verified above).

Checkpoint

{
  "pr": 3283,
  "claim": "Dev",
  "issue": 3281,
  "summary": "A capability's stored failure reason now masks a credential in an inline command line saved in command, and a credential value that begins with a dash. A command containing a space or tab is read as a command line under the same flag, inline and assignment rules as args, and the token after a credential-looking flag is its value even when it starts with -. A single bare-token command stays unmasked, the same documented limit as a bare args token. The accepted over-mask --api-key --verbose -> --api-key [hidden] is in the doc, the fragment and this body.",
  "files": [
    "core/src/host/capabilities.js",
    "core/test/capabilities.test.js",
    "docs/subsystems/core-host.md",
    "changelog.d/3281.fixed.md",
    "patches/ds-bot/0001-core-fixes.patch",
    "patches/ds-bot/0014-flybot-branding.patch"
  ],
  "checks": { "ran": "cd core && node --test test/capabilities.test.js; node scripts/ds-bot-patches.mjs check; node core/scripts/build-client.mjs --check", "result": "green", "at": "44eed15953086cf951128ffc5440c3b77dc731b1" },
  "next": "none — ready for review"
}

…alues

Read a command that contains whitespace as a command line with the same flag, inline
and assignment rules as args, and take the token after a credential-looking flag as its
value even when it begins with `-`. A single bare-token command stays unmasked and is
documented as the same limit as a bare args token; the accepted over-mask
(`--api-key --verbose` -> `--api-key [hidden]`) is recorded in the doc, the fragment and
the pull request body. The stored reason is still one line of at most 300 characters,
masked before the cut; the sig/hmac/pass list, the whole-segment pat/sig/pass match and
longest-value-first order are unchanged.

Fixes #3281
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 21, 2026
@Birfy Birfy self-assigned this Nov 21, 2026
@Birfy

Birfy commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at 44eed15
Written-by: Reviewer
Attestation: 44eed15 role=Reviewer
Reviewed-by: Reviewer
Reviewed-tip: 44eed15

Ran at this tip:

$ cd core && node --test test/capabilities.test.js
# tests 35  # pass 35  # fail 0
$ cp ../../pr3283/cap_base.js core/src/host/capabilities.js && cd core && node --test test/capabilities.test.js
# tests 35  # pass 32  # fail 3   (33 inline command, 34 dash value, 35 flag-as-value)
$ cp ../../pr3283/cap_tip.js core/src/host/capabilities.js && sed -i 's/value.length >= 6 && CREDENTIAL_NAME.test(name)/CREDENTIAL_NAME.test(name)/' core/src/host/capabilities.js && cd core && node --test test/capabilities.test.js
# tests 35  # pass 34  # fail 1   (30 under-six value)

Tree honesty: the six changed files in the run tree are the tip's own blobs (sha1 of core/src/host/capabilities.js b555e7f9, core/test/capabilities.test.js 83571152); the checkout underneath is a local copy of a nearby main tip because this box's tarball fetch of 44eed15 came back truncated twice (no git, no curl here). CI at this tip (ubuntu-latest · Node 24 · DSH 0.2.0-rc.2, tests-ok) runs the full tree and is green.

Review points, each against the diff:

  1. Inline command line — core/src/host/capabilities.js:75-79: command with a space or tab is now split(/[ \t]+/) and joined with args before the same loop; a single bare token keeps the old [command] shape. Test 33 (command: 'node server.js --api-key … --password=… -e SERVICE_TOKEN=…') asserts the exact masked line and that no literal survives in the whole status view. Red at base blob: test 33 fails.
  2. Dash-prefixed value — capabilities.js:89: next.startsWith('-') dropped from the guard, so the token after a credential flag is its value. Test 34 covers --api-key -s3cr3t-abcdef --verbose; red at base blob. The accepted cost (--api-key --verbose → --api-key [hidden], a second --api-key masked) is pinned by test 35, and stated in the module comment, docs/subsystems/core-host.md (prompt.js row), the changelog fragment and the PR body — consistent in all four places.
  3. Bare single-token command stays unmasked — the [command] branch is unchanged, and <6 skip survives at capabilities.js:72 (value.length >= 6). That group is now genuinely pinned: test 30 uses --api-key abcde, and deleting the length filter makes it red (mutation run above). The old test pinned it behind --pin, whose name never matched a credential, so it could not have caught that deletion — this is the Mask a capability's argv literal and three more credential names in the stored error line (#3275 residual) #3279 item and it is fixed.

Regression checks that hold: mask still runs before the cut (capabilities.js:379 withoutCredentialValues(...).slice(0, 300)); status stays one line, ≤300; ordering longest-value-first unchanged; the suite's existing cases for Accept: application/json, 401 bad credentials, assign/compass/bypass, X-Patch-Id and the whole-segment pat/sig/pass still pass untouched (35/35 includes them). Scope is 6 files, all named: source, test, doc, changelog fragment, and the two patches/ds-bot/ mirrors — no unrelated edit.

Check-runs at this tip: enqueue-guard failure only, and its reason is the absence of this Verdict (no Verifier report names the tip 44eed1595308); policy-sign, merge-gate, tests-ok, ubuntu-latest · Node 24, plugins (tree/social/timeline/workflow), package, mock. judge, agent-audience (x4) are success; window check / live are skipped by design; the one earlier agent-audience cancelled is a superseded duplicate run. mergeable: true.

Ready for the merge queue at this tip.

@github-actions github-actions Bot added the pass label Nov 21, 2026
@Birfy
Birfy added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 59ee395 Nov 21, 2026
21 of 22 checks passed
@Birfy
Birfy deleted the dev/3281-mask-a-capability-s-inline-command-line branch November 21, 2026 08:21
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mask a capability's inline command line and a dash-prefixed credential value

1 participant