Repository navigation
fix(cli): honor global flags before the command word, and reject a typo'd upgrade flag - #487
Merged
Merged
Conversation
…po'd upgrade flag Three defects in one class — argv handling that fails silently or fails wrongly. All three were measured against the published 6.6.5, not inferred. 1. `kit upgrade --self.` (trailing period) missed hasFlag's exact match, fell through to the lock-file path, rewrote every `installedAt` in .kit/cli-lock.json to "now" while installing nothing, and printed the normal success line. A typo silently became a different operation. `cmdUpgrade` now rejects unknown flags via the `unknownFlags` helper the repo already ships — self-audit/flag-validation has been advising exactly this for 44 command modules. 2. `kit check --read-only` and `kit check --non-interactive` exited 1 with "unknown flag for kit check" and never ran the check. Both are in the "Global flags" table of docs/COMMANDS.md; CHECK_FLAGS was built from the check path's own literals only — the same false red as the `--attest` regression its own comment documents. GLOBAL_FLAGS is now part of every check allowlist, and check-flags.test.ts pins the superset relation. 3. `kit --read-only check` — the form README.md:299 and docs/THREAT_MODEL.md:98 both document — activated read-only mode and then answered "Unknown command: --read-only" (exit 1), because the flag WAS args[0]. cli.ts now splits leading global flags off the positional stream and re-appends them behind it, so raw-index subcommand reads (`process.argv[3] === "verify-attestation"`) see the same shape as the flagless form. Verified end to end: `kit --read-only check verify-attestation` reaches the subcommand. The oracle for GLOBAL_FLAGS is docs/COMMANDS.md's own table, not a second copy of the list — a test that restated the flags would have passed happily while the flag was rejected in production. `--env=<name>` is added to that table: config.ts has always honored it globally off raw argv. Full suite 4274/4274, lint clean, `kit check --category security` unchanged (one pre-existing accepted secrets-scan warn). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
✅ Docker image built successfully
|
sandstream
added a commit
that referenced
this pull request
Aug 20, 2026
Promotes the #487 arc decision to the curated shared tier: hasFlag matches exact tokens, so a near-miss flag is invisible and the command silently takes another branch (`kit upgrade --self.` rewrote lock-file timestamps instead of self-upgrading). The entry records the rule plus the two corollaries — command allowlists include GLOBAL_FLAGS, and leading globals are stripped before positional dispatch. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Found by running
kit upgrade --self.— with a trailing period. It reported a successful upgrade and upgraded nothing.Three defects, one class: argv handling that fails silently or fails wrongly. All measured against the published 6.6.5, not inferred.
1. A typo'd flag silently became a different operation
kit upgrade --self.missedhasFlag's exact match, fell through to the lock-file path, and rewrote everyinstalledAtin.kit/cli-lock.jsonto "now" while installing nothing — under the normal success output. The user had no signal that the self-upgrade never ran.cmdUpgradenow rejects unknown flags with theunknownFlagshelper this repo already ships.self-audit/flag-validationhas been advising exactly this for 44 command modules; this fixes the one where it bit. The remaining 43 are a separate sweep (#488) — the--attesthistory shows an allowlist built from the wrong source is its own outage, so they need per-command verification, not a mechanical pass.2.
kit checkrejected two documented global flagskit check --read-onlyunknown flag for kit checkkit check --non-interactiveunknown flag for kit checkkit check --env=produnknown flag for kit checkkit check --not-a-real-flagAll three are global —
--read-only/--non-interactiveare in the "Global flags" table ofdocs/COMMANDS.md,--env=is read byconfig.ts:resolveActiveEnvironmentoff raw argv for every command.CHECK_FLAGSwas built from the check path's own literals only: the same false red as the--attestregression its own comment documents. A gate that refuses to run is the mirror image of a false green.3.
kit --read-only <cmd>never dispatchedThe form documented in
README.md:299anddocs/THREAT_MODEL.md:98activated read-only mode and then answeredUnknown command: --read-only(exit 1) — for every command, since the flag wasargs[0].cli.tsnow splits leading global flags off the positional stream and re-appends them behind it. That ordering matters: command modules read subcommands off raw indices, so a flag in front of the command word shifts all of them. Verified end to end thatkit --read-only check verify-attestationreaches the subcommand.Oracle
GLOBAL_FLAGSis asserted againstdocs/COMMANDS.md's own table, not a second copy of the list — a test that restated the flags would have passed happily while the flag was rejected in production. The docs scan has a guard asserting it matched something, per the five historical measurement bugs in this repo that were regexes matching nothing.--env=<name>is added to that table, and the table now states that globals may be written on either side of the command word.Verification
npm run lintclean,format:checkcleankit check --category security: 24/25, one pre-existing accepted secrets-scan warn — unchangedkit upgrade(happy path) andkit check --not-a-real-flag(rejection must survive the widened allowlist)🤖 Generated with Claude Code