cve-lite-cli 1.41.5 → 1.42.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 +22 -19
- package/dist/advisory/detail-resolution.js +62 -0
- package/dist/advisory/local-db.js +90 -15
- package/dist/advisory/osv-advisory-source.js +113 -62
- package/dist/advisory/osv-sync.js +18 -16
- package/dist/advisory/sqlite.js +50 -0
- package/dist/audit-log/ndjson-writer.js +6 -3
- package/dist/audit-log/open-error.js +22 -0
- package/dist/cli/args.js +145 -87
- package/dist/cli/flags.js +2 -0
- package/dist/cli/help.js +6 -2
- package/dist/cli/overrides.js +5 -2
- package/dist/cli/validate.js +45 -5
- package/dist/constants.js +10 -0
- package/dist/index.js +15 -6
- package/dist/licenses/license-check.js +17 -4
- package/dist/osv/cache.js +7 -13
- package/dist/output/cyclonedx.js +57 -18
- package/dist/output/finding-display.js +8 -1
- package/dist/output/formatters.js +52 -11
- package/dist/output/html-reporter.js +40 -8
- package/dist/output/override-findings-terminal.js +21 -13
- package/dist/output/printers.js +185 -76
- package/dist/output/sarif.js +182 -16
- package/dist/output/spdx.js +15 -1
- package/dist/output/write-outputs.js +29 -20
- package/dist/overrides/context-builder.js +1 -7
- package/dist/overrides/detectors/oa005-nested-ineffective.js +6 -1
- package/dist/overrides/detectors/oa008-materialized.js +33 -10
- package/dist/overrides/detectors/oa009-stale-floor.js +2 -2
- package/dist/overrides/detectors/oa010-vulnerable-floor.js +19 -13
- package/dist/overrides/detectors/phantom-utils.js +2 -10
- package/dist/overrides/fixer.js +13 -2
- package/dist/overrides/index.js +1 -0
- package/dist/overrides/types.js +15 -1
- package/dist/parsers/bun-lock.js +6 -0
- package/dist/parsers/index.js +177 -40
- package/dist/parsers/multi-package.js +4 -0
- package/dist/parsers/package-lock.js +6 -2
- package/dist/parsers/pnpm-lock.js +4 -7
- package/dist/parsers/requirements-txt.js +185 -0
- package/dist/parsers/utils.js +11 -6
- package/dist/parsers/yarn-lock.js +1 -5
- package/dist/remediation/fix-commands.js +60 -36
- package/dist/remediation/parent-update-child-note.js +3 -2
- package/dist/scan/completeness.js +57 -4
- package/dist/scan/multi-folder-scan.js +27 -13
- package/dist/scan/single-scan.js +118 -37
- package/dist/scanner.js +59 -36
- package/dist/types.js +1 -1
- package/dist/utils/array.js +5 -0
- package/dist/utils/baseline.js +8 -2
- package/dist/utils/chalk.js +1 -3
- package/dist/utils/create-pr.js +2 -2
- package/dist/utils/debug-bundle.js +37 -22
- package/dist/utils/debug-project.js +6 -5
- package/dist/utils/debug-redaction.js +1 -1
- package/dist/utils/effective-options.js +5 -1
- package/dist/utils/finding.js +4 -0
- package/dist/utils/fix-runner.js +110 -36
- package/dist/utils/import-type-queries.js +5 -1
- package/dist/utils/install-command.js +6 -0
- package/dist/utils/malicious.js +11 -0
- package/dist/utils/package-identity.js +12 -2
- package/dist/utils/path-coverage.js +1 -5
- package/dist/utils/sanitize.js +59 -0
- package/dist/utils/sbom-format.js +17 -8
- package/dist/utils/severity.js +61 -7
- package/dist/utils/url.js +175 -0
- package/dist/utils/version.js +44 -0
- package/dist/utils/vuln.js +11 -14
- package/package.json +2 -4
package/dist/utils/severity.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { chalk } from "./chalk.js";
|
|
2
2
|
import { severityOrder } from "../constants.js";
|
|
3
3
|
import { normalizeSeverity } from "../osv/severity.js";
|
|
4
|
+
import { hasMaliciousAdvisory } from "./malicious.js";
|
|
5
|
+
import { pluralize } from "./string.js";
|
|
4
6
|
export const SEVERITY_ORDER = ["critical", "high", "medium", "low", "unknown", "none"];
|
|
5
7
|
export function reachesFailOn(findings, failOn) {
|
|
6
8
|
if (!failOn)
|
|
@@ -8,6 +10,9 @@ export function reachesFailOn(findings, failOn) {
|
|
|
8
10
|
const failLevel = normalizeSeverity(failOn);
|
|
9
11
|
return findings.some((f) => severityOrder[f.severity] >= severityOrder[failLevel]);
|
|
10
12
|
}
|
|
13
|
+
export function hasUnresolvedAdvisories(finding) {
|
|
14
|
+
return Boolean(finding.unresolvedAdvisoryIds && finding.unresolvedAdvisoryIds.length > 0);
|
|
15
|
+
}
|
|
11
16
|
// One line that names what tripped the --fail-on gate, so a red CI job says why
|
|
12
17
|
// it is red. The gate ORs three finding classes (CVE, override hygiene,
|
|
13
18
|
// maintenance risk) and none of the rendered output mentioned the gate before,
|
|
@@ -16,27 +21,76 @@ export function reachesFailOn(findings, failOn) {
|
|
|
16
21
|
// cannot disagree. The parenthetical echoes the raw flag value: --fail-on is not
|
|
17
22
|
// validated and normalizeSeverity falls back to critical, so echoing the
|
|
18
23
|
// normalized level would show the user a value they never typed.
|
|
19
|
-
// The
|
|
24
|
+
// The finding classes the --fail-on gate ORs, as failingGateSummary
|
|
20
25
|
// names them. Both scan paths build their gate input from this one list, so
|
|
21
26
|
// the wording for a class cannot differ between a single- and multi-folder scan.
|
|
22
27
|
export const GATE_CLASS_LABELS = {
|
|
28
|
+
malicious: "malicious package",
|
|
23
29
|
vulnerability: "vulnerability",
|
|
24
30
|
overrideHygiene: "override hygiene",
|
|
25
31
|
maintenanceRisk: "maintenance risk",
|
|
26
32
|
};
|
|
33
|
+
// MAL- advisories carry no CVSS vector, so a malicious package scores
|
|
34
|
+
// `unknown` and would pass every threshold above low. It is not a severity
|
|
35
|
+
// question: the advice is to remove it, so it fails the gate at any level and
|
|
36
|
+
// is counted apart from ordinary vulnerability findings.
|
|
37
|
+
export function vulnerabilityGateClasses(findings) {
|
|
38
|
+
const isMalicious = (f) => hasMaliciousAdvisory(f.vulnerabilities ?? []);
|
|
39
|
+
const malicious = findings.filter(isMalicious);
|
|
40
|
+
const rest = findings.filter((f) => !isMalicious(f));
|
|
41
|
+
return [
|
|
42
|
+
{ label: GATE_CLASS_LABELS.malicious, findings: malicious, anyLevel: true },
|
|
43
|
+
{ label: GATE_CLASS_LABELS.vulnerability, findings: rest },
|
|
44
|
+
];
|
|
45
|
+
}
|
|
27
46
|
export function failingGateSummary(classes, failOn) {
|
|
28
47
|
if (!failOn)
|
|
29
48
|
return null;
|
|
30
49
|
const failLevel = normalizeSeverity(failOn);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
if (failLevel === "none")
|
|
51
|
+
return null;
|
|
52
|
+
const anyLevelParts = [];
|
|
53
|
+
const thresholdParts = [];
|
|
54
|
+
for (const { label, findings, anyLevel } of classes) {
|
|
55
|
+
const count = anyLevel
|
|
56
|
+
? findings.length
|
|
57
|
+
: findings.filter((f) => {
|
|
58
|
+
if ((!f.vulnerabilities || f.vulnerabilities.length === 0) && hasUnresolvedAdvisories(f)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return severityOrder[f.severity] >= severityOrder[failLevel];
|
|
62
|
+
}).length;
|
|
34
63
|
if (count > 0)
|
|
35
|
-
|
|
64
|
+
(anyLevel ? anyLevelParts : thresholdParts).push(`${count} ${label} ${count === 1 ? "finding" : "findings"}`);
|
|
65
|
+
}
|
|
66
|
+
if (anyLevelParts.length === 0 && thresholdParts.length === 0)
|
|
67
|
+
return null;
|
|
68
|
+
const segments = [];
|
|
69
|
+
if (anyLevelParts.length > 0)
|
|
70
|
+
segments.push(`${anyLevelParts.join(", ")} at any level`);
|
|
71
|
+
if (thresholdParts.length > 0)
|
|
72
|
+
segments.push(`${thresholdParts.join(", ")} at or above ${failLevel}`);
|
|
73
|
+
return `Failing: ${segments.join(", and ")} (--fail-on ${failOn}).`;
|
|
74
|
+
}
|
|
75
|
+
export function unresolvedGateNotice(findings, failOn, incompletePolicy) {
|
|
76
|
+
if (!failOn || normalizeSeverity(failOn) === "none")
|
|
77
|
+
return null;
|
|
78
|
+
const ids = new Set();
|
|
79
|
+
for (const f of findings) {
|
|
80
|
+
if (hasUnresolvedAdvisories(f)) {
|
|
81
|
+
for (const id of f.unresolvedAdvisoryIds) {
|
|
82
|
+
ids.add(id);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
36
85
|
}
|
|
37
|
-
if (
|
|
86
|
+
if (ids.size === 0)
|
|
38
87
|
return null;
|
|
39
|
-
|
|
88
|
+
const count = ids.size;
|
|
89
|
+
const baseMessage = `${count} ${pluralize(count, "advisory", "advisories")} could not be evaluated`;
|
|
90
|
+
if (incompletePolicy === "error") {
|
|
91
|
+
return `${baseMessage}.`;
|
|
92
|
+
}
|
|
93
|
+
return `${baseMessage}; use --incomplete-policy error to fail the build.`;
|
|
40
94
|
}
|
|
41
95
|
export function formatSeverityLabel(severity) {
|
|
42
96
|
const lower = severity.toLowerCase();
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { URL } from "node:url";
|
|
2
|
+
export const SECRET_KEY = /^(?:password|passwd|pwd|pass|_authToken|_auth|authToken|auth|token|authorization|credentials?|apiKey|secret|accessToken|refreshToken|signature|sig|key|bearer|jwt|session)$/i;
|
|
3
|
+
const GIT_SSH_USER = "git";
|
|
4
|
+
const SSH_SCHEMES = new Set(["git+ssh:", "ssh:"]);
|
|
5
|
+
const SSH_PREFIXES = new Set(["git+ssh://", "ssh://"]);
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if the query parameter key represents an authentication token,
|
|
8
|
+
* password, secret, API key, signature, or similar sensitive credential.
|
|
9
|
+
*/
|
|
10
|
+
export function isSensitiveQueryParam(key) {
|
|
11
|
+
const normalized = key.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().replace(/^_+/, "");
|
|
12
|
+
const parts = normalized.split(/[_\-.[\]]+/).filter(Boolean);
|
|
13
|
+
return (parts.some(p => SECRET_KEY.test(p)) ||
|
|
14
|
+
parts.join("").includes("token") ||
|
|
15
|
+
parts.join("").includes("secret"));
|
|
16
|
+
}
|
|
17
|
+
function stripQueryParams(url) {
|
|
18
|
+
const hashIdx = url.indexOf("#");
|
|
19
|
+
const queryIdx = url.indexOf("?");
|
|
20
|
+
if (queryIdx === -1 || (hashIdx !== -1 && queryIdx > hashIdx))
|
|
21
|
+
return url;
|
|
22
|
+
const queryPart = url.slice(queryIdx + 1, hashIdx !== -1 ? hashIdx : undefined);
|
|
23
|
+
const filtered = queryPart.split("&").filter(param => {
|
|
24
|
+
if (!param)
|
|
25
|
+
return false;
|
|
26
|
+
const rawKey = param.split("=")[0];
|
|
27
|
+
try {
|
|
28
|
+
return !isSensitiveQueryParam(decodeURIComponent(rawKey));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Undecodable key: drop it rather than risk leaking a secret
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const newQuery = filtered.length > 0 ? `?${filtered.join("&")}` : "";
|
|
36
|
+
return url.slice(0, queryIdx) + newQuery + (hashIdx !== -1 ? url.slice(hashIdx) : "");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Strips user credentials from SCP-style Git references (e.g. secret@github.com:org/repo.git),
|
|
40
|
+
* while preserving the standard git@ service user and preserving relative scoped paths (packages/@scope/foo).
|
|
41
|
+
*/
|
|
42
|
+
function stripScpUserinfo(url) {
|
|
43
|
+
const queryIdx = url.indexOf("?");
|
|
44
|
+
const hashIdx = url.indexOf("#");
|
|
45
|
+
const authorityEnd = queryIdx !== -1 && (hashIdx === -1 || queryIdx < hashIdx)
|
|
46
|
+
? queryIdx
|
|
47
|
+
: (hashIdx !== -1 ? hashIdx : url.length);
|
|
48
|
+
const urlBeforeQuery = url.slice(0, authorityEnd);
|
|
49
|
+
// Match SCP pattern: userinfo@host:path where:
|
|
50
|
+
// - userinfo cannot contain slashes ("/")
|
|
51
|
+
// - host cannot contain slashes ("/"), colons (":"), or query/hash
|
|
52
|
+
// - greedy match consumes up to the last "@" before the host
|
|
53
|
+
const match = urlBeforeQuery.match(/^([^/]+)@([^/?#:]+):(.*)$/);
|
|
54
|
+
if (!match) {
|
|
55
|
+
return stripQueryParams(url);
|
|
56
|
+
}
|
|
57
|
+
const userinfo = match[1];
|
|
58
|
+
if (userinfo === GIT_SSH_USER) {
|
|
59
|
+
return stripQueryParams(url);
|
|
60
|
+
}
|
|
61
|
+
const hostAndPath = match[2] + ":" + match[3] + url.slice(authorityEnd);
|
|
62
|
+
return stripQueryParams(hostAndPath);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Fallback parser for non-standard, malformed, or SCP-style URLs that WHATWG URL cannot parse.
|
|
66
|
+
*/
|
|
67
|
+
function stripUserinfoFallback(url) {
|
|
68
|
+
const schemeEnd = url.indexOf("://");
|
|
69
|
+
if (schemeEnd === -1) {
|
|
70
|
+
return stripScpUserinfo(url);
|
|
71
|
+
}
|
|
72
|
+
const prefix = url.slice(0, schemeEnd + 3);
|
|
73
|
+
let rest = url.slice(schemeEnd + 3);
|
|
74
|
+
const isSsh = SSH_PREFIXES.has(prefix);
|
|
75
|
+
const slashIdx = rest.indexOf("/");
|
|
76
|
+
const queryIdx = rest.indexOf("?");
|
|
77
|
+
const hashIdx = rest.indexOf("#");
|
|
78
|
+
if (slashIdx !== -1) {
|
|
79
|
+
// Userinfo can contain an unencoded "@"; the host follows the LAST "@" in
|
|
80
|
+
// the authority segment (strictly before the first "/" that marks the path).
|
|
81
|
+
const atIdx = rest.lastIndexOf("@", slashIdx);
|
|
82
|
+
if (atIdx !== -1) {
|
|
83
|
+
const hadQueryOrHash = (queryIdx !== -1 && queryIdx < atIdx) || (hashIdx !== -1 && hashIdx < atIdx);
|
|
84
|
+
if (!hadQueryOrHash) {
|
|
85
|
+
const userinfo = rest.slice(0, atIdx);
|
|
86
|
+
if (isSsh && userinfo === GIT_SSH_USER) {
|
|
87
|
+
// Keep git@ for SSH
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
rest = rest.slice(atIdx + 1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Delimiters (? or #) appeared before @, but @ is strictly before the path slash
|
|
95
|
+
// (e.g. user:pa?ss=foo@host:port/repo.git or user:pa#ss@host/repo.git).
|
|
96
|
+
// Fail closed by stripping credentials up to @ regardless of query-like "=" in the password.
|
|
97
|
+
rest = rest.slice(atIdx + 1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// No slash in URL (e.g. SCP-style git+ssh://host:repo or scheme://host?query)
|
|
103
|
+
const delimIdx = queryIdx !== -1 && (hashIdx === -1 || queryIdx < hashIdx) ? queryIdx : hashIdx;
|
|
104
|
+
const authorityEnd = delimIdx !== -1 ? delimIdx : rest.length;
|
|
105
|
+
const atBeforeDelim = rest.lastIndexOf("@", authorityEnd - 1);
|
|
106
|
+
if (atBeforeDelim !== -1) {
|
|
107
|
+
const userinfo = rest.slice(0, atBeforeDelim);
|
|
108
|
+
if (isSsh && userinfo === GIT_SSH_USER) {
|
|
109
|
+
// Keep git@ for SSH
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
rest = rest.slice(atBeforeDelim + 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// Check if unencoded delimiter exists before an SCP authority (e.g. user:pa?ss=foo@host:path)
|
|
117
|
+
const fullAt = rest.lastIndexOf("@");
|
|
118
|
+
if (fullAt !== -1 && delimIdx !== -1 && delimIdx < fullAt) {
|
|
119
|
+
const afterAt = rest.slice(fullAt + 1);
|
|
120
|
+
if (afterAt.includes(":")) {
|
|
121
|
+
// Unencoded delimiter before @ followed by host:path
|
|
122
|
+
rest = afterAt;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return stripQueryParams(prefix + rest);
|
|
128
|
+
}
|
|
129
|
+
export function stripUrlCredentials(url) {
|
|
130
|
+
if (!url || typeof url !== "string")
|
|
131
|
+
return url;
|
|
132
|
+
// Pure SCP-style Git URLs (e.g. git@host:repo) or non-standard schemes without authority
|
|
133
|
+
if (!url.includes("://") && !url.startsWith("file:") && !url.startsWith("npm:")) {
|
|
134
|
+
return stripUserinfoFallback(url);
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const parsed = new URL(url);
|
|
138
|
+
const isSsh = SSH_SCHEMES.has(parsed.protocol);
|
|
139
|
+
const hasUserinfoToStrip = isSsh
|
|
140
|
+
? (parsed.username !== GIT_SSH_USER && parsed.username !== "") || Boolean(parsed.password)
|
|
141
|
+
: Boolean(parsed.username || parsed.password);
|
|
142
|
+
let hasSensitiveParam = false;
|
|
143
|
+
for (const [key] of parsed.searchParams) {
|
|
144
|
+
if (isSensitiveQueryParam(key)) {
|
|
145
|
+
hasSensitiveParam = true;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Return the original string unchanged when there is nothing to strip (#1591 maintainer review).
|
|
150
|
+
// This preserves relative paths such as file:vendor/foo.tgz, avoids lowercasing hostnames,
|
|
151
|
+
// and avoids re-encoding characters when no credential was present.
|
|
152
|
+
if (!hasUserinfoToStrip && !hasSensitiveParam) {
|
|
153
|
+
return url;
|
|
154
|
+
}
|
|
155
|
+
if (isSsh) {
|
|
156
|
+
if (parsed.username !== GIT_SSH_USER || parsed.password) {
|
|
157
|
+
parsed.username = "";
|
|
158
|
+
parsed.password = "";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
parsed.username = "";
|
|
163
|
+
parsed.password = "";
|
|
164
|
+
}
|
|
165
|
+
for (const [key] of [...parsed.searchParams]) {
|
|
166
|
+
if (isSensitiveQueryParam(key)) {
|
|
167
|
+
parsed.searchParams.delete(key);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return parsed.toString();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return stripUserinfoFallback(url);
|
|
174
|
+
}
|
|
175
|
+
}
|
package/dist/utils/version.js
CHANGED
|
@@ -6,6 +6,12 @@ import { pep440Scheme } from "./versions/pep440.js";
|
|
|
6
6
|
export function isPep440Ecosystem(ecosystem) {
|
|
7
7
|
return typeof ecosystem === "string" && ecosystem.trim().toLowerCase() === "pypi";
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Normalise a PEP 503 package name: lowercase, and replace runs of [-_.]+ with a single hyphen.
|
|
11
|
+
*/
|
|
12
|
+
export function normalizePep503PackageName(name) {
|
|
13
|
+
return name.toLowerCase().replace(/[-_.]+/g, "-");
|
|
14
|
+
}
|
|
9
15
|
export function looksLikeVersion(value, ecosystem) {
|
|
10
16
|
if (isPep440Ecosystem(ecosystem))
|
|
11
17
|
return pep440Scheme.looksLikeVersion(value);
|
|
@@ -257,6 +263,44 @@ export function isValidRange(input) {
|
|
|
257
263
|
return false;
|
|
258
264
|
return semver.validRange(input.trim(), { loose: true }) !== null;
|
|
259
265
|
}
|
|
266
|
+
/** Replace a bare caret's floor while preserving its ceiling and prerelease rules. */
|
|
267
|
+
export function raiseCaretRangeFloor(pin, newFloor) {
|
|
268
|
+
let range;
|
|
269
|
+
try {
|
|
270
|
+
// Use ordinary package resolution here. Audit matching also considers
|
|
271
|
+
// prereleases that the original range may exclude from resolution.
|
|
272
|
+
range = new semver.Range(pin, { loose: true });
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
if (range.set.length !== 1 || !range.test(newFloor))
|
|
278
|
+
return null;
|
|
279
|
+
const ceiling = range.set[0]?.find((comparator) => comparator.operator === "<");
|
|
280
|
+
if (ceiling)
|
|
281
|
+
return `>=${newFloor} ${ceiling.value}`;
|
|
282
|
+
// Semver normalizes unbounded carets such as ^* and ^x to an empty range.
|
|
283
|
+
return range.range === "" ? `>=${newFloor}` : null;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Lowest version that satisfies `range`.
|
|
287
|
+
*
|
|
288
|
+
* Uses `semver.minVersion` with `{ loose: true }`. Upper-bound constraints
|
|
289
|
+
* (`<2.0.0`, `<=1.5.0`) return "0.0.0", ranges with a lower bound (`>=1.2.0`,
|
|
290
|
+
* `1.x`, `^1.2.0`, `1.2.0 - 2.0.0`) return their minimum version, preserving
|
|
291
|
+
* any prerelease tag. Returns null for invalid or unparseable ranges.
|
|
292
|
+
*/
|
|
293
|
+
export function rangeMinVersion(range) {
|
|
294
|
+
if (!range || !range.trim())
|
|
295
|
+
return null;
|
|
296
|
+
try {
|
|
297
|
+
const mv = semver.minVersion(range.trim(), { loose: true });
|
|
298
|
+
return mv ? mv.version : null;
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
260
304
|
/**
|
|
261
305
|
* Does `version` satisfy `range`?
|
|
262
306
|
*
|
package/dist/utils/vuln.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { inferSeverity } from "../osv/severity.js";
|
|
2
2
|
import { severityOrder } from "../constants.js";
|
|
3
3
|
import { unique } from "./array.js";
|
|
4
|
-
|
|
5
|
-
// records are external data - the declared `string` type on OsvVuln.id does
|
|
6
|
-
// not guarantee a malformed advisory record cannot have a missing/non-string id.
|
|
7
|
-
export function isMaliciousVulnId(id) {
|
|
8
|
-
return typeof id === "string" && id.startsWith("MAL-");
|
|
9
|
-
}
|
|
10
|
-
export function hasMaliciousAdvisory(vulns) {
|
|
11
|
-
return vulns.some(v => isMaliciousVulnId(v.id));
|
|
12
|
-
}
|
|
4
|
+
export { isMaliciousVulnId, hasMaliciousAdvisory } from "./malicious.js";
|
|
13
5
|
// Guards against non-string alias elements from malformed OSV records - a
|
|
14
6
|
// malformed record with a null/undefined/non-string entry in `aliases` must
|
|
15
7
|
// not abort the whole scan.
|
|
@@ -31,8 +23,8 @@ export function extractCveAliases(vulns) {
|
|
|
31
23
|
* than "the same as", and a shared CVE is weaker still, since two advisories may
|
|
32
24
|
* legitimately cite one CVE.
|
|
33
25
|
*
|
|
34
|
-
* The survivor keeps the
|
|
35
|
-
*
|
|
26
|
+
* The survivor keeps the highest known severity, and ties break on the
|
|
27
|
+
* smaller id so output is stable run to run. Its alias set
|
|
36
28
|
* absorbs the dropped id, which is the part that matters: the accuracy sweep
|
|
37
29
|
* compares our advisory ids against OSV's, and losing an id would read as a
|
|
38
30
|
* missed advisory rather than a de-duplicated one.
|
|
@@ -81,10 +73,15 @@ export function collapseAliasedDuplicates(vulns) {
|
|
|
81
73
|
return { ...v, aliases: [...ids].sort() };
|
|
82
74
|
});
|
|
83
75
|
}
|
|
84
|
-
/** Higher severity wins; the smaller id breaks a tie so the result is stable. */
|
|
85
76
|
function preferred(a, b) {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
77
|
+
const aSeverity = inferSeverity(a);
|
|
78
|
+
const bSeverity = inferSeverity(b);
|
|
79
|
+
// The gate ranks unknown like low, but a measured rating takes precedence here.
|
|
80
|
+
if ((aSeverity === "unknown") !== (bSeverity === "unknown")) {
|
|
81
|
+
return aSeverity === "unknown" ? b : a;
|
|
82
|
+
}
|
|
83
|
+
const ra = severityOrder[aSeverity];
|
|
84
|
+
const rb = severityOrder[bSeverity];
|
|
88
85
|
if (ra !== rb)
|
|
89
86
|
return ra > rb ? a : b;
|
|
90
87
|
return a.id <= b.id ? a : b;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cve-lite-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.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": {
|
|
@@ -19,14 +19,12 @@
|
|
|
19
19
|
"test:watch": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch --passWithNoTests"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"better-sqlite3": "^12.8.0",
|
|
23
22
|
"fflate": "^0.8.3",
|
|
24
23
|
"semver": "^7.8.5",
|
|
25
24
|
"yaml": "^2.7.1",
|
|
26
25
|
"yarn-lockfile": "^1.1.0"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
30
28
|
"@types/jest": "^30.0.0",
|
|
31
29
|
"@types/node": "^24.0.0",
|
|
32
30
|
"@types/semver": "^7.8.0",
|
|
@@ -50,7 +48,7 @@
|
|
|
50
48
|
],
|
|
51
49
|
"license": "MIT",
|
|
52
50
|
"engines": {
|
|
53
|
-
"node": ">=
|
|
51
|
+
"node": "^22.13.0 || >=23.4.0"
|
|
54
52
|
},
|
|
55
53
|
"repository": {
|
|
56
54
|
"type": "git",
|