cve-lite-cli 1.5.4 → 1.7.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 +5 -4
- package/dist/index.js +5 -0
- package/dist/output/printers.js +12 -2
- package/dist/parsers/bun-lock.js +49 -0
- package/dist/parsers/index.js +32 -2
- package/dist/parsers/pnpm-lock.js +107 -4
- package/dist/remediation/fix-commands.js +6 -0
- package/dist/utils/file.js +3 -1
- package/dist/utils/version.js +5 -0
- package/package.json +3 -2
- package/dist/banner.js +0 -10
- package/dist/chalk.js +0 -44
- package/dist/osv/api.js +0 -26
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ It is built for the moment right before release: fast, local-first, and honest a
|
|
|
59
59
|
|
|
60
60
|
**Key differentiators:**
|
|
61
61
|
|
|
62
|
-
- **Copy-and-run fix commands** — turns findings into package-manager-aware `npm install`, `pnpm add`, or `
|
|
62
|
+
- **Copy-and-run fix commands** — turns findings into package-manager-aware `npm install`, `pnpm add`, `yarn add`, or `bun add` commands you can run immediately
|
|
63
63
|
- **Direct vs transitive visibility** — shows whether the risk comes from something you installed directly or a nested dependency
|
|
64
64
|
- **Offline advisory DB** — sync advisory data ahead of time and scan with zero runtime API calls, useful for enterprise and restricted-network environments
|
|
65
65
|
- **No account required** — no sign-up, no cloud dashboard, no source code upload
|
|
@@ -70,7 +70,7 @@ It is built for the moment right before release: fast, local-first, and honest a
|
|
|
70
70
|
| Capability | CVE Lite CLI | npm audit | OSV-Scanner | Snyk CLI | Socket CLI |
|
|
71
71
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
72
72
|
| JS/TS lockfile scanning | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
73
|
-
| npm + pnpm + Yarn support | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
73
|
+
| npm + pnpm + Yarn + Bun support | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
74
74
|
| No account required | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
75
75
|
| **Free to use** | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
76
76
|
| Direct vs transitive visibility | ✅ | ⚠️ | ✅ | ✅ | ✅ |
|
|
@@ -159,7 +159,7 @@ cve-lite --version
|
|
|
159
159
|
|
|
160
160
|
In the current version it:
|
|
161
161
|
- applies only direct dependency fixes with a validated lowest known non-vulnerable target
|
|
162
|
-
- uses `npm install`, `pnpm add`, or `
|
|
162
|
+
- uses `npm install`, `pnpm add`, `yarn add`, or `bun add` based on your lockfile
|
|
163
163
|
- rescans automatically after applying fixes
|
|
164
164
|
- does **not** auto-apply transitive overrides or guarantee application compatibility
|
|
165
165
|
|
|
@@ -216,6 +216,7 @@ CVE Lite CLI complements these tools by serving a practical developer workflow c
|
|
|
216
216
|
|
|
217
217
|
- [OWASP Juice Shop](docs/case-studies/owasp-juice-shop.md) — scanning a deliberately vulnerable application with known dependency issues
|
|
218
218
|
- [NestJS](docs/case-studies/nestjs.md) — working through a real transitive dependency remediation sequence
|
|
219
|
+
- [Analog](docs/case-studies/analog.md) — scanning a modern pnpm v9 Angular monorepo (3,367 packages) with unexpected toolchain vulnerabilities
|
|
219
220
|
|
|
220
221
|
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.
|
|
221
222
|
|
|
@@ -227,7 +228,7 @@ CVE Lite CLI is a good fit for:
|
|
|
227
228
|
- **Startups and small teams** — lightweight CI gate at no cost
|
|
228
229
|
- **Consultants** — run a scan on a client project in seconds, with a clear fix plan to hand over
|
|
229
230
|
- **Enterprise teams with restricted networks** — offline advisory DB workflow removes the need for runtime outbound calls during scans
|
|
230
|
-
- **Teams running npm, pnpm, and
|
|
231
|
+
- **Teams running npm, pnpm, Yarn, and Bun** — unified scanning across all four package managers in one tool
|
|
231
232
|
|
|
232
233
|
See the [CI and Workflow Integration guide](docs/ci-integration.md) for concrete patterns across these scenarios.
|
|
233
234
|
|
package/dist/index.js
CHANGED
|
@@ -327,6 +327,9 @@ function buildFixCommandParts(packageManager, targets) {
|
|
|
327
327
|
if (packageManager === "pnpm") {
|
|
328
328
|
return ["pnpm", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
329
329
|
}
|
|
330
|
+
if (packageManager === "bun") {
|
|
331
|
+
return ["bun", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
332
|
+
}
|
|
330
333
|
return ["yarn", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
331
334
|
}
|
|
332
335
|
async function runInstallCommand(command, args, cwd) {
|
|
@@ -350,6 +353,8 @@ function commandLabelForPackageManager(packageManager) {
|
|
|
350
353
|
return "npm install";
|
|
351
354
|
if (packageManager === "pnpm")
|
|
352
355
|
return "pnpm add";
|
|
356
|
+
if (packageManager === "bun")
|
|
357
|
+
return "bun add";
|
|
353
358
|
return "yarn add";
|
|
354
359
|
}
|
|
355
360
|
function countBySeverity(findings) {
|
package/dist/output/printers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { chalk, stripAnsi } from "../utils/chalk.js";
|
|
2
2
|
import { severityOrder } from "../constants.js";
|
|
3
3
|
import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
|
|
4
|
+
import { isMajorVersionBump } from "../utils/version.js";
|
|
4
5
|
import { formatSeverityLabel, formatRelationshipLabel, getPrimaryParent, getRecommendedAction, summarizeRisk, summarizeNextAction } from "./formatters.js";
|
|
5
6
|
export function printSummary(findings, packageCount, scanInput) {
|
|
6
7
|
if (findings.length === 0) {
|
|
@@ -134,7 +135,10 @@ export function printSuggestedFixCommands(findings, scanInput) {
|
|
|
134
135
|
if (section.kind === "direct" || section.kind === "direct-adjusted" || (section.kind === "urgent" && hasDirectTargets)) {
|
|
135
136
|
const validationSummary = summarizeAdjustedValidation(section.targets);
|
|
136
137
|
const remainingNotes = [];
|
|
137
|
-
|
|
138
|
+
// Urgent sections compute their own widths so the "breaking change" annotation
|
|
139
|
+
// is not truncated by widths derived from smaller non-urgent sections.
|
|
140
|
+
const tableWidths = section.kind === "urgent" ? undefined : sharedDirectTableWidths;
|
|
141
|
+
printDirectTargetsTable(section.targets, remainingNotes, validationSummary, tableWidths);
|
|
138
142
|
for (const note of remainingNotes) {
|
|
139
143
|
console.log(chalk.gray(` Note: ${note}`));
|
|
140
144
|
}
|
|
@@ -479,6 +483,8 @@ function packageManagerCommandPrefix(packageManager) {
|
|
|
479
483
|
return "npm install";
|
|
480
484
|
if (packageManager === "pnpm")
|
|
481
485
|
return "pnpm add";
|
|
486
|
+
if (packageManager === "bun")
|
|
487
|
+
return "bun add";
|
|
482
488
|
return "yarn add";
|
|
483
489
|
}
|
|
484
490
|
function summarizeAdjustedValidation(targets) {
|
|
@@ -503,10 +509,14 @@ function printDirectTargetsTable(targets, remainingNotes, validationSummary, wid
|
|
|
503
509
|
remainingNotes.push(target.adjustmentNote);
|
|
504
510
|
}
|
|
505
511
|
}
|
|
512
|
+
const isBreaking = !!target.currentVersion && isMajorVersionBump(target.currentVersion, target.targetVersion);
|
|
513
|
+
const targetCell = isBreaking
|
|
514
|
+
? chalk.cyan(target.targetVersion) + chalk.yellow(" (breaking change)")
|
|
515
|
+
: chalk.cyan(target.targetVersion);
|
|
506
516
|
return [
|
|
507
517
|
target.package,
|
|
508
518
|
target.currentVersion ?? "-",
|
|
509
|
-
|
|
519
|
+
targetCell,
|
|
510
520
|
target.scannedVersions !== null && target.scannedVersions !== undefined
|
|
511
521
|
? chalk.blue(String(target.scannedVersions))
|
|
512
522
|
: "-",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { upsertPackage } from "./utils.js";
|
|
3
|
+
function parseJsonc(text) {
|
|
4
|
+
// bun.lock uses JSONC (trailing commas). Strip them before parsing.
|
|
5
|
+
return JSON.parse(text.replace(/,(\s*[}\]])/g, "$1"));
|
|
6
|
+
}
|
|
7
|
+
export function loadFromBunLock(filePath, prodOnly) {
|
|
8
|
+
const raw = parseJsonc(fs.readFileSync(filePath, "utf8"));
|
|
9
|
+
const packages = raw?.packages ?? {};
|
|
10
|
+
const workspaces = raw?.workspaces ?? {};
|
|
11
|
+
const map = new Map();
|
|
12
|
+
// Collect direct dependency names from all workspaces to detect dev-only packages
|
|
13
|
+
const prodNames = new Set();
|
|
14
|
+
const devNames = new Set();
|
|
15
|
+
for (const workspace of Object.values(workspaces)) {
|
|
16
|
+
for (const name of Object.keys(workspace?.dependencies ?? {})) {
|
|
17
|
+
prodNames.add(name);
|
|
18
|
+
}
|
|
19
|
+
for (const name of Object.keys(workspace?.devDependencies ?? {})) {
|
|
20
|
+
devNames.add(name);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const [pkgName, entry] of Object.entries(packages)) {
|
|
24
|
+
if (!Array.isArray(entry) || entry.length < 1)
|
|
25
|
+
continue;
|
|
26
|
+
const nameAtVersion = String(entry[0] ?? "");
|
|
27
|
+
// Split on last @ to handle scoped packages (e.g. @babel/core@7.0.0)
|
|
28
|
+
const atIndex = nameAtVersion.lastIndexOf("@");
|
|
29
|
+
if (atIndex <= 0)
|
|
30
|
+
continue;
|
|
31
|
+
const name = nameAtVersion.slice(0, atIndex);
|
|
32
|
+
const version = nameAtVersion.slice(atIndex + 1);
|
|
33
|
+
if (!name || !version)
|
|
34
|
+
continue;
|
|
35
|
+
// A package is dev-only if it appears in devDependencies but not in dependencies
|
|
36
|
+
// (transitive packages not listed directly are treated as prod)
|
|
37
|
+
const dev = devNames.has(pkgName) && !prodNames.has(pkgName);
|
|
38
|
+
if (prodOnly && dev)
|
|
39
|
+
continue;
|
|
40
|
+
upsertPackage(map, {
|
|
41
|
+
name,
|
|
42
|
+
version,
|
|
43
|
+
ecosystem: "npm",
|
|
44
|
+
dev,
|
|
45
|
+
paths: [["project", name]],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return [...map.values()];
|
|
49
|
+
}
|
package/dist/parsers/index.js
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { findFiles, findNearestPackageJson, chooseBestLockfile, safeReadText, relativeOrName } from "../utils/file.js";
|
|
4
|
+
import { loadFromBunLock } from "./bun-lock.js";
|
|
4
5
|
import { loadFromPackageJson } from "./package-json.js";
|
|
5
6
|
import { loadFromPackageLock } from "./package-lock.js";
|
|
6
7
|
import { loadFromPnpmLock } from "./pnpm-lock.js";
|
|
7
8
|
import { loadFromYarnLock } from "./yarn-lock.js";
|
|
8
9
|
export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
10
|
+
const rootBunLock = path.join(projectRoot, "bun.lock");
|
|
9
11
|
const rootPackageLock = path.join(projectRoot, "package-lock.json");
|
|
10
12
|
const rootPnpmLock = path.join(projectRoot, "pnpm-lock.yaml");
|
|
11
13
|
const rootYarnLock = path.join(projectRoot, "yarn.lock");
|
|
14
|
+
if (fs.existsSync(rootBunLock)) {
|
|
15
|
+
return {
|
|
16
|
+
mode: "resolved-lockfile",
|
|
17
|
+
source: "bun-lock",
|
|
18
|
+
filePath: rootBunLock,
|
|
19
|
+
packages: loadFromBunLock(rootBunLock, prodOnly),
|
|
20
|
+
notes: [
|
|
21
|
+
"Scanned resolved dependency versions from bun.lock.",
|
|
22
|
+
"Dependency paths are approximated from the workspace dependency manifest."
|
|
23
|
+
],
|
|
24
|
+
warnings: [],
|
|
25
|
+
skippedDependencies: []
|
|
26
|
+
};
|
|
27
|
+
}
|
|
12
28
|
if (fs.existsSync(rootPackageLock)) {
|
|
13
29
|
return {
|
|
14
30
|
mode: "resolved-lockfile",
|
|
@@ -51,10 +67,24 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
|
51
67
|
skippedDependencies: []
|
|
52
68
|
};
|
|
53
69
|
}
|
|
54
|
-
const discoveredLockfiles = findFiles(projectRoot, ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"], maxDepth);
|
|
70
|
+
const discoveredLockfiles = findFiles(projectRoot, ["bun.lock", "package-lock.json", "pnpm-lock.yaml", "yarn.lock"], maxDepth);
|
|
55
71
|
if (discoveredLockfiles.length > 0) {
|
|
56
72
|
const selected = chooseBestLockfile(discoveredLockfiles);
|
|
57
73
|
const selectedName = path.basename(selected);
|
|
74
|
+
if (selectedName === "bun.lock") {
|
|
75
|
+
return {
|
|
76
|
+
mode: "resolved-lockfile",
|
|
77
|
+
source: "bun-lock",
|
|
78
|
+
filePath: selected,
|
|
79
|
+
packages: loadFromBunLock(selected, prodOnly),
|
|
80
|
+
notes: [
|
|
81
|
+
`Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
|
|
82
|
+
"Dependency paths are approximated from the workspace dependency manifest."
|
|
83
|
+
],
|
|
84
|
+
warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
|
|
85
|
+
skippedDependencies: []
|
|
86
|
+
};
|
|
87
|
+
}
|
|
58
88
|
if (selectedName === "package-lock.json") {
|
|
59
89
|
return {
|
|
60
90
|
mode: "resolved-lockfile",
|
|
@@ -136,7 +166,7 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
|
136
166
|
export function buildNoPackagesMessage(projectRoot) {
|
|
137
167
|
return [
|
|
138
168
|
"No scannable packages were found.",
|
|
139
|
-
"Supported inputs: package-lock.json, pnpm-lock.yaml, yarn.lock, or package.json with exact pinned versions.",
|
|
169
|
+
"Supported inputs: bun.lock, package-lock.json, pnpm-lock.yaml, yarn.lock, or package.json with exact pinned versions.",
|
|
140
170
|
`Searched under: ${projectRoot}`
|
|
141
171
|
].join(" ");
|
|
142
172
|
}
|
|
@@ -6,6 +6,10 @@ import { uniquePathArrays } from "../utils/array.js";
|
|
|
6
6
|
export function loadFromPnpmLock(filePath, prodOnly) {
|
|
7
7
|
const content = fs.readFileSync(filePath, "utf8");
|
|
8
8
|
const parsed = YAML.parse(content);
|
|
9
|
+
const majorVersion = parseInt(String(parsed?.lockfileVersion ?? "0"), 10);
|
|
10
|
+
return majorVersion >= 9 ? loadV9(parsed, prodOnly) : loadLegacy(parsed, prodOnly);
|
|
11
|
+
}
|
|
12
|
+
function loadLegacy(parsed, prodOnly) {
|
|
9
13
|
const packagesSection = parsed?.packages ?? {};
|
|
10
14
|
const importers = parsed?.importers ?? {};
|
|
11
15
|
const graph = new Map();
|
|
@@ -58,17 +62,91 @@ export function loadFromPnpmLock(filePath, prodOnly) {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
const queue = rootDeps.map(dep => ({ key: dep, path: ["project"] }));
|
|
61
|
-
const
|
|
65
|
+
const seenKeys = new Set();
|
|
62
66
|
while (queue.length > 0) {
|
|
63
67
|
const current = queue.shift();
|
|
68
|
+
if (seenKeys.has(current.key))
|
|
69
|
+
continue;
|
|
70
|
+
seenKeys.add(current.key);
|
|
64
71
|
const ref = parsePnpmPackageKey(current.key);
|
|
65
72
|
if (!ref)
|
|
66
73
|
continue;
|
|
67
74
|
const nextPath = [...current.path, ref.name];
|
|
68
|
-
const
|
|
69
|
-
|
|
75
|
+
const pkgKey = `${ref.name}@${ref.version}`;
|
|
76
|
+
const pkg = map.get(pkgKey);
|
|
77
|
+
if (pkg) {
|
|
78
|
+
pkg.paths = uniquePathArrays([...(pkg.paths ?? []), nextPath]).slice(0, 5);
|
|
79
|
+
}
|
|
80
|
+
const children = graph.get(current.key) ?? [];
|
|
81
|
+
for (const child of children) {
|
|
82
|
+
queue.push({ key: child, path: nextPath });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return [...map.values()];
|
|
86
|
+
}
|
|
87
|
+
function loadV9(parsed, prodOnly) {
|
|
88
|
+
const snapshotsSection = parsed?.snapshots ?? {};
|
|
89
|
+
const importers = parsed?.importers ?? {};
|
|
90
|
+
const graph = new Map();
|
|
91
|
+
const map = new Map();
|
|
92
|
+
for (const [key, meta] of Object.entries(snapshotsSection)) {
|
|
93
|
+
const ref = parsePnpmPackageKeyV9(String(key));
|
|
94
|
+
if (!ref)
|
|
95
|
+
continue;
|
|
96
|
+
const depKeys = new Set();
|
|
97
|
+
for (const depMap of [meta?.dependencies, meta?.optionalDependencies]) {
|
|
98
|
+
if (!depMap || typeof depMap !== "object")
|
|
99
|
+
continue;
|
|
100
|
+
for (const [depName, depRef] of Object.entries(depMap)) {
|
|
101
|
+
const resolved = normalizePnpmDepRefV9(String(depName), depRef);
|
|
102
|
+
if (resolved)
|
|
103
|
+
depKeys.add(resolved);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
graph.set(ref.key, [...depKeys]);
|
|
107
|
+
const dev = !!meta?.dev;
|
|
108
|
+
if (prodOnly && dev)
|
|
109
|
+
continue;
|
|
110
|
+
upsertPackage(map, { name: ref.name, version: ref.version, ecosystem: "npm", dev, paths: [] });
|
|
111
|
+
}
|
|
112
|
+
const rootDeps = [];
|
|
113
|
+
for (const importer of Object.values(importers)) {
|
|
114
|
+
for (const depSectionName of ["dependencies", "optionalDependencies", "devDependencies"]) {
|
|
115
|
+
if (prodOnly && depSectionName === "devDependencies")
|
|
116
|
+
continue;
|
|
117
|
+
const depSection = importer?.[depSectionName];
|
|
118
|
+
if (!depSection || typeof depSection !== "object")
|
|
119
|
+
continue;
|
|
120
|
+
for (const [depName, depRef] of Object.entries(depSection)) {
|
|
121
|
+
const resolved = normalizePnpmDepRefV9(String(depName), depRef);
|
|
122
|
+
if (resolved) {
|
|
123
|
+
rootDeps.push(resolved);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const fallbackVersion = normalizeRawVersion(depRef);
|
|
127
|
+
if (fallbackVersion) {
|
|
128
|
+
upsertPackage(map, {
|
|
129
|
+
name: String(depName),
|
|
130
|
+
version: fallbackVersion,
|
|
131
|
+
ecosystem: "npm",
|
|
132
|
+
paths: [["project", String(depName)]]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const queue = rootDeps.map(dep => ({ key: dep, path: ["project"] }));
|
|
140
|
+
const seenKeys = new Set();
|
|
141
|
+
while (queue.length > 0) {
|
|
142
|
+
const current = queue.shift();
|
|
143
|
+
if (seenKeys.has(current.key))
|
|
144
|
+
continue;
|
|
145
|
+
seenKeys.add(current.key);
|
|
146
|
+
const ref = parsePnpmPackageKeyV9(current.key);
|
|
147
|
+
if (!ref)
|
|
70
148
|
continue;
|
|
71
|
-
|
|
149
|
+
const nextPath = [...current.path, ref.name];
|
|
72
150
|
const pkgKey = `${ref.name}@${ref.version}`;
|
|
73
151
|
const pkg = map.get(pkgKey);
|
|
74
152
|
if (pkg) {
|
|
@@ -89,6 +167,17 @@ function parsePnpmPackageKey(key) {
|
|
|
89
167
|
const [, name, version] = match;
|
|
90
168
|
return { key, name, version };
|
|
91
169
|
}
|
|
170
|
+
function parsePnpmPackageKeyV9(key) {
|
|
171
|
+
const cleaned = key.split("(")[0]; // strip peer-dep suffix e.g. handlebars@4.7.8(foo@1.0.0)
|
|
172
|
+
const idx = cleaned.lastIndexOf("@");
|
|
173
|
+
if (idx <= 0)
|
|
174
|
+
return null; // no @ or @ is the first char
|
|
175
|
+
const name = cleaned.slice(0, idx);
|
|
176
|
+
const version = cleaned.slice(idx + 1);
|
|
177
|
+
if (!name || !version)
|
|
178
|
+
return null;
|
|
179
|
+
return { key: cleaned, name, version };
|
|
180
|
+
}
|
|
92
181
|
function normalizePnpmDepRef(depName, depRef) {
|
|
93
182
|
if (typeof depRef === "string") {
|
|
94
183
|
const cleaned = depRef.replace(/^link:/, "").replace(/^workspace:/, "").split("(")[0];
|
|
@@ -107,3 +196,17 @@ function normalizePnpmDepRef(depName, depRef) {
|
|
|
107
196
|
}
|
|
108
197
|
return null;
|
|
109
198
|
}
|
|
199
|
+
function normalizePnpmDepRefV9(depName, depRef) {
|
|
200
|
+
if (typeof depRef === "string") {
|
|
201
|
+
const cleaned = depRef.replace(/^link:/, "").replace(/^workspace:/, "").split("(")[0];
|
|
202
|
+
if (!cleaned || cleaned.startsWith(".") || cleaned.startsWith(".."))
|
|
203
|
+
return null;
|
|
204
|
+
if (looksLikeVersion(cleaned))
|
|
205
|
+
return `${depName}@${cleaned}`;
|
|
206
|
+
}
|
|
207
|
+
if (depRef && typeof depRef === "object") {
|
|
208
|
+
const version = depRef.version ?? depRef.specifier;
|
|
209
|
+
return normalizePnpmDepRefV9(depName, version);
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
@@ -159,6 +159,8 @@ function inferPackageManager(scanInput) {
|
|
|
159
159
|
return "pnpm";
|
|
160
160
|
if (scanInput.source === "yarn-lock")
|
|
161
161
|
return "yarn";
|
|
162
|
+
if (scanInput.source === "bun-lock")
|
|
163
|
+
return "bun";
|
|
162
164
|
return null;
|
|
163
165
|
}
|
|
164
166
|
function commandPrefix(packageManager) {
|
|
@@ -166,6 +168,8 @@ function commandPrefix(packageManager) {
|
|
|
166
168
|
return "npm install";
|
|
167
169
|
if (packageManager === "pnpm")
|
|
168
170
|
return "pnpm add";
|
|
171
|
+
if (packageManager === "bun")
|
|
172
|
+
return "bun add";
|
|
169
173
|
return "yarn add";
|
|
170
174
|
}
|
|
171
175
|
function packageManagerSourceLabel(scanInput) {
|
|
@@ -178,6 +182,8 @@ function packageManagerSourceLabel(scanInput) {
|
|
|
178
182
|
return "pnpm-lock.yaml";
|
|
179
183
|
if (scanInput.source === "yarn-lock")
|
|
180
184
|
return "yarn.lock";
|
|
185
|
+
if (scanInput.source === "bun-lock")
|
|
186
|
+
return "bun.lock";
|
|
181
187
|
return scanInput.source;
|
|
182
188
|
}
|
|
183
189
|
function upsertTarget(targetsByPackage, next) {
|
package/dist/utils/file.js
CHANGED
package/dist/utils/version.js
CHANGED
|
@@ -27,6 +27,11 @@ export function parseExactManifestVersion(spec) {
|
|
|
27
27
|
return cleaned;
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
+
export function isMajorVersionBump(from, to) {
|
|
31
|
+
const fromMajor = Number(from.split(".")[0]);
|
|
32
|
+
const toMajor = Number(to.split(".")[0]);
|
|
33
|
+
return !Number.isNaN(fromMajor) && !Number.isNaN(toMajor) && toMajor > fromMajor;
|
|
34
|
+
}
|
|
30
35
|
export function normalizeRawVersion(value) {
|
|
31
36
|
if (typeof value !== "string")
|
|
32
37
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cve-lite-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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": {
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"owasp",
|
|
38
38
|
"npm",
|
|
39
39
|
"pnpm",
|
|
40
|
-
"yarn"
|
|
40
|
+
"yarn",
|
|
41
|
+
"bun"
|
|
41
42
|
],
|
|
42
43
|
"license": "MIT",
|
|
43
44
|
"engines": {
|
package/dist/banner.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { chalk } from "./chalk";
|
|
2
|
-
export const CLI_BANNER = [
|
|
3
|
-
`${chalk.green(">_")} ${chalk.bold.whiteBright("CVE Lite CLI")}`,
|
|
4
|
-
chalk.gray("────────────────────────────────"),
|
|
5
|
-
`${chalk.green("✔")} Scan dependencies`,
|
|
6
|
-
`${chalk.green("✔")} Highlight critical issues`,
|
|
7
|
-
`${chalk.green("✔")} Show a clear fix plan`,
|
|
8
|
-
"",
|
|
9
|
-
chalk.gray("Fast. Local. Developer-first.")
|
|
10
|
-
].join("\n");
|
package/dist/chalk.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
const ansi = {
|
|
3
|
-
reset: "\x1b[0m",
|
|
4
|
-
bold: "\x1b[1m",
|
|
5
|
-
red: "\x1b[31m",
|
|
6
|
-
redBright: "\x1b[91m",
|
|
7
|
-
green: "\x1b[32m",
|
|
8
|
-
greenBright: "\x1b[92m",
|
|
9
|
-
yellow: "\x1b[33m",
|
|
10
|
-
blue: "\x1b[34m",
|
|
11
|
-
blueBright: "\x1b[94m",
|
|
12
|
-
magenta: "\x1b[35m",
|
|
13
|
-
cyan: "\x1b[36m",
|
|
14
|
-
white: "\x1b[37m",
|
|
15
|
-
whiteBright: "\x1b[97m",
|
|
16
|
-
gray: "\x1b[90m"
|
|
17
|
-
};
|
|
18
|
-
const colorEnabled = Boolean(process.stdout.isTTY) && process.env.NO_COLOR !== "1";
|
|
19
|
-
function paint(code, text) {
|
|
20
|
-
if (!colorEnabled)
|
|
21
|
-
return text;
|
|
22
|
-
return `${code}${text}${ansi.reset}`;
|
|
23
|
-
}
|
|
24
|
-
export const chalk = {
|
|
25
|
-
bold: Object.assign((text) => paint(ansi.bold, text), {
|
|
26
|
-
cyan: (text) => paint(ansi.bold + ansi.cyan, text),
|
|
27
|
-
green: (text) => paint(ansi.bold + ansi.green, text),
|
|
28
|
-
magenta: (text) => paint(ansi.bold + ansi.magenta, text),
|
|
29
|
-
blue: (text) => paint(ansi.bold + ansi.blue, text),
|
|
30
|
-
yellow: (text) => paint(ansi.bold + ansi.yellow, text)
|
|
31
|
-
}),
|
|
32
|
-
cyan: (text) => paint(ansi.cyan, text),
|
|
33
|
-
green: (text) => paint(ansi.green, text),
|
|
34
|
-
greenBright: (text) => paint(ansi.greenBright, text),
|
|
35
|
-
red: (text) => paint(ansi.red, text),
|
|
36
|
-
redBright: (text) => paint(ansi.redBright, text),
|
|
37
|
-
yellow: (text) => paint(ansi.yellow, text),
|
|
38
|
-
blue: (text) => paint(ansi.blue, text),
|
|
39
|
-
blueBright: (text) => paint(ansi.blueBright, text),
|
|
40
|
-
magenta: (text) => paint(ansi.magenta, text),
|
|
41
|
-
gray: (text) => paint(ansi.gray, text),
|
|
42
|
-
white: (text) => paint(ansi.white, text),
|
|
43
|
-
whiteBright: (text) => paint(ansi.whiteBright, text)
|
|
44
|
-
};
|
package/dist/osv/api.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export async function osvQueryBatch(packages) {
|
|
2
|
-
const response = await fetch("https://api.osv.dev/v1/querybatch", {
|
|
3
|
-
method: "POST",
|
|
4
|
-
headers: { "content-type": "application/json" },
|
|
5
|
-
body: JSON.stringify({
|
|
6
|
-
queries: packages.map(pkg => ({
|
|
7
|
-
package: {
|
|
8
|
-
ecosystem: pkg.ecosystem,
|
|
9
|
-
name: pkg.name
|
|
10
|
-
},
|
|
11
|
-
version: pkg.version
|
|
12
|
-
}))
|
|
13
|
-
})
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
throw new Error(`OSV batch query failed: ${response.status} ${response.statusText}`);
|
|
17
|
-
}
|
|
18
|
-
return response.json();
|
|
19
|
-
}
|
|
20
|
-
export async function osvGetVuln(id) {
|
|
21
|
-
const response = await fetch(`https://api.osv.dev/v1/vulns/${encodeURIComponent(id)}`);
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
throw new Error(`OSV vuln fetch failed for ${id}`);
|
|
24
|
-
}
|
|
25
|
-
return response.json();
|
|
26
|
-
}
|