cve-lite-cli 1.23.0 → 1.23.1
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 +10 -6
- package/dist/output/cyclonedx.js +1 -1
- package/dist/output/html-reporter.js +1 -1
- package/dist/output/sarif.js +1 -1
- package/dist/parsers/npm-lock-graph.js +49 -17
- package/dist/remediation/npm-transitive-resolution.js +6 -2
- package/dist/remediation/parent-upgrade.js +12 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
[](https://owasp.org/cve-lite-cli)
|
|
3
3
|
[](https://www.npmjs.com/package/cve-lite-cli)
|
|
4
4
|
[](https://www.npmjs.com/package/cve-lite-cli)
|
|
5
5
|
[](https://github.com/OWASP/cve-lite-cli/actions)
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<h1>CVE Lite CLI</h1>
|
|
17
17
|
|
|
18
|
-
**🏆 Officially recognized as an [OWASP
|
|
18
|
+
**🏆 Officially recognized as an [OWASP Lab Project](https://owasp.org/cve-lite-cli)**
|
|
19
19
|
|
|
20
20
|
<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>
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<table>
|
|
27
27
|
<tr>
|
|
28
|
-
<td align="center" width="33%"><p>🏆</p><strong>OWASP
|
|
28
|
+
<td align="center" width="33%"><p>🏆</p><strong>OWASP Lab Project</strong><br/><sub>Peer-reviewed by the org behind the OWASP Top 10 —<br/>the security standard followed by millions of developers</sub></td>
|
|
29
29
|
<td align="center" width="33%"><p>🎯</p><strong>Remediation-first</strong><br/><sub>Validated fix commands + parent-aware<br/>transitive guidance — not just CVE IDs</sub></td>
|
|
30
30
|
<td align="center" width="33%"><p>🔒</p><strong>Runs locally</strong><br/><sub>Nothing leaves your machine — not your<br/>code, not your dependency tree</sub></td>
|
|
31
31
|
</tr>
|
|
@@ -226,8 +226,12 @@ CVE Lite CLI has been evaluated against real open-source projects to verify that
|
|
|
226
226
|
- [n8n](https://owasp.org/cve-lite-cli/docs/case-studies/n8n) — verified baseline scan of a workflow automation pnpm monorepo (3,746 packages, 32 findings at revision `e2e0394`) with one direct `turbo` fix, four command groups, and email/editor transitive clusters
|
|
227
227
|
- [CamoFox Browser](https://owasp.org/cve-lite-cli/docs/case-studies/camofox-browser) — verified baseline scan of an AI agent browser automation npm graph (435 packages, 2 findings at revision `ce3a3b0`) with dual `qs` fix strategies — within-range `npm update qs` and parent `npm install express@4.22.2`
|
|
228
228
|
- [Storybook](https://owasp.org/cve-lite-cli/docs/case-studies/storybook) — verified baseline scan of a Yarn Berry monorepo (3,008 packages, 92 findings at revision `cc19ae1`) spanning cross-framework sandbox templates, five critical transitive chains, and one direct vite fix command
|
|
229
|
+
- [Twenty](https://owasp.org/cve-lite-cli/docs/case-studies/twenty) — verified baseline scan of an open-source CRM Yarn Berry monorepo (5,451 packages, 105 findings at revision `fc90b4b`) with 0 direct findings, six critical test-stack chains, and four Nx parent-upgrade command groups
|
|
230
|
+
- [Strapi](https://owasp.org/cve-lite-cli/docs/case-studies/strapi) — verified baseline scan of a headless CMS Yarn Berry monorepo (2,887 packages, 18 findings) with two direct findings (`lodash`, `qs`) and mixed transitive remediation paths
|
|
231
|
+
- [Payload CMS](https://owasp.org/cve-lite-cli/docs/case-studies/payload) — verified baseline scan of a TypeScript-first headless CMS pnpm monorepo (2,602 packages, 18 findings) with one direct finding and workspace-scoped fix commands
|
|
232
|
+
- [Presenton](https://owasp.org/cve-lite-cli/docs/case-studies/presenton) — verified baseline scan of an AI presentation generator with dual npm lockfiles (root + Electron shell), demonstrating multi-lockfile coverage across 9 findings
|
|
229
233
|
|
|
230
|
-
In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, Gatsby, Vercel AI SDK, Mastra, Lit, LangChain.js, OpenAI Agents JS, n8n, CamoFox Browser, and
|
|
234
|
+
In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, Gatsby, Vercel AI SDK, Mastra, Lit, LangChain.js, OpenAI Agents JS, n8n, CamoFox Browser, Storybook, Twenty, Strapi, Payload CMS, and Presenton live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
|
|
231
235
|
|
|
232
236
|
These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
|
|
233
237
|
|
|
@@ -251,7 +255,7 @@ If you maintain an open-source JavaScript or TypeScript project and want CVE Lit
|
|
|
251
255
|
|
|
252
256
|
OWASP (Open Web Application Security Project) is the globally recognized nonprofit behind the security standards followed by millions of developers worldwide — most notably the [OWASP Top 10](https://owasp.org/www-project-top-ten/), the most widely cited web application security reference in the industry. Organizations from startups to Fortune 500 companies use OWASP guidelines as the foundation of their security programs.
|
|
253
257
|
|
|
254
|
-
CVE Lite CLI is an [OWASP
|
|
258
|
+
CVE Lite CLI is an [OWASP Lab Project](https://owasp.org/cve-lite-cli) — reviewed and accepted by the OWASP community as a vendor-neutral, open source security tool. Being part of OWASP means:
|
|
255
259
|
|
|
256
260
|
- **Peer-reviewed** by security professionals
|
|
257
261
|
- **Community-driven** development and governance
|
|
@@ -480,7 +484,7 @@ npm run build
|
|
|
480
484
|
|
|
481
485
|
## Governance
|
|
482
486
|
|
|
483
|
-
CVE Lite CLI is an OWASP
|
|
487
|
+
CVE Lite CLI is an OWASP Lab Project maintained by Sonu Kapoor as project lead. The project follows a single-maintainer (benevolent dictator) governance model. The project lead makes final decisions on scope, design direction, and releases after considering input from contributors and the wider community.
|
|
484
488
|
|
|
485
489
|
### Roles
|
|
486
490
|
|
package/dist/output/cyclonedx.js
CHANGED
|
@@ -90,7 +90,7 @@ export function writeCycloneDxReport(allPackages, findings, plan, projectMeta) {
|
|
|
90
90
|
try {
|
|
91
91
|
fs.rmSync(outputPath, { force: true });
|
|
92
92
|
}
|
|
93
|
-
catch { }
|
|
93
|
+
catch { /* best-effort cleanup */ }
|
|
94
94
|
throw new Error(`Failed to write CycloneDX report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
95
95
|
}
|
|
96
96
|
return filename;
|
|
@@ -609,7 +609,7 @@ export async function writeHtmlReport(params) {
|
|
|
609
609
|
try {
|
|
610
610
|
fs.rmSync(params.outputDir, { recursive: true, force: true });
|
|
611
611
|
}
|
|
612
|
-
catch { }
|
|
612
|
+
catch { /* best-effort cleanup */ }
|
|
613
613
|
}
|
|
614
614
|
throw new Error(`Failed to write HTML report to ${params.outputDir}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
615
615
|
}
|
package/dist/output/sarif.js
CHANGED
|
@@ -88,7 +88,7 @@ export function writeSarifReport(findings, lockfileUri, plan) {
|
|
|
88
88
|
try {
|
|
89
89
|
fs.rmSync(outputPath, { force: true });
|
|
90
90
|
}
|
|
91
|
-
catch { }
|
|
91
|
+
catch { /* best-effort cleanup */ }
|
|
92
92
|
throw new Error(`Failed to write SARIF report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
93
93
|
}
|
|
94
94
|
return filename;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { unique
|
|
2
|
+
import { unique } from "../utils/array.js";
|
|
3
3
|
export function loadNpmLockGraph(filePath, options) {
|
|
4
4
|
const raw = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
5
5
|
const packages = raw?.packages;
|
|
@@ -17,9 +17,9 @@ export function loadNpmLockGraph(filePath, options) {
|
|
|
17
17
|
return createGraph({
|
|
18
18
|
entryPackages: [],
|
|
19
19
|
nodesById,
|
|
20
|
-
nodeIdsByPackageKey,
|
|
21
|
-
parentNodeIdsByChildNodeId,
|
|
22
|
-
childNodeIdsByParentNodeId,
|
|
20
|
+
nodeIdsByPackageKey: setsToArrays(nodeIdsByPackageKey),
|
|
21
|
+
parentNodeIdsByChildNodeId: setsToArrays(parentNodeIdsByChildNodeId),
|
|
22
|
+
childNodeIdsByParentNodeId: setsToArrays(childNodeIdsByParentNodeId),
|
|
23
23
|
rangeByParentNodeId,
|
|
24
24
|
pathSetByNodeId,
|
|
25
25
|
});
|
|
@@ -46,7 +46,9 @@ export function loadNpmLockGraph(filePath, options) {
|
|
|
46
46
|
dev: !!meta?.dev,
|
|
47
47
|
});
|
|
48
48
|
nodeIdByPackagePath.set(packagePath, id);
|
|
49
|
-
|
|
49
|
+
const keySet = nodeIdsByPackageKey.get(packageKey) ?? new Set();
|
|
50
|
+
keySet.add(id);
|
|
51
|
+
nodeIdsByPackageKey.set(packageKey, keySet);
|
|
50
52
|
dependencyRangesByNodeId.set(id, collectDependencyRanges(resolveDependencySource(meta, rawPackages)));
|
|
51
53
|
resolutionBasePathsByNodeId.set(id, resolveBasePaths(packagePath, meta));
|
|
52
54
|
}
|
|
@@ -87,37 +89,56 @@ export function loadNpmLockGraph(filePath, options) {
|
|
|
87
89
|
return createGraph({
|
|
88
90
|
entryPackages,
|
|
89
91
|
nodesById,
|
|
90
|
-
nodeIdsByPackageKey,
|
|
91
|
-
parentNodeIdsByChildNodeId,
|
|
92
|
-
childNodeIdsByParentNodeId,
|
|
92
|
+
nodeIdsByPackageKey: setsToArrays(nodeIdsByPackageKey),
|
|
93
|
+
parentNodeIdsByChildNodeId: setsToArrays(parentNodeIdsByChildNodeId),
|
|
94
|
+
childNodeIdsByParentNodeId: setsToArrays(childNodeIdsByParentNodeId),
|
|
93
95
|
rangeByParentNodeId,
|
|
94
96
|
pathSetByNodeId,
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
99
|
function createGraph(args) {
|
|
98
100
|
const entryPackages = Object.freeze([...unique(args.entryPackages)]);
|
|
101
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
102
|
+
// Pre-freeze all node objects so getNode() returns a pre-computed frozen copy
|
|
103
|
+
const frozenNodesById = new Map();
|
|
104
|
+
for (const [id, node] of args.nodesById) {
|
|
105
|
+
frozenNodesById.set(id, Object.freeze({ ...node }));
|
|
106
|
+
}
|
|
107
|
+
// Pre-freeze all package-key -> nodeId arrays
|
|
108
|
+
const frozenNodeIdsByPackageKey = new Map();
|
|
109
|
+
for (const [key, ids] of args.nodeIdsByPackageKey) {
|
|
110
|
+
frozenNodeIdsByPackageKey.set(key, Object.freeze([...ids]));
|
|
111
|
+
}
|
|
112
|
+
// Pre-freeze all parent arrays
|
|
113
|
+
const frozenParentsByChild = new Map();
|
|
114
|
+
for (const [id, parents] of args.parentNodeIdsByChildNodeId) {
|
|
115
|
+
frozenParentsByChild.set(id, Object.freeze([...parents]));
|
|
116
|
+
}
|
|
117
|
+
// Pre-freeze all children arrays
|
|
118
|
+
const frozenChildrenByParent = new Map();
|
|
119
|
+
for (const [id, children] of args.childNodeIdsByParentNodeId) {
|
|
120
|
+
frozenChildrenByParent.set(id, Object.freeze([...children]));
|
|
121
|
+
}
|
|
99
122
|
return {
|
|
100
123
|
entryPackages,
|
|
101
124
|
nodeIdsFor(name, version) {
|
|
102
|
-
return
|
|
125
|
+
return frozenNodeIdsByPackageKey.get(buildPackageKey(name, version)) ?? EMPTY_ARRAY;
|
|
103
126
|
},
|
|
104
127
|
getNode(nodeId) {
|
|
105
|
-
|
|
106
|
-
return node ? Object.freeze({ ...node }) : null;
|
|
128
|
+
return frozenNodesById.get(nodeId) ?? null;
|
|
107
129
|
},
|
|
108
130
|
parentsFor(nodeId) {
|
|
109
|
-
return
|
|
131
|
+
return frozenParentsByChild.get(nodeId) ?? EMPTY_ARRAY;
|
|
110
132
|
},
|
|
111
133
|
childrenFor(nodeId) {
|
|
112
|
-
return
|
|
134
|
+
return frozenChildrenByParent.get(nodeId) ?? EMPTY_ARRAY;
|
|
113
135
|
},
|
|
114
136
|
rangeFor(parentNodeId, childName) {
|
|
115
137
|
return args.rangeByParentNodeId.get(parentNodeId)?.get(childName) ?? null;
|
|
116
138
|
},
|
|
117
139
|
pathsFor(nodeId) {
|
|
118
|
-
|
|
140
|
+
return [...(args.pathSetByNodeId.get(nodeId) ?? new Set())]
|
|
119
141
|
.map((item) => item.split(">"));
|
|
120
|
-
return uniquePathArrays(serializedPaths);
|
|
121
142
|
},
|
|
122
143
|
};
|
|
123
144
|
}
|
|
@@ -134,8 +155,12 @@ function resolveEdgesForParent(parentPackagePath, dependencyRanges, resolutionBa
|
|
|
134
155
|
const parentNodeId = parentPackagePath ? nodeIdByPackagePath.get(parentPackagePath) : null;
|
|
135
156
|
if (!parentNodeId)
|
|
136
157
|
continue;
|
|
137
|
-
|
|
138
|
-
|
|
158
|
+
const childSet = childNodeIdsByParentNodeId.get(parentNodeId) ?? new Set();
|
|
159
|
+
childSet.add(childNodeId);
|
|
160
|
+
childNodeIdsByParentNodeId.set(parentNodeId, childSet);
|
|
161
|
+
const parentSet = parentNodeIdsByChildNodeId.get(childNodeId) ?? new Set();
|
|
162
|
+
parentSet.add(parentNodeId);
|
|
163
|
+
parentNodeIdsByChildNodeId.set(childNodeId, parentSet);
|
|
139
164
|
const rangesForParent = rangeByParentNodeId.get(parentNodeId) ?? new Map();
|
|
140
165
|
rangesForParent.set(dependencyName, range);
|
|
141
166
|
rangeByParentNodeId.set(parentNodeId, rangesForParent);
|
|
@@ -214,6 +239,13 @@ function rememberPath(pathSetByNodeId, nodeId, pathParts) {
|
|
|
214
239
|
existing.add(serialized);
|
|
215
240
|
pathSetByNodeId.set(nodeId, existing);
|
|
216
241
|
}
|
|
242
|
+
function setsToArrays(map) {
|
|
243
|
+
const result = new Map();
|
|
244
|
+
for (const [key, set] of map) {
|
|
245
|
+
result.set(key, [...set]);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
217
249
|
function isRecord(value) {
|
|
218
250
|
return !!value && typeof value === "object";
|
|
219
251
|
}
|
|
@@ -14,6 +14,7 @@ export async function resolveTransitiveRemediationViaRegistry(args) {
|
|
|
14
14
|
const vulnerableName = args.finding.pkg.name;
|
|
15
15
|
const fixHint = args.finding.validatedFirstFixedVersion ?? args.finding.firstFixedVersion;
|
|
16
16
|
if (directParentName !== immediateParentName) {
|
|
17
|
+
const packagesByName = new Map(args.packages.map(p => [p.name, p]));
|
|
17
18
|
return resolveWithinRangeForDeepChainViaRegistry({
|
|
18
19
|
immediateParentName,
|
|
19
20
|
vulnerableName,
|
|
@@ -21,6 +22,7 @@ export async function resolveTransitiveRemediationViaRegistry(args) {
|
|
|
21
22
|
fixHint,
|
|
22
23
|
viaPath,
|
|
23
24
|
packages: args.packages,
|
|
25
|
+
packagesByName,
|
|
24
26
|
workspaceMap: args.workspaceMap,
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -68,6 +70,7 @@ export async function resolveNpmTransitiveRemediation(args) {
|
|
|
68
70
|
// immediate parent's declared range for the vulnerable package already covers a safe version.
|
|
69
71
|
// If so, a lockfile refresh of the vulnerable package itself is sufficient.
|
|
70
72
|
if (directParentName !== immediateParentName) {
|
|
73
|
+
const packagesByName = new Map(args.packages.map(p => [p.name, p]));
|
|
71
74
|
return resolveWithinRangeForDeepChain({
|
|
72
75
|
graph: args.graph,
|
|
73
76
|
immediateParentName,
|
|
@@ -76,6 +79,7 @@ export async function resolveNpmTransitiveRemediation(args) {
|
|
|
76
79
|
fixHint,
|
|
77
80
|
viaPath,
|
|
78
81
|
packages: args.packages,
|
|
82
|
+
packagesByName,
|
|
79
83
|
offline: args.offline,
|
|
80
84
|
});
|
|
81
85
|
}
|
|
@@ -301,7 +305,7 @@ function parseCoreVersion(version) {
|
|
|
301
305
|
return [Number(major), Number(minor), Number(patch)];
|
|
302
306
|
}
|
|
303
307
|
async function resolveWithinRangeForDeepChainViaRegistry(args) {
|
|
304
|
-
const immediateParent = args.
|
|
308
|
+
const immediateParent = args.packagesByName.get(args.immediateParentName);
|
|
305
309
|
if (!immediateParent || !looksLikeVersion(immediateParent.version))
|
|
306
310
|
return null;
|
|
307
311
|
const safeCandidates = await findSafeChildCandidates(args.vulnerableName, args.installedVersion, args.fixHint);
|
|
@@ -331,7 +335,7 @@ async function resolveWithinRangeForDeepChainViaRegistry(args) {
|
|
|
331
335
|
};
|
|
332
336
|
}
|
|
333
337
|
async function resolveWithinRangeForDeepChain(args) {
|
|
334
|
-
const immediateParent = args.
|
|
338
|
+
const immediateParent = args.packagesByName.get(args.immediateParentName);
|
|
335
339
|
if (!immediateParent || !looksLikeVersion(immediateParent.version))
|
|
336
340
|
return null;
|
|
337
341
|
const nodeIds = args.graph.nodeIdsFor(args.immediateParentName, immediateParent.version);
|
|
@@ -10,7 +10,8 @@ export async function resolveRecommendedParentUpgrade(finding, packages, directD
|
|
|
10
10
|
const viaPath = getBestPath(finding);
|
|
11
11
|
if (!viaPath || viaPath.length < 3)
|
|
12
12
|
return null;
|
|
13
|
-
const
|
|
13
|
+
const packagesByName = new Map(packages.map(p => [p.name, p]));
|
|
14
|
+
const directParentContext = resolveDirectParentContext(viaPath, packages, directDependencyNames, packagesByName);
|
|
14
15
|
if (!directParentContext)
|
|
15
16
|
return null;
|
|
16
17
|
const { directParentName, immediateParentName, directParent } = directParentContext;
|
|
@@ -49,13 +50,13 @@ function getBestPath(finding) {
|
|
|
49
50
|
return null;
|
|
50
51
|
return [...paths].sort((a, b) => a.length - b.length)[0] ?? null;
|
|
51
52
|
}
|
|
52
|
-
function findDirectDependency(packages, name, directDependencyNames) {
|
|
53
|
+
function findDirectDependency(packages, name, directDependencyNames, packagesByName) {
|
|
54
|
+
if (directDependencyNames?.has(name)) {
|
|
55
|
+
return packagesByName.get(name) ?? null;
|
|
56
|
+
}
|
|
53
57
|
for (const pkg of packages) {
|
|
54
58
|
if (pkg.name !== name)
|
|
55
59
|
continue;
|
|
56
|
-
if (directDependencyNames?.has(name)) {
|
|
57
|
-
return pkg;
|
|
58
|
-
}
|
|
59
60
|
const paths = pkg.paths ?? [];
|
|
60
61
|
if (paths.some(path => path.at(-1) === name && path.length >= 2)) {
|
|
61
62
|
return pkg;
|
|
@@ -63,7 +64,7 @@ function findDirectDependency(packages, name, directDependencyNames) {
|
|
|
63
64
|
}
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
|
-
function resolveDirectParentContext(viaPath, packages, directDependencyNames) {
|
|
67
|
+
function resolveDirectParentContext(viaPath, packages, directDependencyNames, packagesByName) {
|
|
67
68
|
const immediateParentName = viaPath[viaPath.length - 2];
|
|
68
69
|
const candidateSegments = viaPath.slice(1, -1);
|
|
69
70
|
const directParentCandidates = directDependencyNames
|
|
@@ -72,12 +73,16 @@ function resolveDirectParentContext(viaPath, packages, directDependencyNames) {
|
|
|
72
73
|
const directParentName = directParentCandidates[0];
|
|
73
74
|
if (!directParentName)
|
|
74
75
|
return null;
|
|
75
|
-
const directParent = findDirectDependency(packages, directParentName, directDependencyNames);
|
|
76
|
+
const directParent = findDirectDependency(packages, directParentName, directDependencyNames, packagesByName);
|
|
76
77
|
if (!directParent)
|
|
77
78
|
return null;
|
|
78
79
|
return { directParentName, immediateParentName, directParent };
|
|
79
80
|
}
|
|
80
81
|
function findPackageVersion(packages, name, pathPrefix) {
|
|
82
|
+
// Cannot use a name-keyed Map here: when the same package is installed at
|
|
83
|
+
// multiple versions (e.g. lodash@3 and lodash@4 on different paths), a Map
|
|
84
|
+
// would only hold one entry. We need path-aware iteration across all installed
|
|
85
|
+
// versions to find the right one for this specific dependency chain.
|
|
81
86
|
for (const pkg of packages) {
|
|
82
87
|
if (pkg.name !== name)
|
|
83
88
|
continue;
|