--only-used does not scope override-hygiene / maintenance findings in the --fail-on gate
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 715
- Forks
- 145
- Avg merge
- 21h 39m
- Merged PRs (30d)
- 66
Description
Note: in-house item already being handled by the maintainer - not open for contribution. Filed for tracking only.
Summary
--only-used filters vulnerability findings down to reachable (imported) ones before --fail-on evaluates, so a team can scope the CI gate to vulnerabilities their code actually imports. But override-hygiene and maintenance-risk findings, which also trip --fail-on, are not scoped by --only-used. A build run with --only-used --fail-on high can still fail on an override or maintenance finding even though the user scoped the gate to reachable findings, which reads as "the flag is broken."
Where
src/index.ts:794-797- the gate ORs three sources together:const shouldFail = reachesFailOn(scanState.sorted, options.failOn) || // vulnerability findings (scoped by --only-used) reachesFailOn(overrideFindings, options.failOn) || // NOT scoped reachesFailOn(maintenanceFindings, options.failOn); // NOT scopedsrc/index.ts:884-886---only-usedfilters only the vulnerability findings (finalFindings.filter(f => f.usage?.imported)), which becomescanState.sorted.
Options
- Document it (likely correct). Override-hygiene and maintenance-risk are not import-reachability concepts - they are about override config and package maintenance, not whether your code imports a vulnerable package - so it is defensible that
--usage/--only-useddoes not apply to them. If so, the CLI reference and the--only-used/--fail-ondocs should state explicitly that--only-usedscopes vulnerability findings only, and override/maintenance findings still gate independently. One sentence prevents the surprise. - Change behavior. If we decide reachability should scope the whole gate, also filter override/maintenance findings under
--only-used. Semantically questionable; probably not desired.
Optionally, the scan summary could note which finding classes the --fail-on gate is currently considering.
Recommendation
Lean toward option 1 (docs), with an explicit note. Needs a maintainer decision on approach before implementing.
Context
Surfaced by an external reviewer evaluating the tool for a neutral SCA comparison - flagged as a footgun that "one sentence prevents."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the gate logic in src/index.ts:794-797 and the --only-used filtering at src/index.ts:884-886. A maintainer must first decide whether documentation or behavior should change; if documentation is chosen, update the CLI reference and --only-used/--fail-on guidance. Done means the chosen semantics are agreed and clearly represented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, security
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100