feat: report incomplete scan data with diagnostics#893
Conversation
Track scan completeness by capturing transient OSV detail failures, offline missing records, packument fetch errors, remediation failures, and chain resolution failures. Surface diagnostic warnings in CLI output, HTML report banner, and JSON output when scan data may be incomplete.
…nd reporting - Pass completeness to writeOutputs call site so JSON output receives real scan completeness instead of always reporting ok/complete - Add onTransientFailure callback to fetchPackument so scanner can track packument failures that were previously silently caught - Add completeness field to MultiFolderScanResult and propagate through multi-folder printer, JSON output, and HTML reports - Add aggregateMultiFolderCompleteness to deduplicate diagnostics across subfolders when aggregating counts - Fix compact mode zero-findings early return that skipped the incomplete scan warning - Differentiate HTML completeness banner text by diagnostic impact: detection failures vs remediation-only failures - Fix HTML banner diagRows join using literal backslash-n - Make ScanState.completeness required to prevent silent downgrades
…h all paths - Pass onTransientFailure callback through resolvePublishedFixVersion, resolveLowestKnownNonVulnerableVersion, validateDirectFixTargets, and resolveChainFix so direct-only scans also track registry failures - Fix printFinalStatus zero-findings path to show incomplete warning instead of conflicting green success when scan data is incomplete - Export renderCompletenessBanner and add per-folder + aggregate completeness banners to multi-folder HTML reports - Update footer text from 'Re-run the scan' to 'Resolve the issues above and re-run the scan'
…ckument tracking - Add module-level RegistryFetchObserver with onTransientFailure and onSuccess callbacks, set by scanner via setRegistryFetchObserver - All fetchPackument calls through any remediation path now automatically track transient failures and clear on retry success - Remove duplicate inline completeness aggregation in HTML reporter; use shared aggregateMultiFolderCompleteness from multi-folder-scan - Fix aggregateMultiFolderCompleteness to update message text when merging diagnostic counts - Fix verbose mode printFinalStatus to show 'Partial scan:' prefix instead of conflicting 'Scan complete' when data is incomplete
…formatDiagnosticMessage - Rename onSuccess to onResolved in RegistryFetchObserver and call it on 404 responses too, so transient-failure-then-404 retries clear old failure entries - Export formatDiagnosticMessage from scanner and use it in aggregateMultiFolderCompleteness instead of regex replacement for correct pluralization in merged diagnostic messages test: add observer retry tests and multi-folder aggregation tests
…agnostics - Replace manual message construction with formatDiagnosticMessage calls so single-folder and multi-folder aggregation share one message source - Update PACKUMENT_FETCH_FAILURE message: 'transitive remediation' -> 'remediation guidance' since it now covers direct fix validation too
- Remove onTransientFailure callback from fetchPackument and all downstream functions (resolvePublishedFixVersion, resolveLowest..., resolveChainFix, traceChain, validateDirectFixTargets). RegistryFetchObserver handles all tracking now. - Compress buildCompletenessDiagnostics: extract inner push() helper to eliminate five repeated diagnostic-construction blocks. - Simplify printFinalStatus: single 'incomplete' flag drives all three branches, collapsing duplicate conditional branches.
…recedence - Rename push() to addDiagnostic() with early-return guard and expanded object literal for readability - Restore redBright for Partial scan with critical/high findings by branching renderStatus on urgent flag
a2dd5af to
51a0b0f
Compare
|
The remaining Self Scan failures are unrelated to this PR. Both findings come from Jest's transitive development dependencies:
I also tried upgrading Jest from The regular CI and CodeQL checks pass, and the Self Scan jobs complete successfully before exiting with code 1 due to Since these are pre-existing, dev-only transitive dependency findings and are outside the scope of this PR, I am not changing the Self Scan policy, adding overrides, or expanding this PR further. The dependency issue can be handled separately once upstream packages provide compatible fixes. |
7fe2efb to
84bd6ae
Compare
|
This PR introduces scan completeness tracking as a foundational model. It intentionally wires the model through all output channels. |
|
Thanks for this @luojiyin1987 - the |
|
Thanks for the clear direction and for the positive feedback on the I’ll split the current implementation into three focused PRs:
I’ll keep each PR focused and make the dependency between them clear. I’ll also leave #898 as a separate follow-up after this infrastructure has landed. I’ll update this PR with links to the split PRs once they are ready. Thanks! |
Review note
This PR introduces a new scan completeness model and touches multiple parts of the pipeline.
I realize the current change is larger than a typical feature PR because the completeness information needs to flow from the scanner layer to all output formats.
This is an initial implementation of the design. If maintainers prefer, I am happy to split this PR into smaller focused changes:
ScanCompletenessdata model and scanner trackingFeedback on architecture and scope is welcome before merging.
Summary
Introduce scan completeness tracking to report when scan results may be incomplete.
Previously, CVE Lite CLI only reported detected vulnerabilities. However, a scan result with no findings does not always mean "no vulnerabilities exist" — some vulnerability data or remediation metadata may be unavailable during scanning.
This PR introduces
ScanCompletenessas first-class metadata attached to scan results, allowing users and CI systems to distinguish:Design
Problem
Security scanners must avoid creating false confidence.
For example:
The result should not be interpreted as:
because the scan may not have had enough information to make a complete determination.
At the same time, not all failures have the same impact:
Therefore, scan completeness needs to track both the occurrence and impact of incomplete data.
Solution
A scan result now contains:
ScanCompletenessdoes not replace vulnerability findings.It describes the confidence level of the scan process and whether additional investigation is needed.
Diagnostics are classified by impact:
Tracked incomplete scan scenarios
Detection impact
These conditions may affect vulnerability discovery:
Detection-impact issues prevent trusted baseline creation because incomplete detection data could hide future vulnerabilities.
Remediation impact
These conditions affect fix recommendations only:
Remediation-only issues do not block baseline operations because vulnerability findings remain reliable.
Output changes
Completeness information is propagated through all report formats:
Users can see:
Example:
or:
Baseline / ratchet behavior
Baseline files represent trusted detection results.
Creating or evaluating a baseline from incomplete detection data could silently hide vulnerabilities.
Therefore:
However:
This keeps ratchet behavior strict for vulnerability detection while avoiding unnecessary failures for remediation-only issues.
Implementation changes
Scanner
scanPackagesnow returns:Added tracking for:
Types
Added:
ScanDiagnosticScanDiagnosticCodeScanCompletenessOutput
Updated:
to display completeness diagnostics.
Tests
Updated affected tests covering:
Why this approach
A scan result should communicate not only:
but also:
ScanCompletenessprovides this confidence layer while keeping vulnerability findings and remediation recommendations separate.Changes
scanner.ts—scanPackagesnow returns{ findings, completeness }; six failure scenarios are tracked and built intoScanCompletenesstypes.ts— addScanDiagnostic,ScanDiagnosticCode,ScanCompletenesstypesprinters.ts—printFinalStatus/printCompactOutputacceptcompletenessparam; newprintIncompleteDiagnosticsprints yellow diagnostics bannerhtml-reporter.ts— addcompleteness-bannerCSS +renderCompletenessBannerto show warnings in HTML reportswrite-outputs.ts— passcompletenessto JSON output (addsstatus,complete,diagnostics)index.ts— plumbcompletenessthrough scan → output pipelinemulti-folder-scan.ts— adapt to newscanPackagesreturn signature