fix(cli): reject unknown --rule values instead of silently passing#25
Open
dmchaledev wants to merge 1 commit into
Open
fix(cli): reject unknown --rule values instead of silently passing#25dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
An unknown or typo'd --rule ID was cast straight to RuleId and used to filter the rule set. A value matching no real rule filtered the set down to nothing, producing zero findings, a passing report, and exit code 0 — a false "PASSED" security gate from a single typo. Validate each --rule value against the RuleId enum and exit 2 with a clear error (mirroring --format and --fail-on). Also list valid rule IDs in --help for discoverability, and add a regression test. Fixes #11 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ffK3ewW2pyTMsmmNSQK2R
This was referenced Jun 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.
Summary
Fixes #11. A security scanner that silently passes on misconfiguration is worse than one that fails loudly, because it gives false assurance.
Today an unknown or typo'd
--rulevalue is cast straight toRuleIdand used to filter the rule set (src/args.ts):A value matching no real rule filters the rule set down to nothing, so the scan produces zero findings, a passing report, and exit code
0:This was inconsistent with
--formatand--fail-on, which already validate their input and exit2. (The original issue pointed atcli.ts; the--ruleparsing has since moved intoargs.ts, but the bug came along with it.)Changes
src/args.ts— validate each--rulevalue against theRuleIdenum; return anerrorresult (exit2) with a clear message listing valid rule IDs when it doesn't match.src/cli.ts— list valid rule IDs in--helpfor discoverability.src/__tests__/args.test.ts— regression test asserting--rule=NOAUTHexits2.Verification
npm run typecheck,npm run lint, andnpm test(100 tests) all pass.Acceptance criteria (from #11)
--rule=BOGUSexits with code2and a clear error message--helplists valid rule IDs🤖 Generated with Claude Code
https://claude.ai/code/session_017ffK3ewW2pyTMsmmNSQK2R
Generated by Claude Code