cve-lite-cli 1.0.3 → 1.0.5
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 +110 -46
- package/dist/advisory/advisory-source.js +1 -0
- package/dist/advisory/osv-advisory-source.js +51 -0
- package/dist/banner.js +10 -0
- package/dist/chalk.js +44 -0
- package/dist/cli/args.js +92 -0
- package/dist/cli/help.js +42 -0
- package/dist/constants.js +19 -0
- package/dist/index.js +45 -1259
- package/dist/osv/api.js +26 -0
- package/dist/osv/cache.js +31 -0
- package/dist/osv/severity.js +50 -0
- package/dist/output/formatters.js +113 -0
- package/dist/output/printers.js +319 -0
- package/dist/output/spinner.js +42 -0
- package/dist/parsers/index.js +142 -0
- package/dist/parsers/package-json.js +37 -0
- package/dist/parsers/package-lock.js +40 -0
- package/dist/parsers/pnpm-lock.js +109 -0
- package/dist/parsers/utils.js +32 -0
- package/dist/parsers/yarn-lock.js +25 -0
- package/dist/scanner.js +137 -0
- package/dist/types.js +1 -0
- package/dist/utils/array.js +22 -0
- package/dist/utils/chalk.js +48 -0
- package/dist/utils/file.js +74 -0
- package/dist/utils/version.js +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function looksLikeVersion(value) {
|
|
2
|
+
return /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][^/]+)?$/.test(value);
|
|
3
|
+
}
|
|
4
|
+
export function compareVersions(a, b) {
|
|
5
|
+
const pa = a.split(/[.+-]/).map(n => Number.isFinite(Number(n)) ? Number(n) : n);
|
|
6
|
+
const pb = b.split(/[.+-]/).map(n => Number.isFinite(Number(n)) ? Number(n) : n);
|
|
7
|
+
const len = Math.max(pa.length, pb.length);
|
|
8
|
+
for (let i = 0; i < len; i++) {
|
|
9
|
+
const av = pa[i] ?? 0;
|
|
10
|
+
const bv = pb[i] ?? 0;
|
|
11
|
+
if (typeof av === "number" && typeof bv === "number") {
|
|
12
|
+
if (av !== bv)
|
|
13
|
+
return av - bv;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const as = String(av);
|
|
17
|
+
const bs = String(bv);
|
|
18
|
+
if (as !== bs)
|
|
19
|
+
return as.localeCompare(bs);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
export function parseExactManifestVersion(spec) {
|
|
25
|
+
const cleaned = spec.trim().replace(/^npm:/, "");
|
|
26
|
+
if (looksLikeVersion(cleaned))
|
|
27
|
+
return cleaned;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export function normalizeRawVersion(value) {
|
|
31
|
+
if (typeof value !== "string")
|
|
32
|
+
return null;
|
|
33
|
+
const cleaned = value.replace(/^workspace:/, "").replace(/^npm:/, "").trim();
|
|
34
|
+
if (!cleaned || cleaned.startsWith(".") || cleaned.startsWith(".."))
|
|
35
|
+
return null;
|
|
36
|
+
if (looksLikeVersion(cleaned))
|
|
37
|
+
return cleaned;
|
|
38
|
+
return null;
|
|
39
|
+
}
|