cve-lite-cli 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -21
- package/dist/index.js +159 -146
- package/dist/output/formatters.js +4 -0
- package/dist/output/printers.js +210 -21
- package/dist/remediation/fix-commands.js +165 -10
- package/dist/remediation/npm-registry.js +258 -0
- package/dist/remediation/parent-upgrade.js +2 -19
- package/dist/scanner.js +45 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<p>
|
|
17
17
|
<a href="#quick-start">Quick Start</a> •
|
|
18
|
+
<a href="#new-here-start-here">New Here? Start Here</a> •
|
|
18
19
|
<a href="#features">Features</a> •
|
|
19
20
|
<a href="#usage">Usage</a> •
|
|
20
21
|
<a href="https://github.com/sonukapoor/cve-lite-cli/blob/main/src/docs/CONTRIBUTING.md">Contributing</a>
|
|
@@ -31,9 +32,11 @@
|
|
|
31
32
|
<td valign="top">
|
|
32
33
|
<strong>Overview</strong><br/>
|
|
33
34
|
<a href="#what-is-cve-lite-cli">What is CVE Lite CLI</a><br/>
|
|
35
|
+
<a href="#new-here-start-here">New here? Start here</a><br/>
|
|
34
36
|
<a href="#new-offline-advisory-db-support">Offline advisory DB support</a><br/>
|
|
35
37
|
<a href="#why-offline-mode-matters">Why offline mode matters</a><br/>
|
|
36
38
|
<a href="docs/case-studies/owasp-juice-shop.md">OWASP Juice Shop case study</a><br/>
|
|
39
|
+
<a href="docs/case-studies/nestjs.md">NestJS case study</a><br/>
|
|
37
40
|
<a href="#what-it-looks-like">What it looks like</a><br/>
|
|
38
41
|
<a href="#why-this-tool-exists">Why this tool exists</a><br/>
|
|
39
42
|
<a href="#project-scope-and-differentiation">Project scope and differentiation</a>
|
|
@@ -77,7 +80,25 @@ It is designed to be:
|
|
|
77
80
|
- usable in enterprise and restricted-network environments
|
|
78
81
|
- capable of zero-runtime-network scans through a local advisory database
|
|
79
82
|
|
|
80
|
-
For
|
|
83
|
+
For real-world remediation examples, see the [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md) and the [NestJS case study](docs/case-studies/nestjs.md).
|
|
84
|
+
|
|
85
|
+
## New here? Start here
|
|
86
|
+
|
|
87
|
+
1. run one scan on a real project with `npx cve-lite-cli /path/to/project --verbose`
|
|
88
|
+
2. review direct vs transitive findings and the `Copy And Run These Fix Commands` section
|
|
89
|
+
3. compare the output with your current scanner workflow
|
|
90
|
+
4. check a real walkthrough:
|
|
91
|
+
- [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md)
|
|
92
|
+
- [NestJS case study](docs/case-studies/nestjs.md)
|
|
93
|
+
|
|
94
|
+
If CVE Lite CLI helps your release workflow, a GitHub star helps more developers discover it: [Star CVE Lite CLI](https://github.com/sonukapoor/cve-lite-cli).
|
|
95
|
+
|
|
96
|
+
If you want to shape the roadmap, open an issue with feedback on:
|
|
97
|
+
|
|
98
|
+
- whether the direct vs transitive split is useful in practice
|
|
99
|
+
- where remediation guidance is still missing
|
|
100
|
+
- what increases or decreases trust in a CLI security tool
|
|
101
|
+
- what would make frontend-heavy CI workflows smoother
|
|
81
102
|
|
|
82
103
|
## New: Offline advisory DB support
|
|
83
104
|
|
|
@@ -210,7 +231,15 @@ cve-lite /path/to/project --offline
|
|
|
210
231
|
|
|
211
232
|
CVE Lite CLI produces a clean, summary-first console view by default, designed for fast triage before release.
|
|
212
233
|
|
|
213
|
-
The default output is designed to stay concise while still surfacing the most important next step, including package-manager-aware
|
|
234
|
+
The default output is designed to stay concise while still surfacing the most important next step, including package-manager-aware fix commands when confident targets exist.
|
|
235
|
+
|
|
236
|
+
The most important section to look for in the output is:
|
|
237
|
+
|
|
238
|
+
```text
|
|
239
|
+
🛠 Copy And Run These Fix Commands
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
That is one of the clearest differentiators in CVE Lite CLI. Instead of only showing advisories and severity counts, the tool tries to turn the findings into concrete commands developers can copy and run immediately.
|
|
214
243
|
|
|
215
244
|
For example, the tool can now suggest a concrete next command such as:
|
|
216
245
|
|
|
@@ -220,15 +249,25 @@ npm install jsonwebtoken@4.2.2 express-jwt@2.1.0 sanitize-html@2.17.2
|
|
|
220
249
|
|
|
221
250
|
The exact command adapts to the dependency file used for the scan, so `package-lock.json`, `pnpm-lock.yaml`, and `yarn.lock` can each produce a package-manager-specific suggestion.
|
|
222
251
|
|
|
223
|
-
For deeper investigation, running with `--verbose` provides the fuller remediation context, including dependency paths, parent upgrade guidance for transitive issues when available, a complete fix plan, skipped-item context for unresolved urgent findings, and a detailed table view.
|
|
252
|
+
For deeper investigation, running with `--verbose` provides the fuller remediation context, including the `Copy And Run These Fix Commands` section, dependency paths, parent upgrade guidance for transitive issues when available, a complete fix plan, skipped-item context for unresolved urgent findings, and a detailed table view.
|
|
253
|
+
|
|
254
|
+
That is the core idea: install it, point it at your project, and immediately get a practical dependency fix plan instead of a wall of raw advisories.
|
|
255
|
+
|
|
256
|
+
That local loop matters a lot in practice. In the NestJS case study, one dependency path required several `tar` upgrades in sequence as the dependency graph changed after each install. If a team only relied on pipeline scanners, they would likely:
|
|
224
257
|
|
|
225
|
-
|
|
258
|
+
1. upgrade `tar`
|
|
259
|
+
2. push a branch
|
|
260
|
+
3. wait for CI or a scheduled scanner to report back
|
|
261
|
+
4. learn they need to upgrade `tar` again
|
|
262
|
+
5. repeat the full cycle
|
|
263
|
+
|
|
264
|
+
That kind of branch-and-pipeline remediation can easily burn hours or days for one CVE path, and in slower teams it can stretch into weeks. CVE Lite CLI brings that feedback loop down to a local scan-fix-rescan workflow that can happen in the same session, and its local caching keeps consecutive rescans extremely fast instead of redoing the same advisory lookups from scratch each time.
|
|
226
265
|
|
|
227
266
|
The final status line also gives the scan a clear ending, which makes terminal use and screenshots easier to read.
|
|
228
267
|
|
|
229
268
|
See the example below using OWASP Juice Shop for real output samples.
|
|
230
269
|
|
|
231
|
-
For
|
|
270
|
+
For real-world case studies, see the [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md) and the [NestJS case study](docs/case-studies/nestjs.md).
|
|
232
271
|
|
|
233
272
|
If you maintain an open-source JavaScript or TypeScript project and want CVE Lite CLI evaluated on it, open an issue and share the repository. Strong candidates may be turned into future public case studies.
|
|
234
273
|
|
|
@@ -254,6 +293,8 @@ cve-lite .
|
|
|
254
293
|
|
|
255
294
|
Verbose examples:
|
|
256
295
|
|
|
296
|
+
Look for the `Copy And Run These Fix Commands` section in the screenshots below. That is the part of the output that turns findings into direct remediation steps.
|
|
297
|
+
|
|
257
298
|
<p align="center">
|
|
258
299
|
<img src="https://raw.githubusercontent.com/sonukapoor/cve-lite-cli/main/assets/verbose-output-1.png" alt="CVE Lite CLI verbose output screenshot" width="900"/>
|
|
259
300
|
<img src="https://raw.githubusercontent.com/sonukapoor/cve-lite-cli/main/assets/verbose-output-2.png" alt="CVE Lite CLI verbose output screenshot" width="900"/>
|
|
@@ -286,7 +327,7 @@ The project emphasizes:
|
|
|
286
327
|
|
|
287
328
|
- npm, pnpm, and Yarn lockfile support
|
|
288
329
|
- direct vs transitive visibility
|
|
289
|
-
- top-priority fixes and a suggested remediation plan
|
|
330
|
+
- top-priority fixes and a suggested dependency remediation plan
|
|
290
331
|
- JSON output for automation
|
|
291
332
|
- offline scanning through a local advisory database
|
|
292
333
|
- configurable advisory endpoint support via `--osv-url` for internal proxies or mirrors
|
|
@@ -303,7 +344,7 @@ Its role is narrower and workflow-focused:
|
|
|
303
344
|
- focused on JavaScript and TypeScript dependency scanning
|
|
304
345
|
- designed for fast local checks and simple CI release gates
|
|
305
346
|
- centered on direct vs transitive visibility
|
|
306
|
-
- built to highlight top-priority fixes and a suggested remediation plan
|
|
347
|
+
- built to highlight top-priority fixes and a suggested dependency remediation plan
|
|
307
348
|
- intentionally lightweight in runtime footprint and setup
|
|
308
349
|
|
|
309
350
|
The closest OWASP comparisons are:
|
|
@@ -408,6 +449,8 @@ It is important to be precise about the current scope:
|
|
|
408
449
|
|
|
409
450
|
So the practical model is: **local lockfile scan + advisory matching**. When malicious versions are published to OSV or mirrored through a compatible internal endpoint, CVE Lite CLI can flag those exact versions during a scan.
|
|
410
451
|
|
|
452
|
+
If a malicious package was installed and executed, upgrading or removing the dependency may not be sufficient on its own; teams should treat that as a potential security incident and follow their incident-response process.
|
|
453
|
+
|
|
411
454
|
## How it works
|
|
412
455
|
|
|
413
456
|
### Architectural Philosophy
|
|
@@ -429,8 +472,8 @@ CVE Lite CLI is designed as a **local-first, metadata-only** scanner. Unlike tra
|
|
|
429
472
|
|
|
430
473
|
- **fast, low-friction workflow**
|
|
431
474
|
Run it locally against a project without adopting a large security platform.
|
|
432
|
-
- **practical remediation guidance**
|
|
433
|
-
It does not stop at raw advisory output. It highlights top-priority fixes, suggests a fix plan, and
|
|
475
|
+
- **practical dependency remediation guidance**
|
|
476
|
+
It does not stop at raw advisory output. It highlights top-priority fixes, suggests a dependency fix plan, and generates package-manager-aware commands developers can copy and run when confident upgrade targets exist. When advisory and registry data allow, it recommends the lowest known non-vulnerable version and shows transparent scan/exclusion counts for checked package versions.
|
|
434
477
|
- **direct vs transitive visibility**
|
|
435
478
|
The output makes it easier to see whether the risk comes from something you installed directly or from a nested package.
|
|
436
479
|
- **developer-first**
|
|
@@ -472,32 +515,53 @@ Instead of only showing advisory IDs, the CLI reports:
|
|
|
472
515
|
|
|
473
516
|
By default, the CLI now presents a cleaner summary-first view, with `--verbose` available for the full detailed output.
|
|
474
517
|
|
|
475
|
-
### 3.
|
|
518
|
+
### 3. Copy-and-run fix commands
|
|
519
|
+
|
|
520
|
+
This is one of the most important parts of the CLI output.
|
|
521
|
+
|
|
522
|
+
When confident upgrade targets exist, CVE Lite CLI shows a dedicated `Copy And Run These Fix Commands` section so developers can move straight from findings to action.
|
|
523
|
+
|
|
524
|
+
The commands are:
|
|
525
|
+
|
|
526
|
+
- package-manager-aware
|
|
527
|
+
- grouped by severity and fix type
|
|
528
|
+
- designed to be copied directly from the terminal
|
|
529
|
+
- shown before the deeper remediation detail in verbose mode
|
|
530
|
+
- when enough advisory data exists, targeted to the lowest known non-vulnerable version with transparent version-scan counts in verbose output
|
|
531
|
+
|
|
532
|
+
In practice, this helps avoid repeated install-and-rescan loops.
|
|
533
|
+
Example: if advisory metadata suggests `tar@7.5.3`, CVE Lite CLI validates that target against known advisory ranges. If `7.5.3` is still known vulnerable, it checks the next published versions (`7.5.4`, `7.5.5`, and so on) until it finds the lowest known non-vulnerable version. The verbose output then shows how many versions were scanned and how many were excluded as still known vulnerable.
|
|
534
|
+
|
|
535
|
+
In the NestJS walkthrough, that validation flow scanned 22 package versions for a `tar` remediation path and excluded 21 as still known vulnerable before selecting the lowest known non-vulnerable target (see the [NestJS case study](docs/case-studies/nestjs.md)).
|
|
536
|
+
|
|
537
|
+
This gives developers a more direct remediation path instead of repeatedly upgrading, rescanning, and discovering that the next version is still affected. In slower CI-only workflows, that trial-and-error cycle can otherwise take much longer.
|
|
538
|
+
|
|
539
|
+
### 4. Top priority fixes
|
|
476
540
|
|
|
477
541
|
The CLI highlights the most important issues first, so developers can focus on the findings most likely to matter immediately.
|
|
478
542
|
|
|
479
|
-
###
|
|
543
|
+
### 5. Suggested fix plan
|
|
480
544
|
|
|
481
|
-
CVE Lite CLI organizes likely remediation work into a practical sequence, such as:
|
|
545
|
+
CVE Lite CLI organizes likely dependency remediation work into a practical sequence, such as:
|
|
482
546
|
|
|
483
547
|
- direct critical and high issues first
|
|
484
548
|
- urgent transitive issues next
|
|
485
549
|
- medium direct cleanup after that
|
|
486
550
|
- duplicated vulnerable packages to consolidate
|
|
487
551
|
|
|
488
|
-
###
|
|
552
|
+
### 6. Parent package hints for transitive issues
|
|
489
553
|
|
|
490
554
|
For transitive vulnerabilities, CVE Lite CLI can show the dependency path and, when it can determine one reliably, recommend the parent package upgrade to make. That makes the output more actionable than simply saying a nested package is vulnerable.
|
|
491
555
|
|
|
492
|
-
###
|
|
556
|
+
### 7. JSON output
|
|
493
557
|
|
|
494
558
|
Structured JSON output makes it easier to integrate with scripts, logs, or pipeline artifacts.
|
|
495
559
|
|
|
496
|
-
###
|
|
560
|
+
### 8. CI-friendly behavior
|
|
497
561
|
|
|
498
562
|
The CLI can be used in CI/CD pipelines and can fail builds based on severity thresholds.
|
|
499
563
|
|
|
500
|
-
###
|
|
564
|
+
### 9. Offline advisory DB support
|
|
501
565
|
|
|
502
566
|
The CLI can sync the official OSV npm advisory dump into a local SQLite advisory database and scan against it later with zero runtime advisory API calls.
|
|
503
567
|
|
|
@@ -582,7 +646,7 @@ jobs:
|
|
|
582
646
|
runs-on: ubuntu-latest
|
|
583
647
|
steps:
|
|
584
648
|
- uses: actions/checkout@v4
|
|
585
|
-
- uses: sonukapoor/cve-lite-cli@v1
|
|
649
|
+
- uses: sonukapoor/cve-lite-cli@v1
|
|
586
650
|
with:
|
|
587
651
|
verbose: "true"
|
|
588
652
|
fail-on: high
|
|
@@ -601,7 +665,7 @@ jobs:
|
|
|
601
665
|
runs-on: ubuntu-latest
|
|
602
666
|
steps:
|
|
603
667
|
- uses: actions/checkout@v4
|
|
604
|
-
- uses: sonukapoor/cve-lite-cli@v1
|
|
668
|
+
- uses: sonukapoor/cve-lite-cli@v1
|
|
605
669
|
with:
|
|
606
670
|
sync-advisories: "true"
|
|
607
671
|
offline: "true"
|
|
@@ -724,7 +788,7 @@ Compared with other tools in this space, CVE Lite CLI focuses on:
|
|
|
724
788
|
- **free to use**
|
|
725
789
|
- **fast to run**
|
|
726
790
|
- **easy to understand**
|
|
727
|
-
- **practical remediation guidance** instead of just raw advisory dumps
|
|
791
|
+
- **practical dependency remediation guidance** instead of just raw advisory dumps
|
|
728
792
|
- **clear direct vs transitive visibility**
|
|
729
793
|
- **top priority fixes** and a suggested fix plan
|
|
730
794
|
- support for **npm**, **pnpm**, and **Yarn** lockfiles
|
|
@@ -735,9 +799,9 @@ Compared with other tools in this space, CVE Lite CLI focuses on:
|
|
|
735
799
|
|
|
736
800
|
### At a glance
|
|
737
801
|
|
|
738
|
-
| Tool | Best at | Ecosystem scope | Lockfile support |
|
|
802
|
+
| Tool | Best at | Ecosystem scope | Lockfile support | Dependency remediation guidance | JSON/SARIF | Best fit |
|
|
739
803
|
|---|---|---|---|---|---|---|
|
|
740
|
-
| **CVE Lite CLI** | Fast, developer-friendly pre-release CVE scanning | Focused on JS/TS | npm, pnpm, Yarn | **
|
|
804
|
+
| **CVE Lite CLI** | Fast, developer-friendly pre-release CVE scanning | Focused on JS/TS | npm, pnpm, Yarn | **Dependency fix guidance** | **Yes** | Developers and small teams who want a free, practical release-time check |
|
|
741
805
|
| `npm audit` | Built-in npm auditing | npm-centric | npm | Basic remediation info | Limited compared to dedicated scanner workflows | Teams already living fully inside npm |
|
|
742
806
|
| OSV-Scanner | Broad multi-ecosystem scanning | Broad | Many ecosystems and lockfiles | More general-purpose | Strong machine-readable workflows | Teams needing wider ecosystem coverage |
|
|
743
807
|
| Snyk CLI | Broader enterprise security workflows | Broad | Strong ecosystem coverage | Strong commercial guidance | Strong | Teams adopting a larger security platform |
|
package/dist/index.js
CHANGED
|
@@ -13,169 +13,182 @@ import { createSpinner } from "./output/spinner.js";
|
|
|
13
13
|
import { buildSuggestedFixCommandPlan } from "./remediation/fix-commands.js";
|
|
14
14
|
import { getCliVersion } from "./utils/version-info.js";
|
|
15
15
|
import { logInfo, logWarn, printCacheSummary, serializeFinding } from "./output/formatters.js";
|
|
16
|
-
import { printSummary, printActionSummary, printPriorityFixes, printFixPlan, printSuggestedFixCommands, printCoverage, printSkippedDependencies, printGroupSummary, printTable, printPathHints, printFinalStatus, printCompactOutput } from "./output/printers.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
printHelp();
|
|
21
|
-
process.exit(0);
|
|
16
|
+
import { printSummary, printActionSummary, printPriorityFixes, printFixPlan, printSuggestedFixCommands, printSuggestedFixCommandSkips, printCoverage, printSkippedDependencies, printGroupSummary, printTable, printPathHints, printFinalStatus, printCompactOutput } from "./output/printers.js";
|
|
17
|
+
let parsedArgs = null;
|
|
18
|
+
try {
|
|
19
|
+
parsedArgs = parseArgs(process.argv.slice(2));
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
catch (error) {
|
|
22
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
24
|
+
console.error(chalk.gray("Run `cve-lite --help` to see supported options."));
|
|
25
|
+
process.exit(1);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
console.log(event.message);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
spinner.update(event.message);
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
if (usePlainProgressLogs) {
|
|
52
|
-
console.log(`Advisory sync complete (${result.advisoryCount} records)`);
|
|
27
|
+
if (parsedArgs) {
|
|
28
|
+
const { command, options, projectArg } = parsedArgs;
|
|
29
|
+
const cliVersion = getCliVersion();
|
|
30
|
+
if (options.help) {
|
|
31
|
+
printHelp();
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
else if (options.version) {
|
|
35
|
+
printBanner();
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const projectPath = path.resolve(projectArg || ".");
|
|
40
|
+
const batchSize = Number(options.batchSize || 100);
|
|
41
|
+
const searchDepth = Math.max(0, Number(options.searchDepth || 4));
|
|
42
|
+
async function main() {
|
|
43
|
+
if (!options.json) {
|
|
44
|
+
printBanner();
|
|
53
45
|
}
|
|
54
|
-
|
|
55
|
-
spinner
|
|
46
|
+
if (command === "advisories-sync") {
|
|
47
|
+
const spinner = createSpinner("Preparing advisory sync...", options);
|
|
48
|
+
const usePlainProgressLogs = !process.stdout.isTTY || !!options.json;
|
|
49
|
+
const result = await syncOsvAdvisories({
|
|
50
|
+
outputPath: options.output,
|
|
51
|
+
onProgress: event => {
|
|
52
|
+
if (event.phase === "complete") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (usePlainProgressLogs) {
|
|
56
|
+
console.log(event.message);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
spinner.update(event.message);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (usePlainProgressLogs) {
|
|
63
|
+
console.log(`Advisory sync complete (${result.advisoryCount} records)`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
spinner.succeed(`Advisory sync complete (${result.advisoryCount} records)`);
|
|
67
|
+
}
|
|
68
|
+
console.log(`${chalk.gray("Advisory database:")} synced ${result.advisoryCount} record${result.advisoryCount === 1 ? "" : "s"} to ${chalk.cyan(result.dbPath)}`);
|
|
69
|
+
process.exit(0);
|
|
70
|
+
return;
|
|
56
71
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if ((options.offline || options.offlineDb) && options.osvUrl) {
|
|
62
|
-
throw new Error("--offline/--offline-db cannot be used with --osv-url");
|
|
63
|
-
}
|
|
64
|
-
if (options.osvUrl) {
|
|
65
|
-
try {
|
|
66
|
-
new URL(options.osvUrl);
|
|
72
|
+
if ((options.offline || options.offlineDb) && options.osvUrl) {
|
|
73
|
+
throw new Error("--offline/--offline-db cannot be used with --osv-url");
|
|
67
74
|
}
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
if (options.osvUrl) {
|
|
76
|
+
try {
|
|
77
|
+
new URL(options.osvUrl);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new Error(`Invalid value for --osv-url: ${options.osvUrl}`);
|
|
81
|
+
}
|
|
70
82
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
let advisorySourceLine;
|
|
84
|
+
let advisoryDbFreshnessLine = null;
|
|
85
|
+
let advisoryDbWarning = null;
|
|
86
|
+
try {
|
|
87
|
+
const advisorySource = createAdvisorySource({
|
|
88
|
+
osvUrl: options.osvUrl,
|
|
89
|
+
offline: options.offline,
|
|
90
|
+
offlineDb: options.offlineDb,
|
|
91
|
+
});
|
|
92
|
+
advisorySourceLine = advisorySource.sourceLabel;
|
|
93
|
+
if (advisorySource.offline) {
|
|
94
|
+
const metadata = advisorySource.advisoryDbMetadata;
|
|
95
|
+
advisoryDbFreshnessLine = formatAdvisoryDbFreshness(metadata?.lastSyncAt ?? null);
|
|
96
|
+
if (advisorySource.advisoryDbIsStale) {
|
|
97
|
+
advisoryDbWarning = metadata?.lastSyncAt
|
|
98
|
+
? "The local advisory DB appears stale. Re-run `cve-lite advisories sync` to refresh it."
|
|
99
|
+
: "The local advisory DB has no recorded sync timestamp. Re-run `cve-lite advisories sync` to refresh it.";
|
|
100
|
+
}
|
|
89
101
|
}
|
|
102
|
+
advisorySource.cleanup();
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (options.offline || options.offlineDb) {
|
|
106
|
+
throw new Error(`Offline advisory database is not available: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
90
109
|
}
|
|
91
|
-
advisorySource.cleanup();
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
110
|
if (options.offline || options.offlineDb) {
|
|
95
|
-
|
|
111
|
+
console.log(chalk.gray("Offline mode:") + " " + chalk.yellow("enabled") + " " + chalk.gray("(no external advisory calls will be made)"));
|
|
96
112
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.log(chalk.gray("Offline mode:") + " " + chalk.yellow("enabled") + " " + chalk.gray("(no external advisory calls will be made)"));
|
|
101
|
-
}
|
|
102
|
-
console.log(`${chalk.gray("Advisory source:")} ${formatAdvisorySourceLine(advisorySourceLine)}`);
|
|
103
|
-
if (advisoryDbFreshnessLine) {
|
|
104
|
-
console.log(`${chalk.gray("Advisory DB freshness:")} ${advisoryDbFreshnessLine}`);
|
|
105
|
-
}
|
|
106
|
-
if (advisoryDbWarning) {
|
|
107
|
-
logWarn(advisoryDbWarning, options);
|
|
108
|
-
}
|
|
109
|
-
const scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
|
|
110
|
-
const packages = scanInput.packages;
|
|
111
|
-
logInfo(`Parsed ${packages.length} package${packages.length === 1 ? "" : "s"} from ${scanInput.source}${scanInput.filePath ? ` (${path.relative(projectPath, scanInput.filePath) || path.basename(scanInput.filePath)})` : ""}`, options);
|
|
112
|
-
printCacheSummary(options.cacheDir, options);
|
|
113
|
-
if (scanInput.warnings.length > 0) {
|
|
114
|
-
for (const warning of scanInput.warnings) {
|
|
115
|
-
logWarn(warning, options);
|
|
113
|
+
console.log(`${chalk.gray("Advisory source:")} ${formatAdvisorySourceLine(advisorySourceLine)}`);
|
|
114
|
+
if (advisoryDbFreshnessLine) {
|
|
115
|
+
console.log(`${chalk.gray("Advisory DB freshness:")} ${advisoryDbFreshnessLine}`);
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
logWarn(buildNoPackagesMessage(projectPath), options);
|
|
120
|
-
process.exit(0);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const findings = await scanPackages(packages, batchSize, options);
|
|
124
|
-
const sorted = findings.sort((a, b) => severityOrder[b.severity] - severityOrder[a.severity]);
|
|
125
|
-
const coverage = buildCoverageNotes(scanInput, !!options.offline || !!options.offlineDb);
|
|
126
|
-
const minSeverity = normalizeSeverity(options.minSeverity || "medium");
|
|
127
|
-
const tableFindings = options.all ? sorted : sorted.filter(f => severityOrder[f.severity] >= severityOrder[minSeverity]);
|
|
128
|
-
const suggestedFixCommands = buildSuggestedFixCommandPlan(sorted, scanInput);
|
|
129
|
-
if (options.json) {
|
|
130
|
-
console.log(JSON.stringify({
|
|
131
|
-
projectPath,
|
|
132
|
-
mode: scanInput.mode,
|
|
133
|
-
source: scanInput.source,
|
|
134
|
-
packageCount: packages.length,
|
|
135
|
-
findingCount: sorted.length,
|
|
136
|
-
suggestedFixCommands,
|
|
137
|
-
notes: [...scanInput.notes, ...coverage],
|
|
138
|
-
warnings: scanInput.warnings,
|
|
139
|
-
skippedDependencies: scanInput.skippedDependencies,
|
|
140
|
-
findings: sorted.map(serializeFinding)
|
|
141
|
-
}, null, 2));
|
|
142
|
-
}
|
|
143
|
-
else if (options.verbose) {
|
|
144
|
-
// Verbose output - show all details
|
|
145
|
-
printSummary(sorted, packages.length, scanInput);
|
|
146
|
-
printActionSummary(sorted);
|
|
147
|
-
printPriorityFixes(sorted);
|
|
148
|
-
printSuggestedFixCommands(sorted, scanInput);
|
|
149
|
-
printFixPlan(sorted);
|
|
150
|
-
printCoverage([...scanInput.notes, ...coverage]);
|
|
151
|
-
if (scanInput.skippedDependencies.length > 0) {
|
|
152
|
-
printSkippedDependencies(scanInput.skippedDependencies);
|
|
117
|
+
if (advisoryDbWarning) {
|
|
118
|
+
logWarn(advisoryDbWarning, options);
|
|
153
119
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
120
|
+
const scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
|
|
121
|
+
const packages = scanInput.packages;
|
|
122
|
+
logInfo(`Parsed ${packages.length} package${packages.length === 1 ? "" : "s"} from ${scanInput.source}${scanInput.filePath ? ` (${path.relative(projectPath, scanInput.filePath) || path.basename(scanInput.filePath)})` : ""}`, options);
|
|
123
|
+
printCacheSummary(options.cacheDir, options);
|
|
124
|
+
if (scanInput.warnings.length > 0) {
|
|
125
|
+
for (const warning of scanInput.warnings) {
|
|
126
|
+
logWarn(warning, options);
|
|
159
127
|
}
|
|
160
|
-
|
|
161
|
-
|
|
128
|
+
}
|
|
129
|
+
if (packages.length === 0) {
|
|
130
|
+
logWarn(buildNoPackagesMessage(projectPath), options);
|
|
131
|
+
process.exit(0);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const findings = await scanPackages(packages, batchSize, options);
|
|
135
|
+
const sorted = findings.sort((a, b) => severityOrder[b.severity] - severityOrder[a.severity]);
|
|
136
|
+
const coverage = buildCoverageNotes(scanInput, !!options.offline || !!options.offlineDb);
|
|
137
|
+
const minSeverity = normalizeSeverity(options.minSeverity || "medium");
|
|
138
|
+
const tableFindings = options.all ? sorted : sorted.filter(f => severityOrder[f.severity] >= severityOrder[minSeverity]);
|
|
139
|
+
const suggestedFixCommands = buildSuggestedFixCommandPlan(sorted, scanInput);
|
|
140
|
+
if (options.json) {
|
|
141
|
+
console.log(JSON.stringify({
|
|
142
|
+
projectPath,
|
|
143
|
+
mode: scanInput.mode,
|
|
144
|
+
source: scanInput.source,
|
|
145
|
+
packageCount: packages.length,
|
|
146
|
+
findingCount: sorted.length,
|
|
147
|
+
suggestedFixCommands,
|
|
148
|
+
notes: [...scanInput.notes, ...coverage],
|
|
149
|
+
warnings: scanInput.warnings,
|
|
150
|
+
skippedDependencies: scanInput.skippedDependencies,
|
|
151
|
+
findings: sorted.map(serializeFinding)
|
|
152
|
+
}, null, 2));
|
|
153
|
+
}
|
|
154
|
+
else if (options.verbose) {
|
|
155
|
+
// Verbose output - show all details
|
|
156
|
+
printSummary(sorted, packages.length, scanInput);
|
|
157
|
+
printActionSummary(sorted);
|
|
158
|
+
printSuggestedFixCommands(sorted, scanInput);
|
|
159
|
+
printPriorityFixes(sorted);
|
|
160
|
+
printFixPlan(sorted);
|
|
161
|
+
printSuggestedFixCommandSkips(sorted, scanInput);
|
|
162
|
+
printCoverage([...scanInput.notes, ...coverage]);
|
|
163
|
+
if (scanInput.skippedDependencies.length > 0) {
|
|
164
|
+
printSkippedDependencies(scanInput.skippedDependencies);
|
|
165
|
+
}
|
|
166
|
+
if (sorted.length > 0) {
|
|
167
|
+
printGroupSummary(sorted);
|
|
168
|
+
if (tableFindings.length > 0) {
|
|
169
|
+
printTable(tableFindings, options.all ? null : minSeverity);
|
|
170
|
+
printPathHints(tableFindings);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
logInfo(`No findings met the table threshold of ${minSeverity}. Re-run with --all to show everything.`, options);
|
|
174
|
+
}
|
|
162
175
|
}
|
|
176
|
+
printFinalStatus(sorted);
|
|
163
177
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
else {
|
|
179
|
+
// Simplified output - cleaner, focused view
|
|
180
|
+
printCompactOutput(sorted, scanInput);
|
|
181
|
+
}
|
|
182
|
+
const failLevel = normalizeSeverity(options.failOn);
|
|
183
|
+
const shouldFail = sorted.some(f => severityOrder[f.severity] >= severityOrder[failLevel]);
|
|
184
|
+
process.exit(shouldFail ? 1 : 0);
|
|
185
|
+
return;
|
|
169
186
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
main().catch((error) => {
|
|
188
|
+
console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
189
|
+
process.exit(1);
|
|
190
|
+
});
|
|
174
191
|
}
|
|
175
|
-
main().catch((error) => {
|
|
176
|
-
console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
177
|
-
process.exit(1);
|
|
178
|
-
});
|
|
179
192
|
}
|
|
180
193
|
function formatAdvisorySourceLine(sourceLabel) {
|
|
181
194
|
const match = sourceLabel.match(/^(.*) \((.*)\)$/);
|
|
@@ -94,6 +94,10 @@ export function serializeFinding(finding) {
|
|
|
94
94
|
severity: finding.severity,
|
|
95
95
|
relationship: finding.relationship,
|
|
96
96
|
firstFixedVersion: finding.firstFixedVersion,
|
|
97
|
+
validatedFirstFixedVersion: finding.validatedFirstFixedVersion ?? null,
|
|
98
|
+
fixVersionValidationNote: finding.fixVersionValidationNote ?? null,
|
|
99
|
+
validatedTargetScannedVersions: finding.validatedTargetScannedVersions ?? null,
|
|
100
|
+
validatedTargetKnownVulnerableVersions: finding.validatedTargetKnownVulnerableVersions ?? null,
|
|
97
101
|
recommendedAction: getRecommendedAction(finding),
|
|
98
102
|
primaryParent: getPrimaryParent(finding),
|
|
99
103
|
recommendedParentUpgrade: finding.recommendedParentUpgrade,
|