cve-lite-cli 1.9.0 โ 1.10.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 +132 -84
- package/dist/output/formatters.js +8 -9
- package/dist/output/html-reporter.js +103 -10
- package/dist/output/printers.js +50 -18
- package/dist/remediation/fix-commands.js +15 -1
- package/dist/utils/finding.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
**๐ Officially recognized as an [OWASP Incubator Project](https://owasp.org/cve-lite-cli)**
|
|
18
18
|
|
|
19
|
-
<p>
|
|
19
|
+
<p>Vulnerability scanning that belongs in your terminal โ not your CI pipeline.<br/>Scan your lockfile, get copy-and-run fix commands, and ship clean code.</p>
|
|
20
20
|
|
|
21
21
|
<strong>Scan. Understand. Fix.</strong>
|
|
22
22
|
|
|
@@ -45,6 +45,24 @@
|
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
48
|
+
## The problem with how security scanning works today
|
|
49
|
+
|
|
50
|
+
Most security tooling is designed around pipelines, not people.
|
|
51
|
+
|
|
52
|
+
Dependabot files PRs you'll get to eventually. CI scanners block merges hours after the fact. Security dashboards surface a list of CVE IDs with no clear path to resolving them. By the time a developer is looking at a scan result, the code has already been reviewed and is waiting to ship.
|
|
53
|
+
|
|
54
|
+
The feedback loop is too slow to be useful, and too noisy to be trusted. Developers learn to ignore it.
|
|
55
|
+
|
|
56
|
+
There is also a more fundamental problem: these tools tell you what is vulnerable. Very few tell you what to actually do about it. The result is a gap between detection and remediation that security teams paper over with manual triage, and developers experience as alert fatigue.
|
|
57
|
+
|
|
58
|
+
## A different model
|
|
59
|
+
|
|
60
|
+
CVE Lite CLI is built around a different idea: **vulnerability scanning belongs at the developer's terminal, not at the end of a pipeline.**
|
|
61
|
+
|
|
62
|
+
It reads your lockfile locally, queries [OSV](https://osv.dev) for advisory data, and produces a concrete remediation plan โ not a list of identifiers. You get copy-and-run `npm install`, `pnpm add`, `yarn add`, or `bun add` commands scoped to your package manager. You see exactly which packages are directly installed versus pulled in transitively. You can scan with no internet connection in restricted-network environments.
|
|
63
|
+
|
|
64
|
+
The tool is designed for the moment right before you push: fast, honest, and actionable.
|
|
65
|
+
|
|
48
66
|
## Quick start
|
|
49
67
|
|
|
50
68
|
```bash
|
|
@@ -58,39 +76,18 @@ Or one-off with `npx`:
|
|
|
58
76
|
npx cve-lite-cli /path/to/project
|
|
59
77
|
```
|
|
60
78
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
CVE Lite CLI scans JavaScript and TypeScript projects for known dependency vulnerabilities and tells you what to fix first. It reads your lockfile locally, queries [OSV](https://osv.dev) for advisory data, and produces a practical remediation plan โ not just a list of advisory IDs.
|
|
79
|
+
No account. No configuration. No source code leaves your machine.
|
|
64
80
|
|
|
65
|
-
|
|
81
|
+
## What it does
|
|
66
82
|
|
|
67
|
-
**
|
|
68
|
-
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
71
|
-
- **
|
|
72
|
-
- **
|
|
73
|
-
- **
|
|
74
|
-
- **
|
|
75
|
-
|
|
76
|
-
## How it compares
|
|
77
|
-
|
|
78
|
-
| Capability | CVE Lite CLI | npm audit | OSV-Scanner | Snyk CLI | Socket CLI |
|
|
79
|
-
|---|:---:|:---:|:---:|:---:|:---:|
|
|
80
|
-
| JS/TS lockfile scanning | โ
| โ
| โ
| โ
| โ
|
|
|
81
|
-
| npm + pnpm + Yarn + Bun support | โ
| โ | โ
| โ
| โ
|
|
|
82
|
-
| No account required | โ
| โ
| โ
| โ | โ |
|
|
83
|
-
| Free to use | โ
| โ
| โ
| โ | โ |
|
|
84
|
-
| Usage-aware reachability scanning | โ
| โ | โ | โ
| โ ๏ธ |
|
|
85
|
-
| Direct vs transitive visibility | โ
| โ ๏ธ | โ
| โ
| โ
|
|
|
86
|
-
| Copy-and-run fix commands | โ
| โ | โ | โ
| โ ๏ธ |
|
|
87
|
-
| Suggested remediation plan | โ
| โ | โ ๏ธ | โ
| โ ๏ธ |
|
|
88
|
-
| JSON output | โ
| โ
| โ
| โ
| โ
|
|
|
89
|
-
| Offline/local advisory DB | โ
| โ | โ ๏ธ | โ | โ |
|
|
90
|
-
|
|
91
|
-
<sub>โ
= built-in strength ยท โ ๏ธ = partial or workflow-dependent ยท โ = not a core strength</sub>
|
|
92
|
-
|
|
93
|
-
For detailed per-tool analysis, see [Comparison with other tools](docs/comparison.md).
|
|
83
|
+
- **Produces copy-and-run fix commands** โ every finding comes with a package-manager-aware install command you can run immediately
|
|
84
|
+
- **Distinguishes direct from transitive risk** โ shows whether the vulnerability is in something you installed or buried three levels deep in a dependency chain
|
|
85
|
+
- **Usage-aware reachability** โ optionally uses static analysis to detect whether vulnerable packages are actually imported in your code, cutting noise with `--usage` and `--only-used`
|
|
86
|
+
- **Offline advisory DB** โ sync advisory data ahead of time and scan with zero runtime API calls, designed for enterprise and air-gapped environments
|
|
87
|
+
- **Interactive HTML report** โ generate a self-contained dashboard with severity cards, a searchable findings table, and copy-ready fix commands (`--report`)
|
|
88
|
+
- **Auto-fix mode** โ apply validated direct dependency fixes and rescan automatically (`--fix`)
|
|
89
|
+
- **CI-ready** โ `--fail-on high` exits non-zero on findings at or above a severity threshold; a first-party [GitHub Action](https://github.com/marketplace/actions/cve-lite-cli) is available on the Marketplace
|
|
90
|
+
- **Minimal footprint** โ four runtime dependencies, intentionally kept small for a security tool
|
|
94
91
|
|
|
95
92
|
## What it looks like
|
|
96
93
|
|
|
@@ -126,16 +123,97 @@ For detailed per-tool analysis, see [Comparison with other tools](docs/compariso
|
|
|
126
123
|
</p>
|
|
127
124
|
</details>
|
|
128
125
|
|
|
129
|
-
##
|
|
126
|
+
## Workflow integration
|
|
130
127
|
|
|
131
|
-
|
|
128
|
+
CVE Lite CLI fits at every stage of the development workflow, not just CI.
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
**Local development** โ run a scan before opening a PR. The default output is fast and minimal. `--verbose` adds the full fix plan with dependency paths and prioritized remediation commands. `--report` opens an interactive HTML dashboard.
|
|
131
|
+
|
|
132
|
+
**CI pipelines** โ use `--fail-on high` to gate builds on severity. JSON output (`--json`) integrates with SIEM, dashboards, and custom automation. SARIF output is on the roadmap for direct integration with GitHub Security.
|
|
133
|
+
|
|
134
|
+
**Restricted and enterprise environments** โ sync the advisory database ahead of time with `cve-lite advisories sync`, then scan offline with `--offline`. No runtime outbound calls during the scan. Syncing ~217,065 advisory records completes in under 9 seconds.
|
|
135
|
+
|
|
136
|
+
**GitHub Actions** โ a first-party action is available on the Marketplace:
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
- uses: OWASP/cve-lite-cli@v1
|
|
140
|
+
with:
|
|
141
|
+
verbose: "true"
|
|
142
|
+
fail-on: high
|
|
136
143
|
```
|
|
137
144
|
|
|
138
|
-
|
|
145
|
+
CVE Lite CLI scans its own dependencies in CI. See [`self-scan.yml`](https://github.com/OWASP/cve-lite-cli/blob/main/.github/workflows/self-scan.yml).
|
|
146
|
+
|
|
147
|
+
For full CI patterns including offline workflows, git hooks, and scripted automation, see the [CI and Workflow Integration guide](docs/ci-integration.md).
|
|
148
|
+
|
|
149
|
+
## How it compares
|
|
150
|
+
|
|
151
|
+
| Capability | CVE Lite CLI | npm audit | OSV-Scanner | Snyk CLI | Socket CLI |
|
|
152
|
+
|---|:---:|:---:|:---:|:---:|:---:|
|
|
153
|
+
| JS/TS lockfile scanning | โ
| โ
| โ
| โ
| โ
|
|
|
154
|
+
| npm + pnpm + Yarn + Bun support | โ
| โ | โ
| โ
| โ
|
|
|
155
|
+
| No account required | โ
| โ
| โ
| โ | โ |
|
|
156
|
+
| Free to use | โ
| โ
| โ
| โ | โ |
|
|
157
|
+
| Usage-aware reachability scanning | โ
| โ | โ | โ
| โ ๏ธ |
|
|
158
|
+
| Direct vs transitive visibility | โ
| โ ๏ธ | โ
| โ
| โ
|
|
|
159
|
+
| Copy-and-run fix commands | โ
| โ | โ | โ
| โ ๏ธ |
|
|
160
|
+
| Suggested remediation plan | โ
| โ | โ ๏ธ | โ
| โ ๏ธ |
|
|
161
|
+
| JSON output | โ
| โ
| โ
| โ
| โ
|
|
|
162
|
+
| Offline/local advisory DB | โ
| โ | โ ๏ธ | โ | โ |
|
|
163
|
+
|
|
164
|
+
<sub>โ
= built-in strength ยท โ ๏ธ = partial or workflow-dependent ยท โ = not a core strength</sub>
|
|
165
|
+
|
|
166
|
+
For detailed per-tool analysis, see [Comparison with other tools](docs/comparison.md).
|
|
167
|
+
|
|
168
|
+
## Real-world validation
|
|
169
|
+
|
|
170
|
+
CVE Lite CLI has been evaluated against real open-source projects to verify that it surfaces meaningful issues โ including non-obvious transitive vulnerabilities and complex upgrade paths โ not just low-signal advisory matches.
|
|
171
|
+
|
|
172
|
+
- [OWASP Juice Shop](docs/case-studies/owasp-juice-shop.md) โ scanning a deliberately vulnerable application with known dependency issues
|
|
173
|
+
- [NestJS](docs/case-studies/nestjs.md) โ working through a real transitive dependency remediation sequence across a widely-used Node.js framework
|
|
174
|
+
- [Analog](docs/case-studies/analog.md) โ scanning a modern pnpm v9 Angular monorepo (3,367 packages) with unexpected toolchain vulnerabilities
|
|
175
|
+
|
|
176
|
+
These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
180
|
+
## Recognized by OWASP
|
|
181
|
+
|
|
182
|
+
CVE Lite CLI is an [OWASP Incubator Project](https://owasp.org/cve-lite-cli), peer-reviewed and maintained under the Open Web Application Security Project Foundation. Being part of OWASP means:
|
|
183
|
+
|
|
184
|
+
- **Peer-reviewed** by security professionals
|
|
185
|
+
- **Community-driven** development and governance
|
|
186
|
+
- **Vendor-neutral** with no commercial platform required
|
|
187
|
+
- **Open source** with transparent security practices and a minimal dependency footprint
|
|
188
|
+
|
|
189
|
+
**Where it fits in the OWASP ecosystem:**
|
|
190
|
+
|
|
191
|
+
CVE Lite CLI fills a specific gap โ fast, local-first JS/TS dependency scanning close to release time โ that broader OWASP tools are not optimized for:
|
|
192
|
+
|
|
193
|
+
| Tool | Focus |
|
|
194
|
+
|---|---|
|
|
195
|
+
| CVE Lite CLI | Lockfile-first, local developer CLI, remediation-focused, JS/TS |
|
|
196
|
+
| OWASP Dependency-Check | Multi-language, SAST-style, broader ecosystem |
|
|
197
|
+
| OWASP dep-scan | Multi-language and environment, SBOM and cloud-native |
|
|
198
|
+
| OWASP Dependency-Track | Platform and SBOM management, not a local CLI |
|
|
199
|
+
|
|
200
|
+
CVE Lite CLI complements these tools. It is not a replacement for continuous monitoring or full SBOM management โ it is the fast local check you run before pushing.
|
|
201
|
+
|
|
202
|
+
## Philosophy
|
|
203
|
+
|
|
204
|
+
Security tooling has optimized heavily for breadth of detection and compliance reporting. That is useful at the platform level. It is the wrong model for the individual developer trying to ship clean code before end of day.
|
|
205
|
+
|
|
206
|
+
Detection without remediation creates work without resolution. A vulnerability report that ends with a list of CVE IDs shifts the burden entirely onto the developer: look up each advisory, figure out which version is safe, work out whether it is a direct or transitive dependency, and construct the right install command by hand. That friction is why security findings go unresolved.
|
|
207
|
+
|
|
208
|
+
CVE Lite CLI is built on the premise that **the closer a security tool is to the developer's natural workflow, the more likely it is to be used** โ and that a tool that surfaces a problem alongside the fix is more valuable than one that only surfaces the problem.
|
|
209
|
+
|
|
210
|
+
## What's next
|
|
211
|
+
|
|
212
|
+
The CLI is the foundation. The model โ local-first, actionable, developer-native โ extends naturally beyond the terminal.
|
|
213
|
+
|
|
214
|
+
JSON and SARIF outputs make findings consumable by editors, dashboards, and automated workflows today. The next phase of the project is oriented around tighter developer integration: surfacing vulnerabilities at the point of dependency installation, not just at scan time; deeper IDE integration; and team-level visibility without requiring a cloud platform.
|
|
215
|
+
|
|
216
|
+
See [roadmap.md](docs/roadmap.md) for the current plan.
|
|
139
217
|
|
|
140
218
|
## Usage
|
|
141
219
|
|
|
@@ -192,7 +270,7 @@ cve-lite --version
|
|
|
192
270
|
|
|
193
271
|
### Why is `--usage` an opt-in flag?
|
|
194
272
|
|
|
195
|
-
CVE Lite CLI is designed to be
|
|
273
|
+
CVE Lite CLI is designed to be fast. Scanning a lockfile is nearly instantaneous, whereas running static reachability analysis across thousands of source files takes significantly more time. Static analysis can also produce false negatives when packages are used in build scripts or dynamically imported at runtime. Making `--usage` opt-in ensures the default lockfile scan remains instant and strictly reflects your dependency graph, while giving you the option to aggressively filter out unreachable noise when triaging findings.
|
|
196
274
|
|
|
197
275
|
## Auto-fix mode (`--fix`)
|
|
198
276
|
|
|
@@ -210,6 +288,17 @@ npx cve-lite-cli /path/to/project --fix
|
|
|
210
288
|
|
|
211
289
|
See the [Fix mode guide](docs/fix-mode.md) for output details and interpretation.
|
|
212
290
|
|
|
291
|
+
## HTML vulnerability report (`--report`)
|
|
292
|
+
|
|
293
|
+
Generate a self-contained HTML dashboard from any scan โ severity cards, an interactive findings table with search, copy-ready fix commands, and breaking-change indicators on upgrades โ all written to a local directory and opened automatically in your browser.
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
cve-lite /path/to/project --report
|
|
297
|
+
cve-lite /path/to/project --report ./my-report --no-open
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
See the [HTML Report guide](docs/html-report.md) for the full option reference and output details.
|
|
301
|
+
|
|
213
302
|
## Offline support
|
|
214
303
|
|
|
215
304
|
For teams in enterprise, restricted-network, or air-gapped environments:
|
|
@@ -226,51 +315,6 @@ Syncing ~217,065 advisory records runs in under 9 seconds after bulk SQLite inge
|
|
|
226
315
|
|
|
227
316
|
See the [Offline Advisory DB guide](docs/offline-advisory-db.md) for the full workflow including CI, scheduled refresh, and controlled-network patterns.
|
|
228
317
|
|
|
229
|
-
## CI integration
|
|
230
|
-
|
|
231
|
-
The project ships a first-party [GitHub Action on the Marketplace](https://github.com/marketplace/actions/cve-lite-cli):
|
|
232
|
-
|
|
233
|
-
```yaml
|
|
234
|
-
- uses: OWASP/cve-lite-cli@v1
|
|
235
|
-
with:
|
|
236
|
-
verbose: "true"
|
|
237
|
-
fail-on: high
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
CVE Lite CLI also uses itself in CI to scan its own dependencies. See [`self-scan.yml`](https://github.com/OWASP/cve-lite-cli/blob/main/.github/workflows/self-scan.yml).
|
|
241
|
-
|
|
242
|
-
For full CI patterns including offline workflows, git hooks, and scripted automation, see the [CI and Workflow Integration guide](docs/ci-integration.md).
|
|
243
|
-
|
|
244
|
-
## Recognized by OWASP
|
|
245
|
-
|
|
246
|
-
CVE Lite CLI is an [OWASP Incubator Project](https://owasp.org/cve-lite-cli), peer-reviewed and maintained under the Open Web Application Security Project Foundation. Being part of OWASP means:
|
|
247
|
-
|
|
248
|
-
- **Peer-reviewed** by security professionals
|
|
249
|
-
- **Community-driven** development and governance
|
|
250
|
-
- **Vendor-neutral** with no commercial platform required
|
|
251
|
-
- **Open source** with transparent security practices and a minimal dependency footprint
|
|
252
|
-
|
|
253
|
-
**Where it fits in the OWASP ecosystem:**
|
|
254
|
-
|
|
255
|
-
CVE Lite CLI fills a specific gap โ fast, local-first JS/TS dependency scanning close to release time โ that broader OWASP tools are not optimized for:
|
|
256
|
-
|
|
257
|
-
| Tool | Focus |
|
|
258
|
-
|---|---|
|
|
259
|
-
| CVE Lite CLI | Lockfile-first, local developer CLI, remediation-focused, JS/TS |
|
|
260
|
-
| OWASP Dependency-Check | Multi-language, SAST-style, broader ecosystem |
|
|
261
|
-
| OWASP dep-scan | Multi-language and environment, SBOM and cloud-native |
|
|
262
|
-
| OWASP Dependency-Track | Platform and SBOM management, not a local CLI |
|
|
263
|
-
|
|
264
|
-
CVE Lite CLI complements these tools. It is not a replacement for continuous monitoring or full SBOM management โ it is the fast local check you run before pushing.
|
|
265
|
-
|
|
266
|
-
## Real-world case studies
|
|
267
|
-
|
|
268
|
-
- [OWASP Juice Shop](docs/case-studies/owasp-juice-shop.md) โ scanning a deliberately vulnerable application with known dependency issues
|
|
269
|
-
- [NestJS](docs/case-studies/nestjs.md) โ working through a real transitive dependency remediation sequence
|
|
270
|
-
- [Analog](docs/case-studies/analog.md) โ scanning a modern pnpm v9 Angular monorepo (3,367 packages) with unexpected toolchain vulnerabilities
|
|
271
|
-
|
|
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.
|
|
273
|
-
|
|
274
318
|
## Who uses it
|
|
275
319
|
|
|
276
320
|
CVE Lite CLI is a good fit for:
|
|
@@ -339,6 +383,10 @@ For security-related reporting: [SECURITY.md](https://github.com/OWASP/cve-lite-
|
|
|
339
383
|
|
|
340
384
|
If CVE Lite CLI helps your release workflow, a [GitHub star](https://github.com/OWASP/cve-lite-cli) helps more developers find it.
|
|
341
385
|
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
*Most tools tell you what's wrong. CVE Lite CLI tells you what to run.*
|
|
389
|
+
|
|
342
390
|
## License
|
|
343
391
|
|
|
344
392
|
MIT
|
|
@@ -2,6 +2,7 @@ import { chalk } from "../utils/chalk.js";
|
|
|
2
2
|
import { severityOrder } from "../constants.js";
|
|
3
3
|
import { loadCache } from "../osv/cache.js";
|
|
4
4
|
import { inferSeverity } from "../osv/severity.js";
|
|
5
|
+
import { getPrimaryParent } from "../utils/finding.js";
|
|
5
6
|
export function formatSeverityLabel(severity) {
|
|
6
7
|
const lower = severity.toLowerCase();
|
|
7
8
|
if (lower === "critical")
|
|
@@ -23,12 +24,6 @@ export function formatRelationshipLabel(value) {
|
|
|
23
24
|
return chalk.yellow(value);
|
|
24
25
|
return chalk.gray(value);
|
|
25
26
|
}
|
|
26
|
-
export function getPrimaryParent(finding) {
|
|
27
|
-
const firstPath = finding.dependencyPaths?.[0];
|
|
28
|
-
if (!firstPath || firstPath.length < 3)
|
|
29
|
-
return null;
|
|
30
|
-
return firstPath[1] ?? null;
|
|
31
|
-
}
|
|
32
27
|
export function getRecommendedAction(finding) {
|
|
33
28
|
if (finding.relationship === "direct" && finding.firstFixedVersion) {
|
|
34
29
|
return `Upgrade ${finding.pkg.name} to ${finding.firstFixedVersion}+ in this project.`;
|
|
@@ -41,13 +36,13 @@ export function getRecommendedAction(finding) {
|
|
|
41
36
|
}
|
|
42
37
|
const parent = getPrimaryParent(finding);
|
|
43
38
|
if (parent && finding.firstFixedVersion) {
|
|
44
|
-
return `
|
|
39
|
+
return `Upgrade ${parent} โ no safe version was identified automatically. Check for a release that resolves ${finding.pkg.name} to ${finding.firstFixedVersion}+.`;
|
|
45
40
|
}
|
|
46
41
|
if (parent) {
|
|
47
42
|
return `Review ${parent}; it currently pulls in vulnerable ${finding.pkg.name}.`;
|
|
48
43
|
}
|
|
49
44
|
if (finding.firstFixedVersion) {
|
|
50
|
-
return `
|
|
45
|
+
return `No dependency path found for ${finding.pkg.name}. Inspect your lockfile to identify which package pulls it in.`;
|
|
51
46
|
}
|
|
52
47
|
return `Inspect the dependency path for ${finding.pkg.name} and choose the safest upgrade path.`;
|
|
53
48
|
}
|
|
@@ -94,8 +89,12 @@ export function summarizeNextAction(finding) {
|
|
|
94
89
|
if (finding.recommendedParentUpgrade) {
|
|
95
90
|
return `Upgrade ${finding.recommendedParentUpgrade.package} ${finding.recommendedParentUpgrade.currentVersion} -> ${finding.recommendedParentUpgrade.targetVersion}.`;
|
|
96
91
|
}
|
|
92
|
+
const parent = getPrimaryParent(finding);
|
|
93
|
+
if (parent && finding.firstFixedVersion) {
|
|
94
|
+
return `Upgrade ${parent} โ no safe version identified. Find a release resolving ${finding.pkg.name} to ${finding.firstFixedVersion}+.`;
|
|
95
|
+
}
|
|
97
96
|
if (finding.firstFixedVersion) {
|
|
98
|
-
return `
|
|
97
|
+
return `No dependency path found for ${finding.pkg.name}. Check your lockfile for which package pulls it in.`;
|
|
99
98
|
}
|
|
100
99
|
return `Inspect the parent dependency chain for ${finding.pkg.name} and choose the safest available upgrade.`;
|
|
101
100
|
}
|
|
@@ -4,6 +4,7 @@ import { spawn } from "node:child_process";
|
|
|
4
4
|
import { serializeFinding } from "./formatters.js";
|
|
5
5
|
import { LOGO_BASE64 } from "./logo-base64.js";
|
|
6
6
|
import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
|
|
7
|
+
import { isMajorVersionBump } from "../utils/version.js";
|
|
7
8
|
export function buildReportData(params) {
|
|
8
9
|
return {
|
|
9
10
|
projectPath: params.projectPath,
|
|
@@ -27,6 +28,7 @@ export function renderHtmlReport(data) {
|
|
|
27
28
|
if (sev in counts)
|
|
28
29
|
counts[sev]++;
|
|
29
30
|
}
|
|
31
|
+
const noticesHtml = renderNotices(data.notes, data.warnings);
|
|
30
32
|
const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
|
|
31
33
|
const findingRowsHtml = data.findings.map(renderFindingRow).join("\n");
|
|
32
34
|
const dataJson = JSON.stringify(data)
|
|
@@ -58,6 +60,8 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
58
60
|
.header-links{display:flex;gap:8px}
|
|
59
61
|
.header-link{display:flex;align-items:center;gap:5px;font-size:12px;color:#8b949e;text-decoration:none;background:#21262d;border:1px solid #30363d;border-radius:6px;padding:5px 10px}
|
|
60
62
|
.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
63
|
+
button.header-link{cursor:pointer;border:1px solid #30363d;font:inherit;background:#21262d;color:#8b949e}
|
|
64
|
+
button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
61
65
|
.header-link.owasp-link{color:#F68B1F;border-color:#F68B1F44}.header-link.owasp-link:hover{color:#F68B1F;border-color:#F68B1F;background:#F68B1F11}
|
|
62
66
|
.summary-bar{padding:20px 32px;display:flex;gap:12px;border-bottom:1px solid #21262d}
|
|
63
67
|
.sev-card{flex:1;background:#161b22;border:1px solid #30363d;border-radius:8px;padding:14px 16px;display:flex;flex-direction:column;gap:4px}
|
|
@@ -96,6 +100,10 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
96
100
|
.filter-btn{font-size:11px;border-radius:20px;padding:4px 12px;border:1px solid #30363d;background:transparent;color:#8b949e;cursor:pointer}
|
|
97
101
|
.filter-btn:hover{border-color:#58a6ff;color:#58a6ff}
|
|
98
102
|
.filter-btn.active{background:#1f6feb22;border-color:#58a6ff;color:#58a6ff}
|
|
103
|
+
.search-input{font-size:12px;background:#0d1117;border:1px solid #30363d;border-radius:6px;color:#e6edf3;padding:4px 10px;width:200px;outline:none}
|
|
104
|
+
.search-input::placeholder{color:#6b7280}
|
|
105
|
+
.search-input:focus{border-color:#58a6ff}
|
|
106
|
+
.no-results{text-align:center;padding:32px;color:#8b949e;font-size:13px;display:none}
|
|
99
107
|
.findings-table{width:100%;border-collapse:collapse}
|
|
100
108
|
.findings-table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:#8b949e;padding:10px 14px;border-bottom:1px solid #21262d;background:#161b22;cursor:pointer;white-space:nowrap;user-select:none}
|
|
101
109
|
.findings-table thead th:hover{color:#e6edf3}
|
|
@@ -137,6 +145,24 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
137
145
|
.fix-cmd-inline code{flex:1;font-family:monospace;font-size:12px;color:#3fb950}
|
|
138
146
|
.fix-cmd-inline .copy-btn{font-size:11px;color:#8b949e;background:#21262d;border:1px solid #30363d;border-radius:4px;padding:3px 8px;cursor:pointer}
|
|
139
147
|
.report-footer{margin:0 32px 32px;padding:12px 0;border-top:1px solid #21262d;display:flex;justify-content:space-between;font-size:11px;color:#8b949e}
|
|
148
|
+
.scan-notes{margin:0 32px 16px}
|
|
149
|
+
.scan-notes-toggle{display:flex;align-items:center;gap:6px;font-size:11px;color:#8b949e;background:none;border:none;cursor:pointer;padding:0}
|
|
150
|
+
.scan-notes-toggle:hover{color:#e6edf3}
|
|
151
|
+
.scan-notes-toggle .arrow{font-size:9px;transition:transform .15s}
|
|
152
|
+
.scan-notes-toggle.open .arrow{transform:rotate(90deg)}
|
|
153
|
+
.scan-notes-body{display:none;margin-top:6px;padding:10px 14px;background:#161b22;border:1px solid #21262d;border-radius:6px}
|
|
154
|
+
.scan-notes-body.open{display:block}
|
|
155
|
+
.scan-notes-body ul{margin:0;padding:0 0 0 16px;display:flex;flex-direction:column;gap:3px}
|
|
156
|
+
.scan-notes-body li{font-size:11px;color:#8b949e;line-height:1.5}
|
|
157
|
+
.scan-notes-body li.warning{color:#e6b84a}
|
|
158
|
+
.fix-targets-list{display:flex;flex-direction:column;gap:4px;margin-top:6px;padding:8px 10px;background:#161b22;border:1px solid #21262d;border-radius:5px}
|
|
159
|
+
.fix-target-row{display:flex;align-items:center;gap:8px;font-size:11px;flex-wrap:wrap}
|
|
160
|
+
.fix-target-pkg{font-family:'SF Mono','Cascadia Code','Fira Code',monospace;color:#8b949e}
|
|
161
|
+
.fix-target-arrow{color:#8b949e}
|
|
162
|
+
.fix-target-to{font-family:'SF Mono','Cascadia Code','Fira Code',monospace;color:#3fb950}
|
|
163
|
+
.fix-target-stats{color:#6b7280;font-size:10px}
|
|
164
|
+
.fix-target-note{color:#6b7280;font-style:italic;font-size:10px}
|
|
165
|
+
.break-badge{font-size:10px;font-weight:700;background:#fb850022;color:#fb8500;border:1px solid #fb850066;border-radius:4px;padding:1px 5px}
|
|
140
166
|
</style>
|
|
141
167
|
</head>
|
|
142
168
|
<body>
|
|
@@ -163,6 +189,10 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
163
189
|
</div>
|
|
164
190
|
<div class="header-links">
|
|
165
191
|
<a class="header-link owasp-link" href="https://owasp.org/cve-lite-cli/" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.49332 261.50668" width="16" height="16" style="flex-shrink:0"><g transform="matrix(1.3333333,0,0,-1.3333333,0,261.50667)"><g transform="scale(0.1)"><path fill="#F68B1F" d="M 980.629,0 C 439.043,0 0,439.051 0,980.637 0,1522.22 439.043,1961.27 980.629,1961.27 1522.2,1961.27 1961.25,1522.22 1961.25,980.637 1961.25,439.051 1522.2,0 980.629,0 m -0.008,1810.35 c -458.226,0 -829.707,-371.48 -829.707,-829.705 0,-458.235 371.481,-829.715 829.707,-829.715 458.219,0 829.699,371.48 829.699,829.715 0,458.225 -371.48,829.705 -829.699,829.705"/><path fill="#F68B1F" d="m 1299.1,285.75 c -31.36,0.02 -145.64,203.41 -161,261.398 -32.11,121.411 -25.2,172.704 -23.28,189.102 5.88,50.07 54.46,75.09 57.4,142.801 0.91,20.91 11.47,125.449 19.9,207.109 -20.8,4.07 -41.52,13.45 -59.94,28 55.3,-74.17 -26.09,-163.058 -144.352,-281.332 C 862.305,707.309 583.695,590.809 583.695,590.809 c 0,0 116.508,278.613 242.024,404.132 92.269,92.259 166.636,162.079 230.101,162.079 17.89,0 34.92,-5.55 51.23,-17.7 -14.56,18.41 -23.93,39.12 -28.01,59.92 -81.661,-8.45 -186.208,-18.99 -207.106,-19.91 -67.719,-2.94 -92.743,-51.52 -142.782,-57.39 -5.761,-0.68 -15.828,-1.98 -31.722,-1.98 -29.367,0 -78.629,4.42 -157.387,25.27 -63.07,16.68 -298.078,150.37 -256.512,167.17 21.196,8.58 88.75,14.38 177.715,14.38 85.559,0 190.922,-5.36 293.844,-18.77 128.328,-16.72 246,-37.87 326.19,-53.6 1.3,4.31 2.86,8.5 4.73,12.57 l -81.98,39.29 c 0,0 -65.479,75.14 -58.487,80.32 0.27,0.2 0.613,0.3 1.023,0.3 10.27,0 62.654,-59.89 67.694,-66.71 3.88,-1.29 26.09,-8.7 49.45,-16.47 l -23.19,20.28 c 0,0 -31.74,117.55 -23.47,120.32 0.1,0.03 0.21,0.05 0.33,0.05 8.71,0 37.51,-102.22 39.98,-109.56 5.66,-4.96 24.78,-12.41 48.67,-26.19 l -25.12,64.62 c 0,0 11.37,106.61 19.88,106.61 0.07,0 0.13,-0.01 0.2,-0.02 8.57,-1.71 -1.68,-88.92 -3.85,-99.78 3.11,-4.77 22.38,-34.33 41.7,-63.97 11.89,4.48 24.68,6.69 37.81,6.69 15.07,0 30.57,-2.92 45.61,-8.67 -19.26,41.01 -17.8,83.75 7.74,109.27 8.08,8.1 17.9,13.75 28.84,17.1 1.32,7.46 4.78,14.54 10.45,20.22 7.39,7.38 17.12,11.05 26.97,11.05 10.31,0 20.76,-4.03 28.76,-12.04 7.67,-7.65 11.65,-17.54 11.99,-27.39 12.33,25.41 26.88,59.7 25.86,70.81 -2.37,25.14 -31.53,69.64 -31.8,70.09 -1.9,2.87 -1.11,6.75 1.78,8.66 1.05,0.69 2.24,1.02 3.42,1.02 2.03,0 4.02,-0.99 5.21,-2.82 1.29,-1.92 31.17,-47.54 33.83,-75.79 1.48,-16.16 -17.07,-56.88 -27.18,-77.68 14.2,-7.77 28.04,-18.03 40.68,-30.67 12.63,-12.63 22.89,-26.47 30.67,-40.68 20.01,9.73 58.4,27.26 75.71,27.26 0.69,0 1.35,-0.02 1.97,-0.08 28.24,-2.66 73.87,-32.54 75.78,-33.81 2.88,-1.89 3.68,-5.77 1.78,-8.65 -1.2,-1.82 -3.19,-2.81 -5.22,-2.81 -1.17,0 -2.36,0.33 -3.41,1.03 -0.45,0.29 -44.94,29.44 -70.09,31.79 -0.38,0.04 -0.79,0.05 -1.22,0.05 -12.23,0 -45.07,-13.97 -69.61,-25.89 9.87,-0.33 19.76,-4.33 27.4,-12 15.67,-15.65 16.1,-40.59 0.99,-55.7 -5.67,-5.68 -12.74,-9.17 -20.2,-10.47 -3.37,-10.95 -9.03,-20.77 -17.11,-28.85 -14.08,-14.09 -33.38,-20.84 -54.76,-20.84 -17.38,0 -36.13,4.47 -54.52,13.1 10.77,-28.12 11.59,-57.89 1.99,-83.41 29.62,-19.32 59.22,-38.6 63.96,-41.71 7.78,1.55 54.5,7.22 81.17,7.22 10.66,0 18.13,-0.9 18.61,-3.34 1.73,-8.56 -106.57,-20.12 -106.57,-20.12 l -64.63,25.15 c 13.79,-23.91 21.21,-43.02 26.18,-48.69 7.47,-2.5 112.26,-32.04 109.5,-40.31 -0.31,-0.96 -2.15,-1.37 -5.16,-1.37 -23.1,0 -115.14,24.85 -115.14,24.85 l -20.3,23.19 c 7.79,-23.37 15.18,-45.56 16.49,-49.45 7.1,-5.25 71.57,-61.7 66.4,-68.708 -0.27,-0.363 -0.71,-0.524 -1.32,-0.524 -11.31,0 -78.99,58.992 -78.99,58.992 l -39.3,81.99 c -4.06,-1.88 -8.26,-3.42 -12.58,-4.73 15.73,-80.19 36.89,-197.861 53.63,-326.181 27.34,-209.949 21.19,-429.969 4.39,-471.571 -1.35,-3.347 -3.46,-4.898 -6.2,-4.898"/></g></g></svg> An OWASP Foundation Project</a>
|
|
192
|
+
<button class="header-link" type="button" onclick="downloadReportJson()" aria-label="Download JSON report">
|
|
193
|
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M7.47 10.78a.75.75 0 0 0 1.06 0l3.75-3.75a.75.75 0 1 0-1.06-1.06L8.75 8.44V1.75a.75.75 0 1 0-1.5 0v6.69L4.78 5.97a.75.75 0 1 0-1.06 1.06l3.75 3.75ZM3.75 13a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z"/></svg>
|
|
194
|
+
Download JSON
|
|
195
|
+
</button>
|
|
166
196
|
<a class="header-link" href="https://github.com/OWASP/cve-lite-cli" target="_blank">
|
|
167
197
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
|
|
168
198
|
GitHub
|
|
@@ -180,16 +210,20 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
180
210
|
</div>
|
|
181
211
|
|
|
182
212
|
${fixPlanHtml}
|
|
213
|
+
${noticesHtml}
|
|
183
214
|
|
|
184
215
|
<div class="findings-section">
|
|
185
216
|
<div class="findings-header">
|
|
186
217
|
<h2>Findings</h2>
|
|
187
|
-
<div
|
|
188
|
-
<
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
218
|
+
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
|
|
219
|
+
<input class="search-input" type="text" id="findings-search" placeholder="Search package, version, CVEโฆ" oninput="applyFilters()" />
|
|
220
|
+
<div class="filter-bar">
|
|
221
|
+
<button class="filter-btn active" onclick="setFilter('all',this)">All (${data.findings.length})</button>
|
|
222
|
+
<button class="filter-btn" onclick="setFilter('critical',this)">Critical (${counts.critical})</button>
|
|
223
|
+
<button class="filter-btn" onclick="setFilter('high',this)">High (${counts.high})</button>
|
|
224
|
+
<button class="filter-btn" onclick="setFilter('medium',this)">Medium (${counts.medium})</button>
|
|
225
|
+
<button class="filter-btn" onclick="setFilter('direct',this)">Direct only</button>
|
|
226
|
+
</div>
|
|
193
227
|
</div>
|
|
194
228
|
</div>
|
|
195
229
|
<table class="findings-table" id="findings-table">
|
|
@@ -205,6 +239,7 @@ ${fixPlanHtml}
|
|
|
205
239
|
</thead>
|
|
206
240
|
<tbody id="findings-tbody">
|
|
207
241
|
${findingRowsHtml}
|
|
242
|
+
<tr id="no-results-row" style="display:none"><td colspan="6" class="no-results">No findings match your search.</td></tr>
|
|
208
243
|
</tbody>
|
|
209
244
|
</table>
|
|
210
245
|
</div>
|
|
@@ -221,6 +256,18 @@ let sortCol = 'severity';
|
|
|
221
256
|
let sortAsc = false;
|
|
222
257
|
let activeFilter = 'all';
|
|
223
258
|
|
|
259
|
+
function downloadReportJson() {
|
|
260
|
+
const blob = new Blob([JSON.stringify(reportData, null, 2)], { type: 'application/json' });
|
|
261
|
+
const url = URL.createObjectURL(blob);
|
|
262
|
+
const a = document.createElement('a');
|
|
263
|
+
a.href = url;
|
|
264
|
+
a.download = 'cve-lite-report.json';
|
|
265
|
+
document.body.appendChild(a);
|
|
266
|
+
a.click();
|
|
267
|
+
document.body.removeChild(a);
|
|
268
|
+
URL.revokeObjectURL(url);
|
|
269
|
+
}
|
|
270
|
+
|
|
224
271
|
function toggleRow(idx) {
|
|
225
272
|
const detail = document.getElementById('detail-' + idx);
|
|
226
273
|
const mainRow = document.getElementById('row-' + idx);
|
|
@@ -236,10 +283,12 @@ function setFilter(filter, btn) {
|
|
|
236
283
|
activeFilter = filter;
|
|
237
284
|
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
|
|
238
285
|
btn.classList.add('active');
|
|
239
|
-
|
|
286
|
+
applyFilters();
|
|
240
287
|
}
|
|
241
288
|
|
|
242
|
-
function
|
|
289
|
+
function applyFilters() {
|
|
290
|
+
const query = (document.getElementById('findings-search').value || '').toLowerCase().trim();
|
|
291
|
+
let visibleCount = 0;
|
|
243
292
|
reportData.findings.forEach((f, i) => {
|
|
244
293
|
const mainRow = document.getElementById('row-' + i);
|
|
245
294
|
const detailRow = document.getElementById('detail-' + i);
|
|
@@ -248,6 +297,10 @@ function applyFilter() {
|
|
|
248
297
|
else if (activeFilter === 'high') visible = f.severity === 'high';
|
|
249
298
|
else if (activeFilter === 'medium') visible = f.severity === 'medium';
|
|
250
299
|
else if (activeFilter === 'direct') visible = f.relationship === 'direct';
|
|
300
|
+
if (visible && query) {
|
|
301
|
+
const ids = [...(f.cves || []), ...(f.vulnerabilities || []).map(v => v.id)].join(' ').toLowerCase();
|
|
302
|
+
visible = f.package.toLowerCase().includes(query) || f.version.toLowerCase().includes(query) || ids.includes(query);
|
|
303
|
+
}
|
|
251
304
|
if (mainRow) mainRow.style.display = visible ? '' : 'none';
|
|
252
305
|
if (detailRow && !visible) {
|
|
253
306
|
detailRow.classList.remove('visible');
|
|
@@ -255,7 +308,10 @@ function applyFilter() {
|
|
|
255
308
|
const icon = document.getElementById('icon-' + i);
|
|
256
309
|
if (icon) icon.textContent = 'โถ';
|
|
257
310
|
}
|
|
311
|
+
if (visible) visibleCount++;
|
|
258
312
|
});
|
|
313
|
+
const noResults = document.getElementById('no-results-row');
|
|
314
|
+
if (noResults) noResults.style.display = visibleCount === 0 ? '' : 'none';
|
|
259
315
|
}
|
|
260
316
|
|
|
261
317
|
function sortBy(col) {
|
|
@@ -294,6 +350,11 @@ function toggleSkipped() {
|
|
|
294
350
|
});
|
|
295
351
|
}
|
|
296
352
|
|
|
353
|
+
function toggleNotes(btn) {
|
|
354
|
+
btn.classList.toggle('open');
|
|
355
|
+
btn.nextElementSibling.classList.toggle('open');
|
|
356
|
+
}
|
|
357
|
+
|
|
297
358
|
document.addEventListener('click', function(e) {
|
|
298
359
|
const btn = e.target.closest('.copy-btn');
|
|
299
360
|
if (btn && btn.dataset.cmd !== undefined) {
|
|
@@ -365,17 +426,49 @@ function renderFindingRow(finding, idx) {
|
|
|
365
426
|
</td>
|
|
366
427
|
</tr>`;
|
|
367
428
|
}
|
|
429
|
+
function renderNotices(notes, warnings) {
|
|
430
|
+
if (notes.length === 0 && warnings.length === 0)
|
|
431
|
+
return "";
|
|
432
|
+
const total = notes.length + warnings.length;
|
|
433
|
+
const items = [
|
|
434
|
+
...warnings.map(w => `<li class="warning">${escapeHtml(w)}</li>`),
|
|
435
|
+
...notes.map(n => `<li>${escapeHtml(n)}</li>`),
|
|
436
|
+
].join("\n");
|
|
437
|
+
return `<div class="scan-notes">
|
|
438
|
+
<button class="scan-notes-toggle" onclick="toggleNotes(this)"><span class="arrow">โถ</span> Scan notes (${total})</button>
|
|
439
|
+
<div class="scan-notes-body"><ul>${items}</ul></div>
|
|
440
|
+
</div>`;
|
|
441
|
+
}
|
|
368
442
|
function renderFixPlan(plan) {
|
|
369
443
|
if (!plan || plan.sections.length === 0)
|
|
370
444
|
return "";
|
|
371
445
|
const directCount = plan.targets.filter(t => t.kind === "direct").length;
|
|
372
446
|
const skippedCount = plan.skipped.length;
|
|
373
|
-
const commandRows = plan.sections.map(section =>
|
|
447
|
+
const commandRows = plan.sections.map(section => {
|
|
448
|
+
const targetRows = section.targets.map(t => {
|
|
449
|
+
const isMajor = t.currentVersion ? isMajorVersionBump(t.currentVersion, t.targetVersion) : false;
|
|
450
|
+
const breakBadge = isMajor ? ` <span class="break-badge">โ breaking</span>` : "";
|
|
451
|
+
const versionHtml = t.currentVersion
|
|
452
|
+
? `<span class="fix-target-pkg">${escapeHtml(t.package)}@${escapeHtml(t.currentVersion)}</span><span class="fix-target-arrow">โ</span><span class="fix-target-to">${escapeHtml(t.targetVersion)}</span>`
|
|
453
|
+
: `<span class="fix-target-pkg">${escapeHtml(t.package)}</span><span class="fix-target-arrow">โ</span><span class="fix-target-to">${escapeHtml(t.targetVersion)}</span>`;
|
|
454
|
+
const statsHtml = t.scannedVersions != null
|
|
455
|
+
? ` <span class="fix-target-stats">${t.scannedVersions} scanned${t.knownVulnerableVersions != null ? ` ยท ${t.knownVulnerableVersions} still vulnerable` : ""}</span>`
|
|
456
|
+
: "";
|
|
457
|
+
const noteHtml = t.adjusted && t.adjustmentNote
|
|
458
|
+
? ` <span class="fix-target-note">${escapeHtml(t.adjustmentNote)}</span>`
|
|
459
|
+
: "";
|
|
460
|
+
return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}</div>`;
|
|
461
|
+
}).join("\n");
|
|
462
|
+
const targetsHtml = section.targets.length > 0
|
|
463
|
+
? `<div class="fix-targets-list">${targetRows}</div>`
|
|
464
|
+
: "";
|
|
465
|
+
return `
|
|
374
466
|
<div class="fix-cmd">
|
|
375
467
|
<span class="cmd-text">${escapeHtml(section.command)}</span>
|
|
376
468
|
<span class="cmd-meta">${escapeHtml(section.title)}</span>
|
|
377
469
|
<button class="copy-btn" data-cmd="${escapeHtml(section.command)}">Copy</button>
|
|
378
|
-
</div
|
|
470
|
+
</div>${targetsHtml}`;
|
|
471
|
+
}).join("\n");
|
|
379
472
|
const skippedRows = plan.skipped.map(s => `
|
|
380
473
|
<div class="skipped-row">
|
|
381
474
|
<span class="skipped-pkg">${escapeHtml(s.package)}@${escapeHtml(s.version)}</span>
|
package/dist/output/printers.js
CHANGED
|
@@ -2,7 +2,8 @@ import { chalk, stripAnsi } from "../utils/chalk.js";
|
|
|
2
2
|
import { severityOrder } from "../constants.js";
|
|
3
3
|
import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
|
|
4
4
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getPrimaryParent } from "../utils/finding.js";
|
|
6
|
+
import { formatSeverityLabel, formatRelationshipLabel, getRecommendedAction, summarizeRisk, summarizeNextAction } from "./formatters.js";
|
|
6
7
|
export function printSummary(findings, packageCount, scanInput) {
|
|
7
8
|
if (findings.length === 0) {
|
|
8
9
|
if (scanInput.mode === "manifest-fallback") {
|
|
@@ -135,18 +136,31 @@ export function printSuggestedFixCommands(findings, scanInput) {
|
|
|
135
136
|
for (const section of plan.sections) {
|
|
136
137
|
console.log("");
|
|
137
138
|
console.log(colorFixSectionTitle(section.severity, section.title));
|
|
138
|
-
|
|
139
|
-
if (section.kind === "direct" || section.kind === "direct-adjusted" || (section.kind === "urgent" && hasDirectTargets)) {
|
|
139
|
+
if (section.kind === "direct" || section.kind === "direct-adjusted") {
|
|
140
140
|
const validationSummary = summarizeAdjustedValidation(section.targets);
|
|
141
141
|
const remainingNotes = [];
|
|
142
|
-
|
|
143
|
-
// is not truncated by widths derived from smaller non-urgent sections.
|
|
144
|
-
const tableWidths = section.kind === "urgent" ? undefined : sharedDirectTableWidths;
|
|
145
|
-
printDirectTargetsTable(section.targets, remainingNotes, validationSummary, tableWidths);
|
|
142
|
+
printDirectTargetsTable(section.targets, remainingNotes, validationSummary, sharedDirectTableWidths);
|
|
146
143
|
for (const note of remainingNotes) {
|
|
147
144
|
console.log(chalk.gray(` Note: ${note}`));
|
|
148
145
|
}
|
|
149
146
|
}
|
|
147
|
+
else if (section.kind === "urgent") {
|
|
148
|
+
const directTargets = section.targets.filter(t => t.kind === "direct");
|
|
149
|
+
const parentUpgradeTargets = section.targets.filter(t => t.kind === "parent-upgrade");
|
|
150
|
+
if (directTargets.length > 0) {
|
|
151
|
+
const validationSummary = summarizeAdjustedValidation(directTargets);
|
|
152
|
+
const remainingNotes = [];
|
|
153
|
+
// Urgent sections compute their own widths so the Breaking? column
|
|
154
|
+
// is not truncated by widths derived from smaller non-urgent sections.
|
|
155
|
+
printDirectTargetsTable(directTargets, remainingNotes, validationSummary, undefined);
|
|
156
|
+
for (const note of remainingNotes) {
|
|
157
|
+
console.log(chalk.gray(` Note: ${note}`));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (parentUpgradeTargets.length > 0) {
|
|
161
|
+
printParentUpgradeTargetsTable(parentUpgradeTargets, undefined);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
150
164
|
else if (shouldRenderParentUpgradeTable(section.targets)) {
|
|
151
165
|
printParentUpgradeTargetsTable(section.targets, sharedParentUpgradeTableWidths);
|
|
152
166
|
}
|
|
@@ -345,15 +359,29 @@ export function printCompactOutput(findings, scanInput) {
|
|
|
345
359
|
console.log(` ${chalk.gray(`Fix: upgrade ${finding.recommendedParentUpgrade.package} to ${finding.recommendedParentUpgrade.targetVersion}`)}`);
|
|
346
360
|
}
|
|
347
361
|
else if (finding.firstFixedVersion) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
362
|
+
let action;
|
|
363
|
+
if (finding.relationship === "direct") {
|
|
364
|
+
action = `upgrade to ${finding.firstFixedVersion}`;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
const parent = getPrimaryParent(finding);
|
|
368
|
+
action = parent
|
|
369
|
+
? `Upgrade ${parent} โ check for release resolving ${finding.pkg.name} to ${finding.firstFixedVersion}+`
|
|
370
|
+
: `No dependency path found โ inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
|
|
371
|
+
}
|
|
351
372
|
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
352
373
|
}
|
|
353
374
|
else {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
375
|
+
let action;
|
|
376
|
+
if (finding.relationship === "direct") {
|
|
377
|
+
action = "review and upgrade directly";
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
const parent = getPrimaryParent(finding);
|
|
381
|
+
action = parent
|
|
382
|
+
? `Upgrade ${parent} to resolve ${finding.pkg.name}`
|
|
383
|
+
: `No dependency path found โ inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
|
|
384
|
+
}
|
|
357
385
|
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
358
386
|
}
|
|
359
387
|
console.log("");
|
|
@@ -406,7 +434,7 @@ export function printCompactOutput(findings, scanInput) {
|
|
|
406
434
|
console.log(`Upgrade ${chalk.whiteBright(parent)} to resolve ${topFinding.pkg.name}`);
|
|
407
435
|
}
|
|
408
436
|
else {
|
|
409
|
-
console.log(`
|
|
437
|
+
console.log(`No dependency path found โ inspect lockfile to identify which package pulls in ${chalk.whiteBright(topFinding.pkg.name)}`);
|
|
410
438
|
}
|
|
411
439
|
}
|
|
412
440
|
if (plan) {
|
|
@@ -601,7 +629,8 @@ function printParentUpgradeTargetsTable(targets, widthsOverride) {
|
|
|
601
629
|
});
|
|
602
630
|
if (rows.length === 0)
|
|
603
631
|
return;
|
|
604
|
-
|
|
632
|
+
// Allow the Context column (index 4) up to 60 chars so reason text is not truncated.
|
|
633
|
+
const widths = widthsOverride ?? computeTableWidths(headers, rows, [40, 40, 40, 40, 60]);
|
|
605
634
|
const line = (left, mid, right) => left + widths.map(w => "โ".repeat(w + 2)).join(mid) + right;
|
|
606
635
|
console.log(line("โ", "โฌ", "โ"));
|
|
607
636
|
console.log(renderRow(headers, widths));
|
|
@@ -611,8 +640,11 @@ function printParentUpgradeTargetsTable(targets, widthsOverride) {
|
|
|
611
640
|
}
|
|
612
641
|
console.log(line("โ", "โด", "โ"));
|
|
613
642
|
}
|
|
614
|
-
function computeTableWidths(headers, rows) {
|
|
615
|
-
return headers.map((header, index) =>
|
|
643
|
+
function computeTableWidths(headers, rows, columnMaxWidths) {
|
|
644
|
+
return headers.map((header, index) => {
|
|
645
|
+
const maxWidth = columnMaxWidths?.[index] ?? 40;
|
|
646
|
+
return Math.min(maxWidth, Math.max(header.length, ...rows.map(row => stripAnsi(String(row[index])).length)));
|
|
647
|
+
});
|
|
616
648
|
}
|
|
617
649
|
function computeSharedDirectTableWidths(sections) {
|
|
618
650
|
const directSections = sections.filter(section => section.kind === "direct" || section.kind === "direct-adjusted");
|
|
@@ -666,5 +698,5 @@ function computeSharedParentUpgradeTableWidths(sections) {
|
|
|
666
698
|
]);
|
|
667
699
|
}
|
|
668
700
|
}
|
|
669
|
-
return computeTableWidths(headers, rows);
|
|
701
|
+
return computeTableWidths(headers, rows, [40, 40, 40, 40, 60]);
|
|
670
702
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { severityOrder } from "../constants.js";
|
|
2
2
|
import { compareVersions, looksLikeVersion } from "../utils/version.js";
|
|
3
|
+
import { getPrimaryParent } from "../utils/finding.js";
|
|
3
4
|
export function buildSuggestedFixCommandPlan(findings, scanInput) {
|
|
4
5
|
const packageManager = inferPackageManager(scanInput);
|
|
5
6
|
if (!packageManager)
|
|
@@ -126,12 +127,25 @@ export function buildSuggestedFixCommandPlan(findings, scanInput) {
|
|
|
126
127
|
});
|
|
127
128
|
continue;
|
|
128
129
|
}
|
|
130
|
+
const primaryParent = getPrimaryParent(finding);
|
|
131
|
+
if (finding.relationship === "transitive" && primaryParent) {
|
|
132
|
+
const fixClause = finding.firstFixedVersion
|
|
133
|
+
? ` โ check for a release that resolves ${finding.pkg.name} to ${finding.firstFixedVersion}+`
|
|
134
|
+
: "";
|
|
135
|
+
skippedByKey.set(`${finding.relationship}:${finding.pkg.name}@${finding.pkg.version}`, {
|
|
136
|
+
package: finding.pkg.name,
|
|
137
|
+
version: finding.pkg.version,
|
|
138
|
+
relationship: finding.relationship,
|
|
139
|
+
reason: `${finding.pkg.name}@${finding.pkg.version} is pulled in by ${primaryParent}. No safe upgrade version for ${primaryParent} was identified automatically${fixClause}.`,
|
|
140
|
+
});
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
129
143
|
skippedByKey.set(`${finding.relationship}:${finding.pkg.name}@${finding.pkg.version}`, {
|
|
130
144
|
package: finding.pkg.name,
|
|
131
145
|
version: finding.pkg.version,
|
|
132
146
|
relationship: finding.relationship,
|
|
133
147
|
reason: finding.relationship === "transitive"
|
|
134
|
-
?
|
|
148
|
+
? `No dependency path available for ${finding.pkg.name}@${finding.pkg.version}. Inspect your lockfile to find which package pulls it in.`
|
|
135
149
|
: "No confident automatic fix command could be generated for this issue.",
|
|
136
150
|
});
|
|
137
151
|
}
|