cve-lite-cli 1.2.0 → 1.3.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 CHANGED
@@ -2,6 +2,7 @@
2
2
  [![npm version](https://img.shields.io/npm/v/cve-lite-cli)](https://www.npmjs.com/package/cve-lite-cli)
3
3
  [![npm downloads](https://img.shields.io/npm/dm/cve-lite-cli)](https://www.npmjs.com/package/cve-lite-cli)
4
4
  [![CI](https://img.shields.io/github/actions/workflow/status/sonukapoor/cve-lite-cli/ci.yml?branch=main)](https://github.com/sonukapoor/cve-lite-cli/actions)
5
+ [![GitHub Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-CVE%20Lite%20CLI-blue)](https://github.com/marketplace/actions/cve-lite-cli)
5
6
  [![License](https://img.shields.io/github/license/sonukapoor/cve-lite-cli)](https://github.com/sonukapoor/cve-lite-cli/blob/main/LICENSE)
6
7
 
7
8
  <div align="center">
@@ -32,6 +33,7 @@
32
33
  <a href="#what-is-cve-lite-cli">What is CVE Lite CLI</a><br/>
33
34
  <a href="#new-offline-advisory-db-support">Offline advisory DB support</a><br/>
34
35
  <a href="#why-offline-mode-matters">Why offline mode matters</a><br/>
36
+ <a href="docs/case-studies/owasp-juice-shop.md">OWASP Juice Shop case study</a><br/>
35
37
  <a href="#what-it-looks-like">What it looks like</a><br/>
36
38
  <a href="#why-this-tool-exists">Why this tool exists</a><br/>
37
39
  <a href="#project-scope-and-differentiation">Project scope and differentiation</a>
@@ -75,6 +77,8 @@ It is designed to be:
75
77
  - usable in enterprise and restricted-network environments
76
78
  - capable of zero-runtime-network scans through a local advisory database
77
79
 
80
+ For a real-world remediation example, see the [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md).
81
+
78
82
  ## New: Offline advisory DB support
79
83
 
80
84
  CVE Lite CLI now supports a local advisory database workflow for teams that cannot allow runtime outbound advisory API calls.
@@ -111,6 +115,8 @@ Offline advisory DB support makes CVE Lite CLI more practical for:
111
115
 
112
116
  This is one of the most important differentiators in the project today because it improves both trust and adoptability, not just convenience.
113
117
 
118
+ The project also ships a reusable first-party GitHub Action, now available on the [GitHub Marketplace](https://github.com/marketplace/actions/cve-lite-cli), for teams that want a low-friction CI integration path.
119
+
114
120
  ## Quick start
115
121
 
116
122
  Install globally:
@@ -147,18 +153,21 @@ cve-lite /path/to/project --min-severity high
147
153
  # Recommended for CI logs when you want full context
148
154
  cve-lite /path/to/project --verbose
149
155
 
156
+ # Limit the scan to production dependencies where supported by the lockfile
157
+ cve-lite /path/to/project --prod-only
158
+
150
159
  # Fail a build on high severity and above
151
160
  cve-lite /path/to/project --fail-on high
152
161
 
153
162
  # JSON output
154
163
  cve-lite /path/to/project --json
155
164
 
156
- # SARIF output
157
- cve-lite /path/to/project --sarif --output reports/scan.sarif
158
-
159
165
  # Use a custom advisory endpoint
160
166
  cve-lite /path/to/project --osv-url https://security.company.internal/osv
161
167
 
168
+ # Show the CLI version
169
+ cve-lite --version
170
+
162
171
  # Build the local advisory DB for offline scans
163
172
  cve-lite advisories sync
164
173
 
@@ -201,7 +210,17 @@ cve-lite /path/to/project --offline
201
210
 
202
211
  CVE Lite CLI produces a clean, summary-first console view by default, designed for fast triage before release.
203
212
 
204
- For deeper investigation, running with `--verbose` provides full details, including dependency paths, parent upgrade guidance for transitive issues when available, a complete fix plan, and a detailed table view.
213
+ The default output is designed to stay concise while still surfacing the most important next step, including package-manager-aware suggested fix commands when confident targets exist.
214
+
215
+ For example, the tool can now suggest a concrete next command such as:
216
+
217
+ ```bash
218
+ npm install jsonwebtoken@4.2.2 express-jwt@2.1.0 sanitize-html@2.17.2
219
+ ```
220
+
221
+ 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
+
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.
205
224
 
206
225
  That is the core idea: install it, point it at your project, and immediately get a practical fix plan instead of a wall of raw advisories.
207
226
 
@@ -209,6 +228,10 @@ The final status line also gives the scan a clear ending, which makes terminal u
209
228
 
210
229
  See the example below using OWASP Juice Shop for real output samples.
211
230
 
231
+ For a real-world case study, see the [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md).
232
+
233
+ 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
+
212
235
  ## Example: Scanning OWASP Juice Shop (Real Output)
213
236
 
214
237
  CVE Lite CLI can be used against real-world vulnerable applications such as the OWASP Juice Shop.
@@ -235,7 +258,6 @@ Verbose examples:
235
258
  <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"/>
236
259
  <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"/>
237
260
  <img src="https://raw.githubusercontent.com/sonukapoor/cve-lite-cli/main/assets/verbose-output-3.png" alt="CVE Lite CLI verbose output screenshot" width="900"/>
238
- <img src="https://raw.githubusercontent.com/sonukapoor/cve-lite-cli/main/assets/verbose-output-4.png" alt="CVE Lite CLI verbose output screenshot" width="900"/>
239
261
  </p>
240
262
 
241
263
  ## Why this tool exists
@@ -265,7 +287,7 @@ The project emphasizes:
265
287
  - npm, pnpm, and Yarn lockfile support
266
288
  - direct vs transitive visibility
267
289
  - top-priority fixes and a suggested remediation plan
268
- - JSON and SARIF output for automation
290
+ - JSON output for automation
269
291
  - offline scanning through a local advisory database
270
292
  - configurable advisory endpoint support via `--osv-url` for internal proxies or mirrors
271
293
  - a small, reviewable runtime footprint
@@ -284,7 +306,20 @@ Its role is narrower and workflow-focused:
284
306
  - built to highlight top-priority fixes and a suggested remediation plan
285
307
  - intentionally lightweight in runtime footprint and setup
286
308
 
287
- This section is here to make the scope clear. CVE Lite CLI aims to complement the broader security ecosystem by being a practical, low-friction option for JS/TS dependency checks close to release time.
309
+ The closest OWASP comparisons are:
310
+
311
+ - **OWASP Dependency-Check**
312
+ A broader dependency analysis tool that covers many ecosystems and use cases beyond the lockfile-first JavaScript/TypeScript workflow emphasized here.
313
+
314
+ - **OWASP dep-scan**
315
+ A broader dependency and security analysis tool with wider language and environment coverage than this project is trying to provide.
316
+
317
+ - **OWASP Dependency-Track**
318
+ More SBOM- and platform-oriented, with a different operational model than a lightweight local CLI focused on developer checks close to release time.
319
+
320
+ CVE Lite CLI is intentionally narrower: it is JavaScript/TypeScript focused, lockfile-first, local-first, designed for fast local checks and simple CI gates, and built to surface direct vs transitive visibility, top-priority fixes, suggested remediation guidance, offline advisory DB workflows, and a small, reviewable runtime footprint.
321
+
322
+ This section is here to make the scope clear. CVE Lite CLI is meant to complement the broader OWASP ecosystem by serving a practical developer workflow close to release time.
288
323
 
289
324
  One of the clearest examples of that focus is offline support: CVE Lite CLI is built to let teams explicitly sync advisory data and then scan locally, instead of forcing every environment to depend on runtime outbound vulnerability API access.
290
325
 
@@ -395,7 +430,7 @@ CVE Lite CLI is designed as a **local-first, metadata-only** scanner. Unlike tra
395
430
  - **fast, low-friction workflow**
396
431
  Run it locally against a project without adopting a large security platform.
397
432
  - **practical remediation guidance**
398
- It does not stop at raw advisory output. It highlights top-priority fixes and suggests a fix plan.
433
+ It does not stop at raw advisory output. It highlights top-priority fixes, suggests a fix plan, and now generates package-manager-aware fix commands when confident upgrade targets exist.
399
434
  - **direct vs transitive visibility**
400
435
  The output makes it easier to see whether the risk comes from something you installed directly or from a nested package.
401
436
  - **developer-first**
@@ -458,21 +493,11 @@ For transitive vulnerabilities, CVE Lite CLI can show the dependency path and, w
458
493
 
459
494
  Structured JSON output makes it easier to integrate with scripts, logs, or pipeline artifacts.
460
495
 
461
- ### 7. SARIF output
462
-
463
- CVE Lite CLI supports SARIF (Static Analysis Results Interchange Format) output for security tooling and code-scanning workflows. SARIF is a standardized JSON-based format for security and code analysis results, which means CI systems, scanners, and code analysis platforms can all understand the same output without custom adapters. This is important because it makes CVE Lite CLI more than just a terminal tool: you can export findings into a format that fits modern DevSecOps workflows, archive results as build artifacts, and integrate vulnerability scans into automated release pipelines. For developers and teams, SARIF support helps security results travel cleanly from a local scan into CI/CD and other tooling, instead of being trapped in plain console output.
464
-
465
- Example:
466
-
467
- ```bash
468
- cve-lite /path/to/project --sarif --output reports/scan.sarif
469
- ```
470
-
471
- ### 8. CI-friendly behavior
496
+ ### 7. CI-friendly behavior
472
497
 
473
498
  The CLI can be used in CI/CD pipelines and can fail builds based on severity thresholds.
474
499
 
475
- ### 9. Offline advisory DB support
500
+ ### 8. Offline advisory DB support
476
501
 
477
502
  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.
478
503
 
@@ -557,7 +582,7 @@ jobs:
557
582
  runs-on: ubuntu-latest
558
583
  steps:
559
584
  - uses: actions/checkout@v4
560
- - uses: sonukapoor/cve-lite-cli@v1.1.1
585
+ - uses: sonukapoor/cve-lite-cli@v1.2.0
561
586
  with:
562
587
  verbose: "true"
563
588
  fail-on: high
@@ -576,7 +601,7 @@ jobs:
576
601
  runs-on: ubuntu-latest
577
602
  steps:
578
603
  - uses: actions/checkout@v4
579
- - uses: sonukapoor/cve-lite-cli@v1.1.1
604
+ - uses: sonukapoor/cve-lite-cli@v1.2.0
580
605
  with:
581
606
  sync-advisories: "true"
582
607
  offline: "true"
@@ -585,7 +610,7 @@ jobs:
585
610
  fail-on: high
586
611
  ```
587
612
 
588
- For CI, we recommend using `--verbose` so build logs include the full fix plan, dependency paths, and detailed table output when a scan fails.
613
+ For CI, we recommend using `--verbose` so build logs include the full fix plan, dependency paths, detailed table output, and suggested fix commands when a scan fails.
589
614
 
590
615
  Use it as a release gate in CI:
591
616
 
@@ -593,12 +618,6 @@ Use it as a release gate in CI:
593
618
  cve-lite . --verbose --fail-on high
594
619
  ```
595
620
 
596
- Export SARIF in CI:
597
-
598
- ```bash
599
- cve-lite . --verbose --sarif --output reports/scan.sarif
600
- ```
601
-
602
621
  ### Scripted automation
603
622
 
604
623
  Use JSON output for custom reporting:
package/dist/cli/args.js CHANGED
@@ -12,6 +12,10 @@ export function parseArgs(argv) {
12
12
  options.help = true;
13
13
  continue;
14
14
  }
15
+ if (arg === "-v" || arg === "--version") {
16
+ options.version = true;
17
+ continue;
18
+ }
15
19
  if (arg === "--output") {
16
20
  options.output = argv[++i];
17
21
  continue;
@@ -33,6 +37,10 @@ export function parseArgs(argv) {
33
37
  options.help = true;
34
38
  continue;
35
39
  }
40
+ if (arg === "-v" || arg === "--version") {
41
+ options.version = true;
42
+ continue;
43
+ }
36
44
  if (arg === "--json") {
37
45
  options.json = true;
38
46
  continue;
package/dist/cli/help.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { chalk } from "../utils/chalk.js";
2
+ import { getCliVersion } from "../utils/version-info.js";
3
+ const CLI_VERSION = getCliVersion();
2
4
  const CLI_BANNER = [
3
- `${chalk.green(">_")} ${chalk.bold.whiteBright("CVE Lite CLI")}`,
5
+ `${chalk.green(">_")} ${chalk.bold.whiteBright(`CVE Lite CLI (${CLI_VERSION})`)}`,
4
6
  chalk.gray("────────────────────────────────"),
5
7
  `${chalk.green("✔")} Scan dependencies`,
6
8
  `${chalk.green("✔")} Highlight critical issues`,
@@ -21,6 +23,8 @@ export function printHelp() {
21
23
  "",
22
24
  "Fast local-first CVE scanner for JS/TS projects using lockfiles + OSV",
23
25
  "",
26
+ `Version: ${CLI_VERSION}`,
27
+ "",
24
28
  "Usage:",
25
29
  " cve-lite [projectPath] [options]",
26
30
  " cve-lite advisories sync [options]",
@@ -42,6 +46,7 @@ export function printHelp() {
42
46
  "Advisory sync options:",
43
47
  " --output <path> Write the local advisory database to this path",
44
48
  "",
49
+ " -v, --version Show the CLI version",
45
50
  " -h, --help Show this help message"
46
51
  ];
47
52
  console.log(lines.join("\n"));
package/dist/index.js CHANGED
@@ -10,161 +10,173 @@ import { normalizeSeverity } from "./osv/severity.js";
10
10
  import { severityOrder } from "./constants.js";
11
11
  import { chalk } from "./utils/chalk.js";
12
12
  import { createSpinner } from "./output/spinner.js";
13
+ import { buildSuggestedFixCommandPlan } from "./remediation/fix-commands.js";
14
+ import { getCliVersion } from "./utils/version-info.js";
13
15
  import { logInfo, logWarn, printCacheSummary, serializeFinding } from "./output/formatters.js";
14
- import { printSummary, printActionSummary, printPriorityFixes, printFixPlan, printCoverage, printSkippedDependencies, printGroupSummary, printTable, printPathHints, printFinalStatus, printCompactOutput } from "./output/printers.js";
16
+ import { printSummary, printActionSummary, printPriorityFixes, printFixPlan, printSuggestedFixCommands, printCoverage, printSkippedDependencies, printGroupSummary, printTable, printPathHints, printFinalStatus, printCompactOutput } from "./output/printers.js";
15
17
  const { command, options, projectArg } = parseArgs(process.argv.slice(2));
18
+ const cliVersion = getCliVersion();
16
19
  if (options.help) {
17
20
  printHelp();
18
21
  process.exit(0);
19
22
  }
20
- const projectPath = path.resolve(projectArg || ".");
21
- const batchSize = Number(options.batchSize || 100);
22
- const searchDepth = Math.max(0, Number(options.searchDepth || 4));
23
- async function main() {
24
- if (!options.json) {
25
- printBanner();
26
- }
27
- if (command === "advisories-sync") {
28
- const spinner = createSpinner("Preparing advisory sync...", options);
29
- const usePlainProgressLogs = !process.stdout.isTTY || !!options.json;
30
- const result = await syncOsvAdvisories({
31
- outputPath: options.output,
32
- onProgress: event => {
33
- if (event.phase === "complete") {
34
- return;
35
- }
36
- if (usePlainProgressLogs) {
37
- console.log(event.message);
38
- return;
39
- }
40
- spinner.update(event.message);
41
- },
42
- });
43
- if (usePlainProgressLogs) {
44
- console.log(`Advisory sync complete (${result.advisoryCount} records)`);
23
+ else if (options.version) {
24
+ printBanner();
25
+ process.exit(0);
26
+ }
27
+ else {
28
+ const projectPath = path.resolve(projectArg || ".");
29
+ const batchSize = Number(options.batchSize || 100);
30
+ const searchDepth = Math.max(0, Number(options.searchDepth || 4));
31
+ async function main() {
32
+ if (!options.json) {
33
+ printBanner();
45
34
  }
46
- else {
47
- spinner.succeed(`Advisory sync complete (${result.advisoryCount} records)`);
35
+ if (command === "advisories-sync") {
36
+ const spinner = createSpinner("Preparing advisory sync...", options);
37
+ const usePlainProgressLogs = !process.stdout.isTTY || !!options.json;
38
+ const result = await syncOsvAdvisories({
39
+ outputPath: options.output,
40
+ onProgress: event => {
41
+ if (event.phase === "complete") {
42
+ return;
43
+ }
44
+ if (usePlainProgressLogs) {
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)`);
53
+ }
54
+ else {
55
+ spinner.succeed(`Advisory sync complete (${result.advisoryCount} records)`);
56
+ }
57
+ console.log(`${chalk.gray("Advisory database:")} synced ${result.advisoryCount} record${result.advisoryCount === 1 ? "" : "s"} to ${chalk.cyan(result.dbPath)}`);
58
+ process.exit(0);
59
+ return;
48
60
  }
49
- console.log(`${chalk.gray("Advisory database:")} synced ${result.advisoryCount} record${result.advisoryCount === 1 ? "" : "s"} to ${chalk.cyan(result.dbPath)}`);
50
- process.exit(0);
51
- return;
52
- }
53
- if ((options.offline || options.offlineDb) && options.osvUrl) {
54
- throw new Error("--offline/--offline-db cannot be used with --osv-url");
55
- }
56
- if (options.osvUrl) {
57
- try {
58
- new URL(options.osvUrl);
61
+ if ((options.offline || options.offlineDb) && options.osvUrl) {
62
+ throw new Error("--offline/--offline-db cannot be used with --osv-url");
59
63
  }
60
- catch {
61
- throw new Error(`Invalid value for --osv-url: ${options.osvUrl}`);
64
+ if (options.osvUrl) {
65
+ try {
66
+ new URL(options.osvUrl);
67
+ }
68
+ catch {
69
+ throw new Error(`Invalid value for --osv-url: ${options.osvUrl}`);
70
+ }
62
71
  }
63
- }
64
- let advisorySourceLine;
65
- let advisoryDbFreshnessLine = null;
66
- let advisoryDbWarning = null;
67
- try {
68
- const advisorySource = createAdvisorySource({
69
- osvUrl: options.osvUrl,
70
- offline: options.offline,
71
- offlineDb: options.offlineDb,
72
- });
73
- advisorySourceLine = advisorySource.sourceLabel;
74
- if (advisorySource.offline) {
75
- const metadata = advisorySource.advisoryDbMetadata;
76
- advisoryDbFreshnessLine = formatAdvisoryDbFreshness(metadata?.lastSyncAt ?? null);
77
- if (advisorySource.advisoryDbIsStale) {
78
- advisoryDbWarning = metadata?.lastSyncAt
79
- ? "The local advisory DB appears stale. Re-run `cve-lite advisories sync` to refresh it."
80
- : "The local advisory DB has no recorded sync timestamp. Re-run `cve-lite advisories sync` to refresh it.";
72
+ let advisorySourceLine;
73
+ let advisoryDbFreshnessLine = null;
74
+ let advisoryDbWarning = null;
75
+ try {
76
+ const advisorySource = createAdvisorySource({
77
+ osvUrl: options.osvUrl,
78
+ offline: options.offline,
79
+ offlineDb: options.offlineDb,
80
+ });
81
+ advisorySourceLine = advisorySource.sourceLabel;
82
+ if (advisorySource.offline) {
83
+ const metadata = advisorySource.advisoryDbMetadata;
84
+ advisoryDbFreshnessLine = formatAdvisoryDbFreshness(metadata?.lastSyncAt ?? null);
85
+ if (advisorySource.advisoryDbIsStale) {
86
+ advisoryDbWarning = metadata?.lastSyncAt
87
+ ? "The local advisory DB appears stale. Re-run `cve-lite advisories sync` to refresh it."
88
+ : "The local advisory DB has no recorded sync timestamp. Re-run `cve-lite advisories sync` to refresh it.";
89
+ }
81
90
  }
91
+ advisorySource.cleanup();
92
+ }
93
+ catch (error) {
94
+ if (options.offline || options.offlineDb) {
95
+ throw new Error(`Offline advisory database is not available: ${error instanceof Error ? error.message : String(error)}`);
96
+ }
97
+ throw error;
82
98
  }
83
- advisorySource.cleanup();
84
- }
85
- catch (error) {
86
99
  if (options.offline || options.offlineDb) {
87
- throw new Error(`Offline advisory database is not available: ${error instanceof Error ? error.message : String(error)}`);
100
+ console.log(chalk.gray("Offline mode:") + " " + chalk.yellow("enabled") + " " + chalk.gray("(no external advisory calls will be made)"));
88
101
  }
89
- throw error;
90
- }
91
- if (options.offline || options.offlineDb) {
92
- console.log(chalk.gray("Offline mode:") + " " + chalk.yellow("enabled") + " " + chalk.gray("(no external advisory calls will be made)"));
93
- }
94
- console.log(`${chalk.gray("Advisory source:")} ${formatAdvisorySourceLine(advisorySourceLine)}`);
95
- if (advisoryDbFreshnessLine) {
96
- console.log(`${chalk.gray("Advisory DB freshness:")} ${advisoryDbFreshnessLine}`);
97
- }
98
- if (advisoryDbWarning) {
99
- logWarn(advisoryDbWarning, options);
100
- }
101
- const scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
102
- const packages = scanInput.packages;
103
- logInfo(`Parsed ${packages.length} package${packages.length === 1 ? "" : "s"} from ${scanInput.source}${scanInput.filePath ? ` (${path.relative(projectPath, scanInput.filePath) || path.basename(scanInput.filePath)})` : ""}`, options);
104
- printCacheSummary(options.cacheDir, options);
105
- if (scanInput.warnings.length > 0) {
106
- for (const warning of scanInput.warnings) {
107
- logWarn(warning, options);
102
+ console.log(`${chalk.gray("Advisory source:")} ${formatAdvisorySourceLine(advisorySourceLine)}`);
103
+ if (advisoryDbFreshnessLine) {
104
+ console.log(`${chalk.gray("Advisory DB freshness:")} ${advisoryDbFreshnessLine}`);
108
105
  }
109
- }
110
- if (packages.length === 0) {
111
- logWarn(buildNoPackagesMessage(projectPath), options);
112
- process.exit(0);
113
- return;
114
- }
115
- const findings = await scanPackages(packages, batchSize, options);
116
- const sorted = findings.sort((a, b) => severityOrder[b.severity] - severityOrder[a.severity]);
117
- const coverage = buildCoverageNotes(scanInput, !!options.offline || !!options.offlineDb);
118
- const minSeverity = normalizeSeverity(options.minSeverity || "medium");
119
- const tableFindings = options.all ? sorted : sorted.filter(f => severityOrder[f.severity] >= severityOrder[minSeverity]);
120
- if (options.json) {
121
- console.log(JSON.stringify({
122
- projectPath,
123
- mode: scanInput.mode,
124
- source: scanInput.source,
125
- packageCount: packages.length,
126
- findingCount: sorted.length,
127
- notes: [...scanInput.notes, ...coverage],
128
- warnings: scanInput.warnings,
129
- skippedDependencies: scanInput.skippedDependencies,
130
- findings: sorted.map(serializeFinding)
131
- }, null, 2));
132
- }
133
- else if (options.verbose) {
134
- // Verbose output - show all details
135
- printSummary(sorted, packages.length, scanInput);
136
- printActionSummary(sorted);
137
- printPriorityFixes(sorted);
138
- printFixPlan(sorted);
139
- printCoverage([...scanInput.notes, ...coverage]);
140
- if (scanInput.skippedDependencies.length > 0) {
141
- printSkippedDependencies(scanInput.skippedDependencies);
106
+ if (advisoryDbWarning) {
107
+ logWarn(advisoryDbWarning, options);
142
108
  }
143
- if (sorted.length > 0) {
144
- printGroupSummary(sorted);
145
- if (tableFindings.length > 0) {
146
- printTable(tableFindings, options.all ? null : minSeverity);
147
- printPathHints(tableFindings);
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);
148
116
  }
149
- else {
150
- logInfo(`No findings met the table threshold of ${minSeverity}. Re-run with --all to show everything.`, options);
117
+ }
118
+ if (packages.length === 0) {
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);
153
+ }
154
+ if (sorted.length > 0) {
155
+ printGroupSummary(sorted);
156
+ if (tableFindings.length > 0) {
157
+ printTable(tableFindings, options.all ? null : minSeverity);
158
+ printPathHints(tableFindings);
159
+ }
160
+ else {
161
+ logInfo(`No findings met the table threshold of ${minSeverity}. Re-run with --all to show everything.`, options);
162
+ }
151
163
  }
164
+ printFinalStatus(sorted);
152
165
  }
153
- printFinalStatus(sorted);
154
- }
155
- else {
156
- // Simplified output - cleaner, focused view
157
- printCompactOutput(sorted);
166
+ else {
167
+ // Simplified output - cleaner, focused view
168
+ printCompactOutput(sorted, scanInput);
169
+ }
170
+ const failLevel = normalizeSeverity(options.failOn);
171
+ const shouldFail = sorted.some(f => severityOrder[f.severity] >= severityOrder[failLevel]);
172
+ process.exit(shouldFail ? 1 : 0);
173
+ return;
158
174
  }
159
- const failLevel = normalizeSeverity(options.failOn);
160
- const shouldFail = sorted.some(f => severityOrder[f.severity] >= severityOrder[failLevel]);
161
- process.exit(shouldFail ? 1 : 0);
162
- return;
175
+ main().catch((error) => {
176
+ console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
177
+ process.exit(1);
178
+ });
163
179
  }
164
- main().catch((error) => {
165
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
166
- process.exit(1);
167
- });
168
180
  function formatAdvisorySourceLine(sourceLabel) {
169
181
  const match = sourceLabel.match(/^(.*) \((.*)\)$/);
170
182
  if (!match) {
@@ -1,5 +1,6 @@
1
1
  import { chalk, stripAnsi } from "../utils/chalk.js";
2
2
  import { severityOrder } from "../constants.js";
3
+ import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
3
4
  import { formatSeverityLabel, formatRelationshipLabel, getPrimaryParent, getRecommendedAction, summarizeRisk, summarizeNextAction } from "./formatters.js";
4
5
  export function printSummary(findings, packageCount, scanInput) {
5
6
  if (findings.length === 0) {
@@ -57,7 +58,7 @@ export function printPriorityFixes(findings) {
57
58
  });
58
59
  const top = scored.slice(0, 5);
59
60
  console.log("");
60
- console.log(chalk.bold.magenta("Top priority fixes"));
61
+ console.log(chalk.bold.magenta("🚀 Top priority fixes"));
61
62
  for (const finding of top) {
62
63
  console.log(`- ${chalk.whiteBright(finding.pkg.name)}@${chalk.white(finding.pkg.version)} (${formatSeverityLabel(finding.severity)}, ${formatRelationshipLabel(finding.relationship)})`);
63
64
  console.log(` Risk: ${summarizeRisk(finding)}`);
@@ -77,7 +78,7 @@ export function printFixPlan(findings) {
77
78
  const transitiveUrgent = findings.filter(f => f.relationship === "transitive" && (f.severity === "critical" || f.severity === "high"));
78
79
  const directMedium = findings.filter(f => f.relationship === "direct" && f.severity === "medium");
79
80
  console.log("");
80
- console.log(chalk.bold.green("Suggested fix plan"));
81
+ console.log(chalk.bold.green("📋 Suggested fix plan"));
81
82
  if (directUrgent.length > 0) {
82
83
  console.log(chalk.green("1) Upgrade these direct critical/high dependencies first:"));
83
84
  for (const finding of directUrgent.slice(0, 5)) {
@@ -114,6 +115,31 @@ export function printFixPlan(findings) {
114
115
  }
115
116
  }
116
117
  }
118
+ export function printSuggestedFixCommands(findings, scanInput) {
119
+ const plan = buildSuggestedFixCommandPlan(findings, scanInput);
120
+ if (!plan)
121
+ return;
122
+ if (!plan.command && plan.skipped.length === 0)
123
+ return;
124
+ console.log("");
125
+ console.log(chalk.bold.green("🛠 Suggested fix command"));
126
+ console.log(`${chalk.gray("Detected package manager:")} ${chalk.cyan(plan.packageManager)} ${chalk.gray(`(${plan.sourceLabel})`)}`);
127
+ if (plan.command) {
128
+ console.log(chalk.cyan(plan.command));
129
+ }
130
+ else {
131
+ console.log(chalk.gray("No confident package-manager command could be generated for the urgent findings."));
132
+ }
133
+ if (plan.skipped.length > 0) {
134
+ console.log(chalk.gray("Not included automatically:"));
135
+ for (const skipped of plan.skipped.slice(0, 5)) {
136
+ console.log(`- ${skipped.package}@${skipped.version}: ${skipped.reason}`);
137
+ }
138
+ if (plan.skipped.length > 5) {
139
+ console.log(`- ...and ${plan.skipped.length - 5} more`);
140
+ }
141
+ }
142
+ }
117
143
  export function printCoverage(notes) {
118
144
  if (notes.length === 0)
119
145
  return;
@@ -224,7 +250,7 @@ function truncate(value, width) {
224
250
  return value;
225
251
  return plain.slice(0, Math.max(0, width - 1)) + "…";
226
252
  }
227
- export function printCompactOutput(findings) {
253
+ export function printCompactOutput(findings, scanInput) {
228
254
  console.log("");
229
255
  if (findings.length === 0) {
230
256
  console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
@@ -291,6 +317,16 @@ export function printCompactOutput(findings) {
291
317
  }
292
318
  console.log("");
293
319
  }
320
+ if (scanInput) {
321
+ const plan = buildSuggestedFixCommandPlan(findings, scanInput);
322
+ if (plan?.command) {
323
+ console.log("────────────────────────────────");
324
+ console.log(chalk.bold("🛠 Suggested Fix Command"));
325
+ console.log("────────────────────────────────\n");
326
+ console.log(plan.command);
327
+ console.log("");
328
+ }
329
+ }
294
330
  // Summary
295
331
  console.log("────────────────────────────────");
296
332
  console.log("Summary");
@@ -0,0 +1,121 @@
1
+ import { severityOrder } from "../constants.js";
2
+ import { compareVersions, looksLikeVersion } from "../utils/version.js";
3
+ export function buildSuggestedFixCommandPlan(findings, scanInput) {
4
+ const packageManager = inferPackageManager(scanInput);
5
+ if (!packageManager)
6
+ return null;
7
+ const urgentFindings = [...findings]
8
+ .filter(f => f.severity === "critical" || f.severity === "high")
9
+ .sort((a, b) => {
10
+ const sevDelta = severityOrder[b.severity] - severityOrder[a.severity];
11
+ if (sevDelta !== 0)
12
+ return sevDelta;
13
+ const relScore = (finding) => finding.relationship === "direct" ? 1 : 0;
14
+ const relDelta = relScore(b) - relScore(a);
15
+ if (relDelta !== 0)
16
+ return relDelta;
17
+ return a.pkg.name.localeCompare(b.pkg.name);
18
+ });
19
+ const targetsByPackage = new Map();
20
+ const skippedByKey = new Map();
21
+ for (const finding of urgentFindings) {
22
+ if (finding.relationship === "direct") {
23
+ if (finding.firstFixedVersion) {
24
+ upsertTarget(targetsByPackage, {
25
+ package: finding.pkg.name,
26
+ targetVersion: finding.firstFixedVersion,
27
+ kind: "direct",
28
+ reason: `Direct upgrade target for ${finding.pkg.name}@${finding.pkg.version}`,
29
+ });
30
+ }
31
+ else {
32
+ skippedByKey.set(`${finding.relationship}:${finding.pkg.name}@${finding.pkg.version}`, {
33
+ package: finding.pkg.name,
34
+ version: finding.pkg.version,
35
+ relationship: finding.relationship,
36
+ reason: "No safe upgrade target is known for this urgent direct dependency.",
37
+ });
38
+ }
39
+ continue;
40
+ }
41
+ if (finding.relationship === "transitive" && finding.recommendedParentUpgrade) {
42
+ upsertTarget(targetsByPackage, {
43
+ package: finding.recommendedParentUpgrade.package,
44
+ targetVersion: finding.recommendedParentUpgrade.targetVersion,
45
+ kind: "parent-upgrade",
46
+ reason: `Parent upgrade for vulnerable ${finding.pkg.name}@${finding.pkg.version}`,
47
+ });
48
+ continue;
49
+ }
50
+ skippedByKey.set(`${finding.relationship}:${finding.pkg.name}@${finding.pkg.version}`, {
51
+ package: finding.pkg.name,
52
+ version: finding.pkg.version,
53
+ relationship: finding.relationship,
54
+ reason: finding.relationship === "transitive"
55
+ ? "No specific parent upgrade target was found for this urgent transitive issue."
56
+ : "No confident automatic fix command could be generated for this issue.",
57
+ });
58
+ }
59
+ const targets = [...targetsByPackage.values()].sort((a, b) => {
60
+ const kindScore = (target) => target.kind === "direct" ? 1 : 0;
61
+ const kindDelta = kindScore(b) - kindScore(a);
62
+ if (kindDelta !== 0)
63
+ return kindDelta;
64
+ return a.package.localeCompare(b.package);
65
+ });
66
+ const skipped = [...skippedByKey.values()].sort((a, b) => a.package.localeCompare(b.package));
67
+ const command = targets.length > 0
68
+ ? `${commandPrefix(packageManager)} ${targets.map(target => `${target.package}@${target.targetVersion}`).join(" ")}`
69
+ : null;
70
+ return {
71
+ packageManager,
72
+ sourceLabel: packageManagerSourceLabel(scanInput),
73
+ command,
74
+ targets,
75
+ skipped,
76
+ };
77
+ }
78
+ function inferPackageManager(scanInput) {
79
+ if (scanInput.source === "package-lock")
80
+ return "npm";
81
+ if (scanInput.source === "pnpm-lock")
82
+ return "pnpm";
83
+ if (scanInput.source === "yarn-lock")
84
+ return "yarn";
85
+ return null;
86
+ }
87
+ function commandPrefix(packageManager) {
88
+ if (packageManager === "npm")
89
+ return "npm install";
90
+ if (packageManager === "pnpm")
91
+ return "pnpm add";
92
+ return "yarn add";
93
+ }
94
+ function packageManagerSourceLabel(scanInput) {
95
+ if (scanInput.filePath) {
96
+ return scanInput.filePath.split(/[/\\]/).pop() ?? scanInput.source;
97
+ }
98
+ if (scanInput.source === "package-lock")
99
+ return "package-lock.json";
100
+ if (scanInput.source === "pnpm-lock")
101
+ return "pnpm-lock.yaml";
102
+ if (scanInput.source === "yarn-lock")
103
+ return "yarn.lock";
104
+ return scanInput.source;
105
+ }
106
+ function upsertTarget(targetsByPackage, next) {
107
+ const existing = targetsByPackage.get(next.package);
108
+ if (!existing) {
109
+ targetsByPackage.set(next.package, next);
110
+ return;
111
+ }
112
+ if (looksLikeVersion(existing.targetVersion) && looksLikeVersion(next.targetVersion)) {
113
+ if (compareVersions(next.targetVersion, existing.targetVersion) > 0) {
114
+ targetsByPackage.set(next.package, next);
115
+ }
116
+ return;
117
+ }
118
+ if (next.kind === "direct" && existing.kind !== "direct") {
119
+ targetsByPackage.set(next.package, next);
120
+ }
121
+ }
@@ -0,0 +1,12 @@
1
+ import fs from "node:fs";
2
+ export function getCliVersion() {
3
+ try {
4
+ const packageJsonPath = new URL("../../package.json", import.meta.url);
5
+ const raw = fs.readFileSync(packageJsonPath, "utf8");
6
+ const parsed = JSON.parse(raw);
7
+ return parsed.version ?? "0.0.0";
8
+ }
9
+ catch {
10
+ return "0.0.0";
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Developer-friendly CLI for scanning JS/TS projects for dependency vulnerabilities using local lockfiles and OSV",
5
5
  "type": "module",
6
6
  "bin": {