vigievuln 1.1.2 → 1.2.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/CHANGELOG.md +25 -0
- package/README.md +51 -141
- package/completions/vigievuln.bash +1 -1
- package/completions/vigievuln.zsh +1 -0
- package/lib/account-client.js +21 -14
- package/lib/account-session.js +6 -2
- package/lib/advisory-compression.js +25 -0
- package/lib/advisory-fixes.js +21 -0
- package/lib/advisory-store-sqlite.js +156 -0
- package/lib/advisory-store.js +484 -0
- package/lib/airgap-project.js +117 -0
- package/lib/application-plugins/runner.js +22 -13
- package/lib/application-plugins/wordpress.js +4 -3
- package/lib/application-providers/live-snapshot.js +1 -12
- package/lib/application-providers/snapshot-cache.js +27 -0
- package/lib/application-providers/wordfence-client.js +3 -3
- package/lib/attribution.js +2 -2
- package/lib/cache-archive-sqlite.js +215 -0
- package/lib/cache-archive.js +357 -26
- package/lib/cache-db.js +142 -0
- package/lib/cache-directory.js +18 -74
- package/lib/cache-policy.js +25 -0
- package/lib/cache-repository.js +48 -0
- package/lib/cache-startup.js +54 -0
- package/lib/certfr.js +9 -9
- package/lib/cli-command-routing.js +29 -6
- package/lib/cli-groups.js +32 -3
- package/lib/cli-project-commands.js +47 -6
- package/lib/cli-setup.js +300 -0
- package/lib/codecs/binary/pe-metadata.js +79 -0
- package/lib/codecs/binary/scan.js +4 -3
- package/lib/codecs/binary.codec.js +4 -2
- package/lib/codecs/composer/registry.js +8 -6
- package/lib/codecs/go/parse.js +7 -9
- package/lib/codecs/go/registry.js +7 -5
- package/lib/codecs/go.codec.js +5 -0
- package/lib/codecs/maven.codec.js +73 -8
- package/lib/codecs/npm/collect.js +12 -5
- package/lib/codecs/npm/parse.js +12 -5
- package/lib/codecs/npm/registry.js +42 -12
- package/lib/codecs/nuget/registry.js +8 -6
- package/lib/codecs/pypi/registry.js +8 -6
- package/lib/codecs/ruby/registry.js +7 -5
- package/lib/compression-dictionary.js +5 -0
- package/lib/coverage-diagnostics.js +26 -0
- package/lib/cve-download.js +157 -41
- package/lib/cve-legacy-ranges.js +59 -0
- package/lib/cve-match.js +85 -17
- package/lib/cve-npm-proxy.js +29 -0
- package/lib/cve-report.js +145 -58
- package/lib/cve-version-verdict.js +77 -0
- package/lib/deps-descriptor.js +8 -3
- package/lib/epss.js +13 -8
- package/lib/euvd.js +32 -8
- package/lib/gcve-feed.js +103 -0
- package/lib/gcve-index.js +181 -0
- package/lib/gcve.js +1 -1
- package/lib/github-publisher-maven.js +40 -0
- package/lib/hash-id.js +5 -5
- package/lib/hosted-proxy.js +6 -1
- package/lib/i18n.js +31 -8
- package/lib/json-cache.js +18 -0
- package/lib/json-export.js +16 -2
- package/lib/kev.js +7 -8
- package/lib/line-stream.js +23 -0
- package/lib/maven-airgap.js +80 -0
- package/lib/maven-cache.js +21 -0
- package/lib/maven-license.js +2 -1
- package/lib/maven-presence.js +2 -2
- package/lib/maven-reactor.js +23 -14
- package/lib/maven-repo.js +11 -6
- package/lib/merge-sources.js +25 -18
- package/lib/native-advisories.js +268 -0
- package/lib/nvd-bulk.js +145 -0
- package/lib/nvd-package-ranges.js +109 -0
- package/lib/nvd.js +52 -24
- package/lib/osv-db.js +253 -59
- package/lib/osv-legacy.js +57 -0
- package/lib/osv.js +241 -168
- package/lib/outdated.js +11 -12
- package/lib/package-metadata.js +141 -0
- package/lib/package-versions.js +52 -0
- package/lib/packagist-audit.js +6 -6
- package/lib/provenance.js +73 -19
- package/lib/providers/common.js +11 -1
- package/lib/providers/gcve.js +17 -0
- package/lib/providers/github.js +1 -0
- package/lib/providers/index.js +49 -26
- package/lib/providers/vigievuln.js +7 -0
- package/lib/proxy-cache.js +1 -1
- package/lib/proxy-scope.js +59 -0
- package/lib/proxy-throttle.js +71 -0
- package/lib/resource-cache/engine.js +36 -9
- package/lib/resource-cache/sqlite-store.js +95 -0
- package/lib/resource-cache/validate.js +5 -0
- package/lib/retire.js +24 -24
- package/lib/ruby-version.js +36 -0
- package/lib/sarif-export.js +1 -1
- package/lib/sbom-export.js +11 -7
- package/lib/snyk.js +32 -20
- package/lib/source-profile.js +67 -0
- package/lib/sqlite-driver.js +46 -0
- package/lib/transitive.js +69 -34
- package/lib/unmanaged.js +2 -1
- package/lib/vigievuln-advisories.js +47 -0
- package/package.json +7 -6
- package/vigievuln.js +380 -107
|
@@ -18,32 +18,97 @@ const cveIndexScanner = {
|
|
|
18
18
|
id: "cve-index",
|
|
19
19
|
kind: "cve", // résultats → chapitre CVE (mergés avec OSV)
|
|
20
20
|
async scan(deps, opts = {}) {
|
|
21
|
-
const { ensureCveIndex, newIndex, addToIndex } = require("../cve-download");
|
|
21
|
+
const { ensureCveIndex, loadCveIndex, newIndex, addToIndex, isCurrentCveIndex } = require("../cve-download");
|
|
22
|
+
const store = require("../advisory-store").openAdvisoryStore();
|
|
23
|
+
try {
|
|
24
|
+
const { matchCveStore } = require("../native-advisories");
|
|
25
|
+
const hasStored = () => !!(store.getSourceCoverage('cveproject','*') || store.getSourceCoverage('cveproject-legacy','*'));
|
|
26
|
+
const fallback = err => {
|
|
27
|
+
const idx = loadCveIndex();
|
|
28
|
+
if (!idx && !hasStored()) throw err;
|
|
29
|
+
const result = matchCveStore(deps, store, idx);
|
|
30
|
+
return {matches:result.matches,meta:{cveDataDate:idx?.meta?.builtAt || null,incomplete:true,refreshError:err.message,identityUncertain:result.identityUncertain || (!!idx && !isCurrentCveIndex(idx)),uncertainCandidates:result.uncertainCandidates,oldProjection:!!idx && !isCurrentCveIndex(idx)}};
|
|
31
|
+
};
|
|
22
32
|
if (opts.hostedProxy && !opts.offline && !opts.cveOffline) {
|
|
33
|
+
try {
|
|
23
34
|
const keys = new Set();
|
|
24
35
|
for (const dep of deps.values()) {
|
|
25
|
-
if (dep.ecosystem
|
|
36
|
+
if ((dep.ecosystem && dep.ecosystem !== "maven") || dep.provenance === "binary") continue;
|
|
26
37
|
const group = String(dep.groupId || "").toLowerCase(), artifact = String(dep.artifactId || "").toLowerCase();
|
|
27
38
|
if (group && artifact) keys.add("p:" + group + ":" + artifact);
|
|
28
39
|
if (artifact) keys.add("a:" + artifact);
|
|
29
40
|
}
|
|
30
|
-
const idx = newIndex(), all = [...keys], seen = new Set();
|
|
41
|
+
const idx = newIndex(), all = [...keys], seen = new Set(), collected = [];
|
|
42
|
+
let oldestFetchedAt = Infinity, oldestBuiltAt = Infinity, timestampsKnown = true, builtAtKnown = true, staleResponse = false;
|
|
31
43
|
for (let i = 0; i < all.length; i += 200) {
|
|
32
|
-
const res = await require("../providers").getResource("github", "cve-maven", { keys: all.slice(i, i + 200) }, {
|
|
44
|
+
const res = await require("../providers").getResource("github", "cve-maven", { keys: all.slice(i, i + 200) }, { forceRefresh:true });
|
|
33
45
|
if (!res.ok) throw new Error(`hosted CVE index unavailable (HTTP ${res.status})`);
|
|
34
46
|
const data = await res.json();
|
|
35
47
|
if (!Array.isArray(data.cves)) throw new Error("invalid hosted CVE index response");
|
|
48
|
+
const stamp = Date.parse(res.headers?.get('x-fad-proxy-fetched-at') || '');
|
|
49
|
+
if (!Number.isFinite(stamp) || stamp <= 0 || stamp > Date.now()+300000) timestampsKnown = false;
|
|
50
|
+
else oldestFetchedAt = Math.min(oldestFetchedAt, stamp);
|
|
51
|
+
if (res.headers?.get('x-fad-proxy') === 'stale') staleResponse = true;
|
|
52
|
+
const built = Date.parse(data.builtAt || '');
|
|
53
|
+
if (!Number.isFinite(built) || built <= 0 || built > Date.now()+300000) builtAtKnown = false;
|
|
54
|
+
else oldestBuiltAt = Math.min(oldestBuiltAt, built);
|
|
36
55
|
idx.meta.builtAt = data.builtAt;
|
|
37
|
-
for (const cve of data.cves) if (!seen.has(cve.id)) { seen.add(cve.id); addToIndex(idx, cve); }
|
|
56
|
+
for (const cve of data.cves) if (!seen.has(cve.id)) { seen.add(cve.id); addToIndex(idx, cve); collected.push(cve); }
|
|
38
57
|
}
|
|
39
|
-
|
|
58
|
+
const fetchedAt = timestampsKnown && Number.isFinite(oldestFetchedAt) ? oldestFetchedAt : null;
|
|
59
|
+
const provenance = {transport:'proxy'};
|
|
60
|
+
const {projectedCveEnvelope} = require('../native-advisories');
|
|
61
|
+
if (fetchedAt) {
|
|
62
|
+
for (let i=0;i<collected.length;i+=100) store.commit({records:collected.slice(i,i+100).map(cve=>projectedCveEnvelope(cve,fetchedAt,provenance))});
|
|
63
|
+
store.commit({coverages:[{source:'cveproject-legacy',ecosystem:'*',fetchedAt,complete:false,provenance}]});
|
|
64
|
+
}
|
|
65
|
+
// A proxy projection cannot prove that a rejected CVE was reinstated.
|
|
66
|
+
// Preserve the native tombstone regardless of the proxy corpus date;
|
|
67
|
+
// only a newer native published revision may replace it in the store.
|
|
68
|
+
let identityUncertain = false;
|
|
69
|
+
const uncertainCandidates=[];
|
|
70
|
+
let matches = matchDepsAgainstCves(deps,idx,{onUncertain:candidate=>{identityUncertain=true;uncertainCandidates.push(candidate);}}), conflict = false;
|
|
71
|
+
const {isWithdrawn} = require('../advisory-store');
|
|
72
|
+
matches = matches.filter(m => {
|
|
73
|
+
const native = store.getRecord('cveproject',m.cve.id);
|
|
74
|
+
if (native && isWithdrawn(native)) {conflict=true; return false;}
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
// Other native revisions may supersede a complete proxy batch only
|
|
78
|
+
// when their revision is demonstrably newer than its corpus date.
|
|
79
|
+
if (builtAtKnown && Number.isFinite(oldestBuiltAt)) {
|
|
80
|
+
const nativeResult=matchCveStore(deps,store,null), nativeMatches=nativeResult.matches;
|
|
81
|
+
identityUncertain ||= nativeResult.identityUncertain;
|
|
82
|
+
uncertainCandidates.push(...nativeResult.uncertainCandidates);
|
|
83
|
+
const newer = id => {const r=store.getRecord('cveproject',id);const at=Date.parse(r?.document?.cveMetadata?.dateUpdated || '');return r && Number.isFinite(at) && at > oldestBuiltAt ? r : null;};
|
|
84
|
+
matches=matches.filter(m=>{const r=newer(m.cve.id);if(r){conflict=true;return false;}return true;});
|
|
85
|
+
for (const m of nativeMatches) if(newer(m.cve.id)) {conflict=true;matches.push(m);}
|
|
86
|
+
}
|
|
87
|
+
return { matches, meta: { cveDataDate: builtAtKnown && Number.isFinite(oldestBuiltAt) ? new Date(oldestBuiltAt).toISOString() : null, incomplete: true,
|
|
88
|
+
stale: staleResponse || (fetchedAt != null && opts.queryTtlMs != null && Date.now()-fetchedAt >= opts.queryTtlMs), timestampUnknown: !fetchedAt, conflict, identityUncertain, uncertainCandidates } };
|
|
89
|
+
} catch (err) { return fallback(err); }
|
|
40
90
|
}
|
|
41
|
-
|
|
91
|
+
let idx;
|
|
92
|
+
if ((opts.offline || opts.cveOffline) && !loadCveIndex() && (store.getSourceCoverage('cveproject','*') || store.getSourceCoverage('cveproject-legacy','*'))) idx = null;
|
|
93
|
+
else try { idx = await ensureCveIndex({
|
|
42
94
|
force: !!opts.cveRefresh && !opts.offline,
|
|
43
95
|
offline: !!opts.cveOffline || !!opts.offline,
|
|
44
96
|
verbose: opts.verbose,
|
|
97
|
+
ttlMs: opts.queryTtlMs,
|
|
98
|
+
}); } catch (err) { return fallback(err); }
|
|
99
|
+
const result = matchCveStore(deps, store, idx);
|
|
100
|
+
const oldProjection = !!idx && !isCurrentCveIndex(idx);
|
|
101
|
+
// A complete current Maven index is itself a complete projection of the
|
|
102
|
+
// source, even if the separate native-record journal is only partial.
|
|
103
|
+
const snapshot = store.db.prepare("SELECT complete,stale FROM cache_snapshots WHERE namespace='cve_lookup'").get();
|
|
104
|
+
const scopedBucket=store.db.prepare("SELECT 1 FROM cache_entries WHERE namespace='airgap-cve-index' AND key=? AND stale=0");
|
|
105
|
+
const scopedComplete=!!idx && [...deps.values()].filter(d=>(!d.ecosystem||d.ecosystem==='maven') && d.provenance!=='binary' && d.scope!=='parent').every(d=>{
|
|
106
|
+
const artifact=String(d.artifactId||d.name||'').toLowerCase();
|
|
107
|
+
return scopedBucket.get(`p:${String(d.groupId||d.namespace||'').toLowerCase()}:${artifact}`) && scopedBucket.get(`a:${artifact}`);
|
|
45
108
|
});
|
|
46
|
-
|
|
109
|
+
const completeIndex = !!idx && !oldProjection && snapshot?.stale === 0 && (snapshot.complete === 1 || scopedComplete);
|
|
110
|
+
return { matches: result.matches, meta: { cveDataDate: idx?.meta?.builtAt || (result.coverage?.fetchedAt ? new Date(result.coverage.fetchedAt).toISOString() : null), incomplete: !(result.coverage?.complete || completeIndex), identityUncertain:result.identityUncertain || oldProjection, uncertainCandidates:result.uncertainCandidates,oldProjection } };
|
|
111
|
+
} finally { store.close(); }
|
|
47
112
|
},
|
|
48
113
|
};
|
|
49
114
|
|
|
@@ -52,14 +52,13 @@ function isResolvedVersion(v) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* --ignore-test: what a production install would NOT ship.
|
|
55
|
+
* --ignore-test: what a production install would NOT ship. Declared-dev
|
|
56
56
|
* scopes as before, plus a transitive reachable only through dev deps (isDev). A
|
|
57
57
|
* declared devDependency that a prod dep ALSO pulls in (isDev === false) ships, so it
|
|
58
58
|
* stays.
|
|
59
59
|
*/
|
|
60
60
|
function isDevOnly(scope, isDev) {
|
|
61
61
|
if (isDev) return true;
|
|
62
|
-
if (scope === "optional") return true;
|
|
63
62
|
return scope === "dev" && isDev !== false;
|
|
64
63
|
}
|
|
65
64
|
|
|
@@ -179,7 +178,9 @@ function upsert(out, dep, manifestPath, lockType, relations) {
|
|
|
179
178
|
// one name are routinely classified differently (ms@2.1.3 under a prod dep,
|
|
180
179
|
// ms@1.0.0 only under jest). "dev" marks a dev-only occurrence; attribution reads a
|
|
181
180
|
// version as dev only when EVERY occurrence of it is.
|
|
182
|
-
|
|
181
|
+
// A dev declaration can also be reachable through a production optional
|
|
182
|
+
// path (npm devOptional). Preserve that production evidence per version.
|
|
183
|
+
const scopeToken = dep.isDev ? "dev" : (record.scope === 'dev' ? 'prod' : (record.scope || "prod"));
|
|
183
184
|
record.versionScopes = {};
|
|
184
185
|
for (const v of record.versions) record.versionScopes[v] = [scopeToken];
|
|
185
186
|
// Union evidence per version before the coordinate-wide scope/depth merge.
|
|
@@ -301,7 +302,7 @@ function collectNpmDeps(rootDir, opts = {}) {
|
|
|
301
302
|
if (pj && !hasLock) {
|
|
302
303
|
let pinned = 0, ranges = 0;
|
|
303
304
|
for (const d of pj.deps) {
|
|
304
|
-
if (ignoreTest &&
|
|
305
|
+
if (ignoreTest && d.isDev) continue;
|
|
305
306
|
if (deps2Exclude && deps2Exclude.test(d.name)) continue;
|
|
306
307
|
if (isResolvedVersion(d.version)) {
|
|
307
308
|
upsert(out, { name: d.name, version: d.version, scope: d.scope || "prod", isDev: !!d.isDev }, group.packageJson, "package-json-nolock", ["direct"]);
|
|
@@ -331,7 +332,11 @@ function collectNpmDeps(rootDir, opts = {}) {
|
|
|
331
332
|
|
|
332
333
|
// Used only as a source of scope info — never emits deps on its own. Keyed by
|
|
333
334
|
// the DECLARED name, which for an alias is the alias, not the real package.
|
|
334
|
-
const directScopes = pj ? new Map(
|
|
335
|
+
const directScopes = pj ? new Map() : null;
|
|
336
|
+
if (pj) for (const d of pj.deps) {
|
|
337
|
+
const name=d.alias || d.name, previous=directScopes.get(name);
|
|
338
|
+
if (!previous || rankScope(d.scope)>rankScope(previous)) directScopes.set(name,d.scope);
|
|
339
|
+
}
|
|
335
340
|
|
|
336
341
|
if (pl) {
|
|
337
342
|
parsedCount++;
|
|
@@ -408,6 +413,8 @@ function webjarToNpm(dep) {
|
|
|
408
413
|
if (g !== "org.webjars" && !g.startsWith("org.webjars.")) return null;
|
|
409
414
|
let name = dep.artifactId || "";
|
|
410
415
|
if (!name) return null;
|
|
416
|
+
// The Java locator is WebJars infrastructure, not a bundled JS library.
|
|
417
|
+
if (g === "org.webjars" && /^webjars-locator(?:-|$)/.test(name)) return null;
|
|
411
418
|
if (name.includes("__")) name = "@" + name.replace(/__/g, "/");
|
|
412
419
|
return { name, version: dep.version || null };
|
|
413
420
|
}
|
package/lib/codecs/npm/parse.js
CHANGED
|
@@ -272,7 +272,7 @@ function parsePackageJson(filePath) {
|
|
|
272
272
|
const push = (obj, scope) => {
|
|
273
273
|
for (const [name, version] of Object.entries(obj || {})) {
|
|
274
274
|
if (isWorkspaceVersion(version)) continue;
|
|
275
|
-
const isDev = scope === "dev"
|
|
275
|
+
const isDev = scope === "dev";
|
|
276
276
|
// "lodash-legacy": "npm:lodash@4.17.20" → lodash @ 4.17.20 (alias kept).
|
|
277
277
|
const al = parseNpmAlias(version);
|
|
278
278
|
if (al) deps.push({ name: al.name, alias: name, version: al.range, scope, isDev, depth: 0 });
|
|
@@ -346,15 +346,16 @@ function parsePackageLock(filePath) {
|
|
|
346
346
|
// node_modules/, so depth===0 alone doesn't mean "direct". An entry
|
|
347
347
|
// is direct iff it appears in the root project's dependency lists.
|
|
348
348
|
let scope = "prod";
|
|
349
|
-
if (entry.dev
|
|
349
|
+
if (entry.dev && !entry.devOptional) scope = "dev";
|
|
350
|
+
else if (entry.devOptional) scope = "optional";
|
|
350
351
|
else if (entry.optional) scope = "optional";
|
|
351
352
|
else if (entry.peer) scope = "peer";
|
|
352
353
|
const isDirectDep = depth === 0 && isAnyDirect(installName);
|
|
353
354
|
if (isDirectDep) {
|
|
354
|
-
if (isDirect(installName, "
|
|
355
|
+
if (isDirect(installName, "prod")) scope = "prod";
|
|
355
356
|
else if (isDirect(installName, "optional")) scope = "optional";
|
|
356
357
|
else if (isDirect(installName, "peer")) scope = "peer";
|
|
357
|
-
else scope = "
|
|
358
|
+
else scope = "dev";
|
|
358
359
|
} else if (depth > 0 || !isAnyDirect(installName)) {
|
|
359
360
|
// Flattened-but-not-direct = transitive. Keep dev/optional flags
|
|
360
361
|
// for filtering, but record it as a transitive.
|
|
@@ -362,7 +363,12 @@ function parsePackageLock(filePath) {
|
|
|
362
363
|
}
|
|
363
364
|
// isDev flag survives the scope reclassification: a flattened
|
|
364
365
|
// transitive of a dev-only dep is still dev-only.
|
|
365
|
-
const
|
|
366
|
+
const directProduction = isDirectDep && ["prod", "optional", "peer"].some(s => isDirect(installName, s));
|
|
367
|
+
// npm's devOptional means both a dev path and an optional production path.
|
|
368
|
+
const isDev = !directProduction && !entry.devOptional && !!(entry.dev || (isDirectDep && isDirect(installName, "dev")));
|
|
369
|
+
// A dev-only direct declaration with a production optional path is
|
|
370
|
+
// indirect in production, even when npm hoists it to the root.
|
|
371
|
+
if (isDirectDep && scope === 'dev' && entry.devOptional) scope = 'transitive';
|
|
366
372
|
out.deps.push({
|
|
367
373
|
name,
|
|
368
374
|
...(name !== installName ? { alias: installName } : {}),
|
|
@@ -381,6 +387,7 @@ function parsePackageLock(filePath) {
|
|
|
381
387
|
let scope = "prod";
|
|
382
388
|
if (entry.dev) scope = "dev";
|
|
383
389
|
else if (entry.optional) scope = "optional";
|
|
390
|
+
if (depth > 0) scope = "transitive";
|
|
384
391
|
const isDev = !!entry.dev || parentIsDev;
|
|
385
392
|
// v1 spells an alias install in the version: "npm:string-width@4.2.3".
|
|
386
393
|
const al = parseNpmAlias(entry.version);
|
|
@@ -26,18 +26,15 @@ const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
|
26
26
|
|
|
27
27
|
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
28
28
|
const CACHE_PATH = path.join(CACHE_DIR, "npm-registry-cache.json");
|
|
29
|
-
const CACHE_MAX_AGE_MS =
|
|
29
|
+
const CACHE_MAX_AGE_MS = 4 * 3600 * 1000;
|
|
30
|
+
const sourceFetchedAt=new WeakMap();
|
|
30
31
|
|
|
31
32
|
function loadCache() {
|
|
32
|
-
|
|
33
|
-
catch { return { meta: { fetchedAt: 0 }, entries: {} }; }
|
|
33
|
+
return require('../../json-cache').load(CACHE_DIR,'npm-registry',{ meta: { fetchedAt: 0 }, entries: {} });
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function saveCache(data) {
|
|
37
|
-
|
|
38
|
-
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
39
|
-
fs.writeFileSync(CACHE_PATH, JSON.stringify(data));
|
|
40
|
-
} catch { /* ignore */ }
|
|
37
|
+
require('../../json-cache').save(CACHE_DIR,'npm-registry',data);
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
/** Pull a recommended replacement out of a free-form deprecation message. */
|
|
@@ -117,10 +114,15 @@ async function fetchPackument(name, opts = {}) {
|
|
|
117
114
|
const ah = authHeaderFor(base);
|
|
118
115
|
if (ah) headers.Authorization = ah;
|
|
119
116
|
try {
|
|
117
|
+
const hosted = base.name === "public" && require("../../providers").hasHostedProxy();
|
|
120
118
|
const res = await require("../../providers").getResource("npm", "package", { name },
|
|
121
|
-
{ fetcher, headers, signal: AbortSignal.timeout(timeoutMs),
|
|
119
|
+
{ fetcher, headers, ...(hosted ? { requestTimeoutMs: timeoutMs } : { signal: AbortSignal.timeout(timeoutMs) }),
|
|
122
120
|
...(base.name === "public" ? {} : { urlOverride: url, direct: true }) });
|
|
123
|
-
if (res.ok)
|
|
121
|
+
if (res.ok) {
|
|
122
|
+
const body=await res.json(),fetchedAt=Date.parse(res.headers?.get('x-fad-proxy-fetched-at')||'');
|
|
123
|
+
if(body&&typeof body==='object'&&Number.isFinite(fetchedAt))sourceFetchedAt.set(body,fetchedAt);
|
|
124
|
+
return body;
|
|
125
|
+
}
|
|
124
126
|
lastErr = `HTTP ${res.status}`;
|
|
125
127
|
statuses.push(res.status);
|
|
126
128
|
} catch (err) {
|
|
@@ -156,10 +158,23 @@ async function checkNpmRegistryDeps(resolvedDeps, opts = {}) {
|
|
|
156
158
|
if (!targets.length) return result;
|
|
157
159
|
|
|
158
160
|
const cache = loadCache();
|
|
159
|
-
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && (
|
|
161
|
+
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && require('../../cache-policy').fresh(cache.meta.fetchedAt, CACHE_MAX_AGE_MS);
|
|
162
|
+
const previous = !fresh && !offline ? {entries:cache.entries, fetchedAt:cache.meta?.fetchedAt} : null;
|
|
160
163
|
if (!fresh && !offline) cache.entries = {};
|
|
161
164
|
|
|
162
165
|
const cacheKey = t => `${t.npmName}@${t.version}`;
|
|
166
|
+
// A definitive packument 404/410 is evidence about the package name, not
|
|
167
|
+
// just the version used for the probe. Preserve it across versions offline
|
|
168
|
+
// unless another cached observation for that name found a packument.
|
|
169
|
+
const offlineAbsent = new Map();
|
|
170
|
+
if (offline) for (const [key, value] of Object.entries(cache.entries || {})) {
|
|
171
|
+
const split = key.lastIndexOf('@');
|
|
172
|
+
if (split <= 0) continue;
|
|
173
|
+
const name = key.slice(0, split), status = offlineAbsent.get(name) || { absent: false, present: false };
|
|
174
|
+
if (value?.absent) status.absent = true;
|
|
175
|
+
else if (value && !value.error) status.present = true;
|
|
176
|
+
offlineAbsent.set(name, status);
|
|
177
|
+
}
|
|
163
178
|
const liveCount = offline ? 0 : targets.filter(t => !cache.entries[cacheKey(t)]).length;
|
|
164
179
|
if (liveCount && !offline && !onProgress) {
|
|
165
180
|
console.log(`📦 npm registry: checking ${targets.length} packages for deprecation${allLibs ? " + outdated" : ""} (${liveCount} live, ${targets.length - liveCount} cached)…`);
|
|
@@ -168,6 +183,7 @@ async function checkNpmRegistryDeps(resolvedDeps, opts = {}) {
|
|
|
168
183
|
// Incremental progress — fetching ~hundreds/thousands of packuments at
|
|
169
184
|
// concurrency N would otherwise be total silence for a minute or more.
|
|
170
185
|
let processed = 0;
|
|
186
|
+
let oldestFetchedAt=Date.now();
|
|
171
187
|
const startedAt = Date.now();
|
|
172
188
|
const printProgress = (final = false) => {
|
|
173
189
|
if (onProgress) { onProgress(processed, targets.length); return; }
|
|
@@ -184,8 +200,21 @@ async function checkNpmRegistryDeps(resolvedDeps, opts = {}) {
|
|
|
184
200
|
const { dep, npmName, version } = t;
|
|
185
201
|
const key = cacheKey(t);
|
|
186
202
|
let extracted = cache.entries[key];
|
|
203
|
+
if (!extracted && offline) {
|
|
204
|
+
const status = offlineAbsent.get(npmName);
|
|
205
|
+
if (status?.absent && !status.present) extracted = { absent: true };
|
|
206
|
+
}
|
|
207
|
+
if (!extracted && offline && !registries.length) {
|
|
208
|
+
const seeded=require('../../package-versions').getVersion('npm',npmName,version);
|
|
209
|
+
if (seeded) {
|
|
210
|
+
const manifest=JSON.parse(seeded.body);
|
|
211
|
+
const f=packumentToFindings({versions:{[version]:manifest}},{version});
|
|
212
|
+
extracted={deprecated:null,latest:null,latestDate:null,license:f.license || null};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
187
215
|
if (!extracted) {
|
|
188
216
|
const packument = await fetchPackument(npmName, { offline, registries });
|
|
217
|
+
if(packument&&typeof packument==='object')oldestFetchedAt=Math.min(oldestFetchedAt,sourceFetchedAt.get(packument)||Date.now());
|
|
189
218
|
if (packument && !packument.error) {
|
|
190
219
|
const f = packumentToFindings(packument, { version });
|
|
191
220
|
extracted = {
|
|
@@ -224,8 +253,9 @@ async function checkNpmRegistryDeps(resolvedDeps, opts = {}) {
|
|
|
224
253
|
if (liveCount) printProgress(true);
|
|
225
254
|
|
|
226
255
|
if (!offline) {
|
|
227
|
-
if (!fresh) cache.meta = { fetchedAt:
|
|
228
|
-
|
|
256
|
+
if (!fresh) cache.meta = { fetchedAt: oldestFetchedAt };
|
|
257
|
+
require('../../cache-policy').preserveEntries(cache, previous);
|
|
258
|
+
saveCache(cache);
|
|
229
259
|
}
|
|
230
260
|
|
|
231
261
|
result.deprecated.sort((a, b) => a.dep.artifactId.localeCompare(b.dep.artifactId));
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* API: https://api.nuget.org/v3/registration5-gz-semver2/{lowerid}/index.json
|
|
6
6
|
* → { items: [ { items: [ { catalogEntry: { version, deprecation } } ] } ] }
|
|
7
7
|
*
|
|
8
|
-
* Cached in ~/.fad-checker/nuget-cache.json for
|
|
8
|
+
* Cached in ~/.fad-checker/nuget-cache.json for 4h.
|
|
9
9
|
*
|
|
10
10
|
* @author: N.BRAUN
|
|
11
11
|
* @email: pp9ping@gmail.com
|
|
@@ -19,10 +19,10 @@ const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
|
19
19
|
|
|
20
20
|
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
21
21
|
const CACHE_PATH = path.join(CACHE_DIR, "nuget-cache.json");
|
|
22
|
-
const CACHE_MAX_AGE_MS =
|
|
22
|
+
const CACHE_MAX_AGE_MS = 4 * 3600 * 1000;
|
|
23
23
|
|
|
24
|
-
function loadCache() {
|
|
25
|
-
function saveCache(d) {
|
|
24
|
+
function loadCache() { return require('../../json-cache').load(CACHE_DIR,'nuget',{ entries: {}, meta: {} }); }
|
|
25
|
+
function saveCache(d) { require('../../json-cache').save(CACHE_DIR,'nuget',d); }
|
|
26
26
|
function isStable(v) { return /^\d+(\.\d+)*$/.test(String(v || "")); }
|
|
27
27
|
function cmp(a, b) {
|
|
28
28
|
const pa = String(a).split(/[.\-+]/).map(n => parseInt(n, 10) || 0);
|
|
@@ -135,7 +135,8 @@ async function checkNugetRegistryDeps(deps, opts = {}) {
|
|
|
135
135
|
const result = { deprecated: [], outdated: [], licensed: [], private: [] };
|
|
136
136
|
if (!targets.length) return result;
|
|
137
137
|
const cache = loadCache();
|
|
138
|
-
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && (
|
|
138
|
+
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && require('../../cache-policy').fresh(cache.meta.fetchedAt, CACHE_MAX_AGE_MS);
|
|
139
|
+
const previous = !fresh && !offline ? {entries:cache.entries, fetchedAt:cache.meta?.fetchedAt} : null;
|
|
139
140
|
if (!fresh && !offline) cache.entries = {};
|
|
140
141
|
const limit = pLimit(concurrency);
|
|
141
142
|
await Promise.all(targets.map(t => limit(async () => {
|
|
@@ -168,7 +169,8 @@ async function checkNugetRegistryDeps(deps, opts = {}) {
|
|
|
168
169
|
// fresh to the next ONLINE run and skip its refetch.
|
|
169
170
|
if (!offline) {
|
|
170
171
|
if (!fresh) cache.meta = { fetchedAt: Date.now() };
|
|
171
|
-
|
|
172
|
+
require('../../cache-policy').preserveEntries(cache, previous);
|
|
173
|
+
saveCache(cache);
|
|
172
174
|
}
|
|
173
175
|
return result;
|
|
174
176
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* API: https://pypi.org/pypi/{name}/json
|
|
6
6
|
* → { info: { version, classifiers[] }, releases: { "<v>": [{ yanked, yanked_reason }] } }
|
|
7
7
|
*
|
|
8
|
-
* Cached in ~/.fad-checker/pypi-cache.json for
|
|
8
|
+
* Cached in ~/.fad-checker/pypi-cache.json for 4h.
|
|
9
9
|
*
|
|
10
10
|
* @author: N.BRAUN
|
|
11
11
|
* @email: pp9ping@gmail.com
|
|
@@ -19,10 +19,10 @@ const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
|
19
19
|
|
|
20
20
|
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
21
21
|
const CACHE_PATH = path.join(CACHE_DIR, "pypi-cache.json");
|
|
22
|
-
const CACHE_MAX_AGE_MS =
|
|
22
|
+
const CACHE_MAX_AGE_MS = 4 * 3600 * 1000;
|
|
23
23
|
|
|
24
|
-
function loadCache() {
|
|
25
|
-
function saveCache(d) {
|
|
24
|
+
function loadCache() { return require('../../json-cache').load(CACHE_DIR,'pypi',{ entries: {}, meta: {} }); }
|
|
25
|
+
function saveCache(d) { require('../../json-cache').save(CACHE_DIR,'pypi',d); }
|
|
26
26
|
function cmp(a, b) {
|
|
27
27
|
const pa = String(a).split(/[.\-+]/).map(n => parseInt(n, 10) || 0);
|
|
28
28
|
const pb = String(b).split(/[.\-+]/).map(n => parseInt(n, 10) || 0);
|
|
@@ -83,7 +83,8 @@ async function checkPypiRegistryDeps(deps, opts = {}) {
|
|
|
83
83
|
const result = { deprecated: [], outdated: [], licensed: [], private: [] };
|
|
84
84
|
if (!targets.length) return result;
|
|
85
85
|
const cache = loadCache();
|
|
86
|
-
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && (
|
|
86
|
+
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && require('../../cache-policy').fresh(cache.meta.fetchedAt, CACHE_MAX_AGE_MS);
|
|
87
|
+
const previous = !fresh && !offline ? {entries:cache.entries, fetchedAt:cache.meta?.fetchedAt} : null;
|
|
87
88
|
if (!fresh && !offline) cache.entries = {};
|
|
88
89
|
const limit = pLimit(concurrency);
|
|
89
90
|
await Promise.all(targets.map(t => limit(async () => {
|
|
@@ -118,7 +119,8 @@ async function checkPypiRegistryDeps(deps, opts = {}) {
|
|
|
118
119
|
// fresh to the next ONLINE run and skip its refetch.
|
|
119
120
|
if (!offline) {
|
|
120
121
|
if (!fresh) cache.meta = { fetchedAt: Date.now() };
|
|
121
|
-
|
|
122
|
+
require('../../cache-policy').preserveEntries(cache, previous);
|
|
123
|
+
saveCache(cache);
|
|
122
124
|
}
|
|
123
125
|
return result;
|
|
124
126
|
}
|
|
@@ -16,10 +16,10 @@ const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
|
16
16
|
|
|
17
17
|
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
18
18
|
const CACHE_PATH = path.join(CACHE_DIR, "rubygems-cache.json");
|
|
19
|
-
const CACHE_MAX_AGE_MS =
|
|
19
|
+
const CACHE_MAX_AGE_MS = 4 * 3600 * 1000;
|
|
20
20
|
|
|
21
|
-
function loadCache() {
|
|
22
|
-
function saveCache(d) {
|
|
21
|
+
function loadCache() { return require('../../json-cache').load(CACHE_DIR,'rubygems',{ entries: {}, meta: {} }); }
|
|
22
|
+
function saveCache(d) { require('../../json-cache').save(CACHE_DIR,'rubygems',d); }
|
|
23
23
|
function isStable(v) { return /^\d+(\.\d+)*$/.test(String(v || "")); }
|
|
24
24
|
function cmp(a, b) {
|
|
25
25
|
const pa = String(a).split(/[.\-+]/).map(n => parseInt(n, 10) || 0);
|
|
@@ -61,7 +61,8 @@ async function checkRubyRegistryDeps(deps, opts = {}) {
|
|
|
61
61
|
const result = { deprecated: [], outdated: [], licensed: [], private: [] };
|
|
62
62
|
if (!targets.length) return result;
|
|
63
63
|
const cache = loadCache();
|
|
64
|
-
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && (
|
|
64
|
+
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && require('../../cache-policy').fresh(cache.meta.fetchedAt, CACHE_MAX_AGE_MS);
|
|
65
|
+
const previous = !fresh && !offline ? {entries:cache.entries, fetchedAt:cache.meta?.fetchedAt} : null;
|
|
65
66
|
if (!fresh && !offline) cache.entries = {};
|
|
66
67
|
const limit = pLimit(concurrency);
|
|
67
68
|
await Promise.all(targets.map(t => limit(async () => {
|
|
@@ -83,7 +84,8 @@ async function checkRubyRegistryDeps(deps, opts = {}) {
|
|
|
83
84
|
})));
|
|
84
85
|
if (!offline) {
|
|
85
86
|
if (!fresh) cache.meta = { fetchedAt: Date.now() };
|
|
86
|
-
|
|
87
|
+
require('../../cache-policy').preserveEntries(cache, previous);
|
|
88
|
+
saveCache(cache);
|
|
87
89
|
}
|
|
88
90
|
return result;
|
|
89
91
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Version 1: common advisory JSON symbols. Changing these bytes requires a cache schema bump.
|
|
4
|
+
const DICTIONARY = Buffer.from("\"version\"\"affected\"\"dateUpdated\"\"providerMetadata\"\"versionType\"\"descriptions\"\"status\"https://plugins.trac.wordpress.org\"vectorString\"\"unaffected\"https://git.kernel.org\"assignerShortName\"\"defaultStatus\"\"baseSeverity\"\"value\"\"shortName\"\"versionStartIncluding\"\"lang\"\"lessThanOrEqual\"\"baseScore\"\"versionEndExcluding\"\"assignerOrgId\"\"datePublished\"\"lessThan\"\"product\"\"description\"https://access.redhat.com\"versions\"\"dateReserved\"\"Automatable\"\"dataVersion\"\"cveMetadata\"\"problemTypes\"\"privilegesRequired\"\"Exploitation\"https://vuldb.com\"references\"\"metrics\"\"NOT_DEFINED\"\"type\"\"cveproject\"\"CVE_RECORD\"\"containers\"\"provenance\"\"releaseTag\"\"vendor\"\"attackComplexity\"vulnerability\"confidentialityImpact\"\"fetchedAt\"\"transport\"\"userInteraction\"\"PUBLISHED\"Vulnrichment\"orgId\"\"availabilityImpact\"\"document\"\"dataType\"\"packages\"\"timestamp\"Coordinatorhttps://catalog.redhat.com\"title\"\"vulnerable\"\"collectionURL\"https://github.com\"source\"\"attackVector\"\"CISA-ADP\"linux_kernel\"integrityImpact\"\"tags\"\"packageName\"\"content\"\"semver\"Technical\"options\"\"HIGH\"\"criteria\"\"vendor-advisory\"\"NONE\"\"direct\"\"x_refsource_REDHAT\"\"third-party-advisory\"https://chromereleases.googleblog.com\"supportingMedia\"\"technical-description\"stable-channel-update-for-desktop_\"x_generator\"\"cweId\"\"permissions-required\"\"cveId\"\"state\"https://www.netgear.com\"vulnerabilityResponseEffort\"\"other\"\"vulnConfidentialityImpact\"https://issues.chromium.org\"credits\"\"name\"\"subConfidentialityImpact\"\"partial\"\"MEDIUM\"\"vulnAvailabilityImpact\"\"Linux\"\"NETWORK\"\"subAvailabilityImpact\"\"programFiles\"attacker\"time\"\"scenarios\"\"timeline\"authenticated\"ssvc\"\"role\"\"vulnIntegrityImpact\"https://www.wordfence.com\"original_commit_for_fix\"\"UNCHANGED\"package-browsersecurity\"attackRequirements\"\"subIntegrityImpact\"Injection\"cpes\"\"vdb-entry\"\"cpeApplicability\"\"engine\"\"Chrome\"\"custom\"build_keycloakinjection\"discovery\"containersManagementmanipulation\"providerUrgency\"\"exploitMaturity\"\"none\"\"Wordfence\"unauthenticatedvulnerabilitiesarbitraryhttps://www.ibm.com\"GENERAL\"\"format\"disclosed\"VulDB\"\"signature\"Improper\"scope\"software\"exploit\"\"reporter\"\"coordinator\"\"issue-tracking\"\"valueDensity\"\"finder\"IndicatorsauthenticationfunctionAuthorization\"operator\"validationKeycloakkeycloak-rhel\"REQUIRED\"versions\"total\"\"CVEProduct\"vulnerableopenshift_data_foundationcomponent\"cpeMatch\"downloadswebsphere_application_serverincluding\"ecosystem\"Advisory\"CRITICAL\"attackersNeutralizationpossibleWordPressVulnogramEnterprisedisclosure\"CVSS\"configurationthreat-intelScriptingCross-Site\"modules\"keycloak-operator-bundle\"patch\"SourceCodester\"Recovery\"\"datePublic\"authorizationpotentiallyoverflowattacker-controlled\"solutions\"informationApplication\"Disclosed\"\"negate\"affectedseverity\"repo\"unauthorizedhttps://bugzilla.redhat.comavailableremotelyfollowing\"UNKNOWN\"argumentavailabilityUnauthenticatedexploitationincludesWebSphere\"Google\"Authenticationexecutionhttps://www.tp-link.comChromium\"chrome\"https://www.totolink.netAuthenticated\"Safety\"administrator\"EXTERNAL\"InformationapplicationTotolinkInsufficientresolvedhttps://gist.github.com\"CHANGED\"NighthawkStudentManagementSystem\"impacts\"\"nodes\"stack-based\"capecId\"parameterrequiredhttps://lavender-bicycle-aprivilegesadministrative\"workarounds\"cluster_observability_operatorcluster-observability-operatormaliciousOpenShift\"NETGEAR\"sensitiveinsufficientfunctionalitycompromisedrecommendscustom-registration-form-builder-with-subidentifiedscriptingenterprise_linuxadvisoriesFoundationOverflowhttps://www.sourcecodester.comGenerationcontactedcorvuspay-woocommerce-integrationVulnerabilityhttps://www.zerodayinitiative.comhttps://www.rockwellautomation.comsecurity-advisorieschangesetDirectorywhatsorder-instant-checkout-for-woocommerLangflowTraversalitsourcecodedenial-of-serviceimproperendpointDevolutionsremediation\"Mattermost\"\"Injection\"untrustedoperatorStack-basedcredentialsWooCommercehttps://talosintelligence.compubliclyEMPLOYEE_MANAGEMENT_SYSTEMallowingout-of-boundsimplementationhermes-agentInterfacecode-projectsCross-siteclassificationcapability\"x_redhatCweChain\"neutralizationCodeIgniter-StudentManagementSystemOpenshiftpayment-gateway-stripe-and-woocommerce-inhttps://hackerone.comContainerhttps://mattermost.atlassian.net\"VulnCheck\"addressingpassworduser-suppliedSecurityPlatform\"x_freeware\"operationscontainer_native_virtualizationcontainer-native-virtualizationCorruption\"release-notes\"\"advisory\"https://jira.mongodb.orgsanitizationstronglycorruptionMattermostPrivilegereferenceprocessingArbitrary", 'utf8');
|
|
5
|
+
module.exports = { DICTIONARY };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// A product-name candidate does not establish package identity. An exact Maven
|
|
4
|
+
// candidate is actionable unless a fresh, independently identified OSV record
|
|
5
|
+
// gives a definite, consistent answer for that same CVE and package/version.
|
|
6
|
+
function needsMavenReview(candidate, store, {ttlMs} = {}) {
|
|
7
|
+
const evidence=candidate?.cve?.coordinateEvidence;
|
|
8
|
+
if (!['explicit-coordinate','curated-module'].includes(evidence)) return false;
|
|
9
|
+
const dep=candidate.dep || {}, name=`${dep.groupId}:${dep.artifactId}`;
|
|
10
|
+
const id=candidate.cve?.id,version=String(dep.version || '');
|
|
11
|
+
if(!id || !dep.groupId || !dep.artifactId || !version) return true;
|
|
12
|
+
const query=store.getQuery({source:'osv',ecosystem:'Maven',name,version},{ttlMs});
|
|
13
|
+
if(!query?.fresh) return true;
|
|
14
|
+
const records=store.getPackageRecords('Maven',name,{source:'osv'}).filter(r=>{
|
|
15
|
+
const d=r.document;
|
|
16
|
+
return !r.withdrawnAt && !d?.withdrawn && [d?.id,...(d?.aliases || [])].includes(id);
|
|
17
|
+
});
|
|
18
|
+
if(!records.length) return true;
|
|
19
|
+
const {vulnVerdict}=require('./osv-db');
|
|
20
|
+
const verdicts=records.map(({document})=>{
|
|
21
|
+
const affected=(document.affected || []).filter(a=>a?.package?.ecosystem==='Maven' && a.package.name===name);
|
|
22
|
+
return affected.length ? vulnVerdict(version,{...document,affected},'Maven') : null;
|
|
23
|
+
});
|
|
24
|
+
return verdicts.some(v=>v===null) || verdicts.some(v=>v!==verdicts[0]);
|
|
25
|
+
}
|
|
26
|
+
module.exports={needsMavenReview};
|