Repository navigation
Fix CLI scan completion, error handling, and advisory deduplication - #623
Conversation
|
Why the full rewrite from eventemitter to async? |
|
Tests should be split into test files per module. Example: license tests |
|
getIdentifiers has changed semantics. Why? |
|
Commits must have verified signatures. |
018599e to
703593f
Compare
|
The change addresses a completion-order bug introduced with OSV integration: directory traversal can finish while OSV requests are still pending. In an isolated reproduction using the old and new sources, the old CLI closed the report with no findings and exit code 0; the new code waited and closed with the finding and exit code 13. Scanner events remain intact. The waiting is necessary, although moving the entire CLI into async main() is not required to fix it. |
|
Previously, any shared identifier could collapse two advisories, including a shared issue number. Bootstrap issue 20184 covers multiple distinct CVEs, so this dropped valid findings. The change prioritizes CVE/GHSA identifiers and namespaces fallback identifiers. The tradeoff is that an issue-only record may remain separate from a CVE-bearing record for the same vulnerability. |
|
The tests are now split by module into CLI, scanner, repository, depsdev, and license specs. All 70 tests pass, along with the build, TypeScript checks, and ESLint. The updated commit, 703593f, has a verified SSH signature. Production code is unchanged from the previous PR revision. |
|
Hmm. why was this closed by the other merge. Not intentional |
Can we reduce the size of the new main? The commandline argument parsing etc. is using sync methods because it all needs to be done before we can continue, so it's deliberately not async or using callbacks. |
|
Removed the async main wrapper; setup stays synchronous while scans still await OSV results. |
Thanks. Does the try catch really need to cover the entire cli.ts? It makes this PR so hard to review. |
| ); | ||
| } | ||
| const severity = prg.severity ?? 'none'; | ||
| if (!Object.prototype.hasOwnProperty.call(severityLevels, severity)) { |
There was a problem hiding this comment.
Show probably rewrite this to us a zod schema
| if (bower.version) { | ||
| const results = retire.check(bower.name, bower.version, repo); | ||
| emitResults({ file: file, results: results }, options, repo); | ||
| return emitResults({ file: file, results: results }, options, repo); |
There was a problem hiding this comment.
Shouldn't this be awaited now that emitResults is async ?
| } | ||
| } | ||
| emitResults({ file: file, results: results }, options, repo); | ||
| return emitResults({ file: file, results: results }, options, repo); |
There was a problem hiding this comment.
Shouldn't this be awaited now that emitResults is async?
| import { run } from '../run-script'; | ||
|
|
||
| it('preserves distinct Bootstrap CVEs sharing an issue while removing repeated advisories', () => { | ||
| run(` |
There was a problem hiding this comment.
Can we solve this without the massive evals? (run-script)
| }); | ||
|
|
||
| it('keeps fallback identifier namespaces separate and prefers canonical identifiers', () => { | ||
| run(` |
There was a problem hiding this comment.
Can we solve this without the massive evals? (run-script)
| }); | ||
|
|
||
| it('awaits OSV results before resolving file scans', () => { | ||
| run(` |
There was a problem hiding this comment.
Can we solve this without the massive evals? (run-script)
| import { it } from 'node:test'; | ||
| import { run } from '../run-script'; | ||
|
|
||
| it('rejects malformed local and remote repositories with source context', () => { |
There was a problem hiding this comment.
Can we solve this without the massive evals? (run-script)
| import { run } from '../run-script'; | ||
|
|
||
| it('handles malformed OSV JSON through the warning path', () => { | ||
| run(` |
There was a problem hiding this comment.
Can we solve this without the massive evals? (run-script)
|
Narrowed the try/catch, added explicit awaits, removed the eval blocks, and switched severity validation to Zod. |
CLI scans could close reports before asynchronous OSV findings arrived, and malformed inputs or repository responses could escape the intended error path. This PR waits for scan completion before finalizing output, validates terminal CLI input, handles malformed local/remote JSON with source context, and passes the insecure option through repository loading.
It also fixes the exclusive upper license boundary and platform-dependent Bower path handling, and preserves distinct CVEs sharing an issue while removing repeated advisories.
This is the CLI-only replacement for the relevant part of #622, as requested. It changes seven CLI/core/test files; extension rewrites, portable build scripts, and CycloneDX changes are excluded.
Validation: 70 tests pass, TypeScript checking and nonfixing ESLint pass, repository validation passes, and the full detection suite completes successfully across 48 packages. On Windows, the unchanged Unix-oriented npm scripts were run using equivalent direct Node/TypeScript commands against freshly compiled output.
AI-assisted implementation, with regression tests for the corrected behavior.
Related independent replacements: browser extensions #624 and CycloneDX #625.