vigievuln 1.1.0 → 1.1.2
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 +13 -0
- package/README.md +18 -11
- package/lib/account-client.js +29 -3
- package/lib/account-session.js +5 -2
- package/lib/account-terms.js +13 -0
- package/lib/cache-archive.js +46 -24
- package/lib/cache-directory.js +77 -0
- package/lib/certfr.js +1 -1
- package/lib/cli-project-commands.js +16 -5
- package/lib/cli-watch.js +2 -1
- package/lib/codecs/composer/registry.js +3 -2
- package/lib/codecs/go/registry.js +1 -1
- package/lib/codecs/maven/jar-scan.js +25 -17
- package/lib/codecs/npm/registry.js +1 -1
- package/lib/codecs/nuget/registry.js +3 -2
- package/lib/codecs/pypi/parse.js +15 -8
- package/lib/codecs/pypi/registry.js +3 -2
- package/lib/codecs/pypi.codec.js +1 -1
- package/lib/codecs/ruby/registry.js +1 -1
- package/lib/config.js +1 -1
- package/lib/cve-download.js +1 -1
- package/lib/cve-report.js +3 -1
- package/lib/epss.js +1 -1
- package/lib/euvd.js +1 -1
- package/lib/hash-id.js +1 -1
- package/lib/hosted-proxy.js +19 -17
- package/lib/kev.js +5 -2
- package/lib/nvd.js +1 -1
- package/lib/options-env.js +4 -5
- package/lib/osv-db.js +1 -1
- package/lib/osv.js +1 -1
- package/lib/outdated.js +1 -1
- package/lib/packagist-audit.js +5 -3
- package/lib/project-client.js +15 -4
- package/lib/provenance.js +1 -1
- package/lib/proxy-cache.js +14 -4
- package/lib/resource-cache/fs-store.js +1 -1
- package/lib/resource-cache/validate.js +3 -1
- package/lib/retire.js +17 -8
- package/lib/transitive.js +1 -1
- package/package.json +3 -3
- package/vigievuln.js +41 -29
|
@@ -17,7 +17,7 @@ const os = require("os");
|
|
|
17
17
|
let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
|
|
18
18
|
const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
19
19
|
|
|
20
|
-
const CACHE_DIR = path.join(
|
|
20
|
+
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
21
21
|
const CACHE_PATH = path.join(CACHE_DIR, "nuget-cache.json");
|
|
22
22
|
const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
|
|
23
23
|
|
|
@@ -111,7 +111,8 @@ async function fetchRegistration(name, { offline, version = null, registries = [
|
|
|
111
111
|
catch (e) { lastErr = e.message; statuses.push(null); continue; }
|
|
112
112
|
if (!regBase) { lastErr = "no registration base"; statuses.push(null); continue; }
|
|
113
113
|
try {
|
|
114
|
-
|
|
114
|
+
if (!/^[a-z0-9_.-]+$/i.test(id) || id === '.' || id === '..') throw new Error('invalid NuGet package name');
|
|
115
|
+
const url = `${regBase}${encodeURIComponent(id)}/index.json`;
|
|
115
116
|
const res = await require("../../providers").getResource("nuget", "registration", { name: id },
|
|
116
117
|
{ fetcher, headers, ...(url === `https://api.nuget.org/v3/registration5-gz-semver2/${id}/index.json`
|
|
117
118
|
? {} : { urlOverride: url, direct: true }) });
|
package/lib/codecs/pypi/parse.js
CHANGED
|
@@ -123,13 +123,20 @@ function parsePyprojectToml(filePath) {
|
|
|
123
123
|
// Walk a requirements.txt graph, following -r/--requirement (deps) and
|
|
124
124
|
// -c/--constraint (version pins) includes recursively. `kind` is "req" for the
|
|
125
125
|
// dependency graph and "constraint" for files reached via -c.
|
|
126
|
-
function collectReqGraph(filePath, seen, kind, acc) {
|
|
126
|
+
function collectReqGraph(filePath, seen, kind, acc, root) {
|
|
127
127
|
const real = path.resolve(filePath);
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
let resolved;
|
|
129
|
+
try { resolved = fs.realpathSync(real); }
|
|
130
|
+
catch { acc.missing.push(real); return; }
|
|
131
|
+
const relative = path.relative(root, resolved);
|
|
132
|
+
if (relative === '..' || relative.startsWith('..' + path.sep) || path.isAbsolute(relative)) {
|
|
133
|
+
acc.missing.push(`${real} (outside scan root; ignored)`); return;
|
|
134
|
+
}
|
|
135
|
+
if (seen.has(resolved)) return; // cycle / re-include guard
|
|
136
|
+
seen.add(resolved);
|
|
130
137
|
if (seen.size > 200) return; // sanity bound
|
|
131
138
|
let lines;
|
|
132
|
-
try { lines = fs.readFileSync(
|
|
139
|
+
try { lines = fs.readFileSync(resolved, "utf8").split(/\r?\n/); }
|
|
133
140
|
catch { acc.missing.push(real); return; }
|
|
134
141
|
const dir = path.dirname(real);
|
|
135
142
|
for (const raw of lines) {
|
|
@@ -141,9 +148,9 @@ function collectReqGraph(filePath, seen, kind, acc) {
|
|
|
141
148
|
line = line.replace(/\\$/, "").trim();
|
|
142
149
|
if (!line) continue;
|
|
143
150
|
const rMatch = line.match(/^(?:-r|--requirement)[=\s]+(.+)$/);
|
|
144
|
-
if (rMatch) { collectReqGraph(path.resolve(dir, rMatch[1].trim()), seen, kind, acc); continue; }
|
|
151
|
+
if (rMatch) { collectReqGraph(path.resolve(dir, rMatch[1].trim()), seen, kind, acc, root); continue; }
|
|
145
152
|
const cMatch = line.match(/^(?:-c|--constraint)[=\s]+(.+)$/);
|
|
146
|
-
if (cMatch) { collectReqGraph(path.resolve(dir, cMatch[1].trim()), seen, "constraint", acc); continue; }
|
|
153
|
+
if (cMatch) { collectReqGraph(path.resolve(dir, cMatch[1].trim()), seen, "constraint", acc, root); continue; }
|
|
147
154
|
if (line.startsWith("-")) continue; // -e ., --hash, other flags
|
|
148
155
|
// Per-requirement options ("pkg==1.0 --hash=sha256:…") come after the spec.
|
|
149
156
|
const { name, spec } = splitPep508(line.split(/\s+--/)[0].trim());
|
|
@@ -154,9 +161,9 @@ function collectReqGraph(filePath, seen, kind, acc) {
|
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
|
|
157
|
-
function parseRequirementsTxt(filePath) {
|
|
164
|
+
function parseRequirementsTxt(filePath, scanRoot = path.dirname(filePath)) {
|
|
158
165
|
const acc = { reqs: [], constraints: new Map(), missing: [] };
|
|
159
|
-
collectReqGraph(filePath, new Set(), "req", acc);
|
|
166
|
+
collectReqGraph(filePath, new Set(), "req", acc, fs.realpathSync(scanRoot));
|
|
160
167
|
const deps = [];
|
|
161
168
|
let skipped = 0;
|
|
162
169
|
const seen = new Set();
|
|
@@ -17,7 +17,7 @@ const os = require("os");
|
|
|
17
17
|
let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
|
|
18
18
|
const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
19
19
|
|
|
20
|
-
const CACHE_DIR = path.join(
|
|
20
|
+
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
21
21
|
const CACHE_PATH = path.join(CACHE_DIR, "pypi-cache.json");
|
|
22
22
|
const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
|
|
23
23
|
|
|
@@ -60,11 +60,12 @@ function pypiToFindings(data, { version }) {
|
|
|
60
60
|
// Custom registries first (same JSON API: <base>/<name>/json), then pypi.org.
|
|
61
61
|
async function fetchProject(name, { offline, registries = [], fetcher = globalThis.fetch } = {}) {
|
|
62
62
|
if (offline) return null;
|
|
63
|
+
if (typeof name !== 'string' || !/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/i.test(name)) return { error: 'invalid package name', absent: false };
|
|
63
64
|
const bases = withPublic("pypi", registries);
|
|
64
65
|
let lastErr = null;
|
|
65
66
|
const statuses = []; // one per base: HTTP status, or null for a non-answer
|
|
66
67
|
for (const base of bases) {
|
|
67
|
-
const url = normalise(base.url) + `${name}/json`;
|
|
68
|
+
const url = normalise(base.url) + `${encodeURIComponent(name)}/json`;
|
|
68
69
|
const headers = { "User-Agent": "vigievuln-pypi", Accept: "application/json" };
|
|
69
70
|
const ah = authHeaderFor(base); if (ah) headers.Authorization = ah;
|
|
70
71
|
try { const res = await require("../../providers").getResource("pypi", "package", { name },
|
package/lib/codecs/pypi.codec.js
CHANGED
|
@@ -105,7 +105,7 @@ module.exports = {
|
|
|
105
105
|
parsedManifests.push(fp);
|
|
106
106
|
const devFile = DEV_REQ_RE.test(rf);
|
|
107
107
|
try {
|
|
108
|
-
const r = P.parseRequirementsTxt(fp);
|
|
108
|
+
const r = P.parseRequirementsTxt(fp, dir);
|
|
109
109
|
for (const d of r.deps) add(devFile ? { ...d, isDev: true, scope: "dev" } : d, fp);
|
|
110
110
|
skipped += r.skipped;
|
|
111
111
|
sources.push(rf);
|
|
@@ -14,7 +14,7 @@ const os = require("os");
|
|
|
14
14
|
let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
|
|
15
15
|
const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
16
16
|
|
|
17
|
-
const CACHE_DIR = path.join(
|
|
17
|
+
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
18
18
|
const CACHE_PATH = path.join(CACHE_DIR, "rubygems-cache.json");
|
|
19
19
|
const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
|
|
20
20
|
|
package/lib/config.js
CHANGED
|
@@ -11,7 +11,7 @@ const fs = require("fs");
|
|
|
11
11
|
const path = require("path");
|
|
12
12
|
const os = require("os");
|
|
13
13
|
|
|
14
|
-
const CONFIG_DIR = path.join(
|
|
14
|
+
const CONFIG_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
15
15
|
const CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
|
|
16
16
|
|
|
17
17
|
function load() {
|
package/lib/cve-download.js
CHANGED
|
@@ -20,7 +20,7 @@ const execFileP = promisify(execFile);
|
|
|
20
20
|
|
|
21
21
|
const { compareMavenVersions, versionLikeBound } = require("./maven-version");
|
|
22
22
|
|
|
23
|
-
const CVE_DATA_DIR = path.join(
|
|
23
|
+
const CVE_DATA_DIR = path.join(require("./cache-directory").getCacheDir(), "cve-data");
|
|
24
24
|
const CVE_INDEX_PATH = path.join(CVE_DATA_DIR, "maven-cve-index.json");
|
|
25
25
|
const CVE_META_PATH = path.join(CVE_DATA_DIR, "meta.json");
|
|
26
26
|
const CVE_EXTRACT_DIR = path.join(CVE_DATA_DIR, "extracted");
|
package/lib/cve-report.js
CHANGED
|
@@ -1980,9 +1980,11 @@ function renderRetireTable(matches) {
|
|
|
1980
1980
|
const isRealIdentifier = id => /^(CVE-|GHSA-|RETIRE-)/i.test(String(id || ""));
|
|
1981
1981
|
const proseLabel = id => { const s = String(id || "?"); return s.length > 100 ? s.slice(0, 100) + "…" : s; };
|
|
1982
1982
|
const idLink = m => {
|
|
1983
|
-
const
|
|
1983
|
+
const candidate = m.cve.id?.startsWith("CVE-")
|
|
1984
1984
|
? `https://nvd.nist.gov/vuln/detail/${esc(m.cve.id)}`
|
|
1985
1985
|
: (m.cve.osvRefs?.[0]?.url || null);
|
|
1986
|
+
let href = null;
|
|
1987
|
+
try { if (candidate && ['https:', 'http:'].includes(new URL(candidate).protocol)) href = candidate; } catch { /* untrusted advisory URL */ }
|
|
1986
1988
|
const real = isRealIdentifier(m.cve.id);
|
|
1987
1989
|
const chop = real ? " no-chop" : "";
|
|
1988
1990
|
const label = esc(real ? m.cve.id : proseLabel(m.cve.id));
|
package/lib/epss.js
CHANGED
|
@@ -14,7 +14,7 @@ const fs = require("fs");
|
|
|
14
14
|
const path = require("path");
|
|
15
15
|
const os = require("os");
|
|
16
16
|
|
|
17
|
-
const CACHE_DIR = path.join(
|
|
17
|
+
const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
18
18
|
const CACHE_PATH = path.join(CACHE_DIR, "epss-cache.json");
|
|
19
19
|
const CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
20
20
|
const EPSS_BASE = "https://api.first.org/data/v1/epss";
|
package/lib/euvd.js
CHANGED
|
@@ -23,7 +23,7 @@ const fs = require("fs");
|
|
|
23
23
|
const path = require("path");
|
|
24
24
|
const os = require("os");
|
|
25
25
|
|
|
26
|
-
const DEFAULT_CACHE_DIR = path.join(
|
|
26
|
+
const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
27
27
|
const CACHE_FILE = "euvd-cache.json";
|
|
28
28
|
const CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
29
29
|
const MAX_PAGES = 200;
|
package/lib/hash-id.js
CHANGED
|
@@ -15,7 +15,7 @@ const fs = require("fs");
|
|
|
15
15
|
const path = require("path");
|
|
16
16
|
const os = require("os");
|
|
17
17
|
|
|
18
|
-
const CACHE_DIR = path.join(
|
|
18
|
+
const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
19
19
|
const CACHE_PATH = path.join(CACHE_DIR, "hash-id-cache.json");
|
|
20
20
|
const CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
21
21
|
const DEPSDEV = "https://api.deps.dev/v3/query";
|
package/lib/hosted-proxy.js
CHANGED
|
@@ -14,23 +14,25 @@ function resolveHostedProxy(options, env = process.env) {
|
|
|
14
14
|
return { proxyCache: ORIGINS[domain], proxyCacheToken: token || null, vigievulnProxy: domain };
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async function loginForProxy({
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const login = await
|
|
24
|
-
if (!login.ok) throw new Error(`VigieVuln login failed (HTTP ${login.status}); check your credentials and verified account`);
|
|
25
|
-
const session = (await login.json()).token;
|
|
26
|
-
if (typeof session !== 'string' || !session) throw new Error('invalid account login response');
|
|
17
|
+
async function loginForProxy({ email, password, fetcher = globalThis.fetch, ask, interactive, warn }) {
|
|
18
|
+
const {createAccountClient} = require('./account-client');
|
|
19
|
+
const {requireTerms} = require('./account-terms');
|
|
20
|
+
let session = null;
|
|
21
|
+
const store = {read:()=>session, write:value=>{session=value;}, clear:()=>{session=null;}};
|
|
22
|
+
const account = createAccountClient({fetcher, sessionStore:store});
|
|
23
|
+
const login = await account.login({email,password});
|
|
27
24
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
await requireTerms({account, terms:login.terms, ask, interactive, warn});
|
|
26
|
+
return await createProxyKey(account);
|
|
27
|
+
} finally { try { await account.logout(); } catch { /* session expires automatically */ } }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function createProxyKey(account) {
|
|
31
|
+
try { return (await account.createProxyKey()).token; }
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error.code === 'FORBIDDEN') throw new Error('proxy key creation forbidden; check your account and current terms with vigievuln login, then retry');
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
async function checkHostedProxy(url, token, fetcher = globalThis.fetch) {
|
|
@@ -46,4 +48,4 @@ async function checkHostedProxy(url, token, fetcher = globalThis.fetch) {
|
|
|
46
48
|
if (data.ok !== true || data.service !== "vigievuln-proxy") throw new Error("unexpected VigieVuln proxy response");
|
|
47
49
|
} finally { if (!response.bodyUsed) await response.body?.cancel(); }
|
|
48
50
|
}
|
|
49
|
-
module.exports = { ORIGINS, resolveHostedProxy, checkHostedProxy, loginForProxy };
|
|
51
|
+
module.exports = { ORIGINS, resolveHostedProxy, checkHostedProxy, loginForProxy, createProxyKey };
|
package/lib/kev.js
CHANGED
|
@@ -14,7 +14,7 @@ const fs = require("fs");
|
|
|
14
14
|
const path = require("path");
|
|
15
15
|
const os = require("os");
|
|
16
16
|
|
|
17
|
-
const CACHE_DIR = path.join(
|
|
17
|
+
const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
18
18
|
const CACHE_PATH = path.join(CACHE_DIR, "kev-cache.json");
|
|
19
19
|
const CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
20
20
|
const KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json";
|
|
@@ -89,7 +89,10 @@ async function enrichKev(matches, opts = {}) {
|
|
|
89
89
|
if (verbose) console.warn(` KEV fetch failed: ${err.message}`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
if (!index)
|
|
92
|
+
if (!index) {
|
|
93
|
+
if (!offline) throw new Error('CISA KEV catalog unavailable; exploitation status is unknown');
|
|
94
|
+
return matches;
|
|
95
|
+
}
|
|
93
96
|
|
|
94
97
|
for (const m of matches || []) {
|
|
95
98
|
const hit = index.byId[m.cve?.id];
|
package/lib/nvd.js
CHANGED
|
@@ -19,7 +19,7 @@ const path = require("path");
|
|
|
19
19
|
const os = require("os");
|
|
20
20
|
const { getNvdApiKey } = require("./config");
|
|
21
21
|
|
|
22
|
-
const NVD_CACHE_DIR = path.join(
|
|
22
|
+
const NVD_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "nvd-cache");
|
|
23
23
|
const NVD_CACHE_TTL_MS = 7 * 24 * 3600 * 1000;
|
|
24
24
|
// Bump whenever `extractFromNvdRecord` adds a new field — pre-bump cache
|
|
25
25
|
// entries are treated as cache-miss so we re-fetch and pick up the new field.
|
package/lib/options-env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/options-env.js — layered option resolution.
|
|
3
3
|
*
|
|
4
|
-
* Layers (highest → lowest): CLI flags > config file (--config
|
|
4
|
+
* Layers (highest → lowest): CLI flags > explicitly selected config file (--config,
|
|
5
5
|
* JSON) > FAD_CHECKER_ENV (a CLI-flag string) > global ~/.fad-checker/config.json
|
|
6
6
|
* > commander defaults. Scalar options follow precedence; `registries` are unioned
|
|
7
7
|
* elsewhere (lib/registries.js). The source flag has aliases (src/source).
|
|
@@ -69,10 +69,9 @@ function parseEnvFlags(str, program) {
|
|
|
69
69
|
/** Resolve { fileLayer, envLayer, envRepos }. */
|
|
70
70
|
function loadLayers({ cwd = process.cwd(), configPath = null, envStr = process.env.VIGIEVULN_ENV ?? process.env.FAD_CHECKER_ENV, program = null } = {}) {
|
|
71
71
|
let fileLayer = {};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (configPath) fileLayer = loadConfigFile(
|
|
75
|
-
else if (fs.existsSync(chosen)) fileLayer = loadConfigFile(chosen);
|
|
72
|
+
// The working directory may be the untrusted repository being audited.
|
|
73
|
+
// Only an explicitly selected configuration may affect the scan.
|
|
74
|
+
if (configPath) fileLayer = loadConfigFile(configPath);
|
|
76
75
|
fileLayer = normalizeSource(fileLayer || {});
|
|
77
76
|
let envLayer = {}, envRepos = [];
|
|
78
77
|
if (envStr && program) {
|
package/lib/osv-db.js
CHANGED
|
@@ -26,7 +26,7 @@ const { unzipSync } = require("fflate");
|
|
|
26
26
|
const { compareMavenVersions } = require("./maven-version");
|
|
27
27
|
const { vulnToMatch } = require("./osv");
|
|
28
28
|
|
|
29
|
-
const OSV_DB_DIR = path.join(
|
|
29
|
+
const OSV_DB_DIR = path.join(require("./cache-directory").getCacheDir(), "osv-db");
|
|
30
30
|
const BUCKET = "https://osv-vulnerabilities.storage.googleapis.com";
|
|
31
31
|
const TTL_MS = 24 * 3600 * 1000;
|
|
32
32
|
// OSV ecosystem export name per fad codec id. Maven only for now (version ordering).
|
package/lib/osv.js
CHANGED
|
@@ -20,7 +20,7 @@ const fs = require("fs");
|
|
|
20
20
|
const path = require("path");
|
|
21
21
|
const os = require("os");
|
|
22
22
|
|
|
23
|
-
const OSV_CACHE_DIR = path.join(
|
|
23
|
+
const OSV_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "osv-cache");
|
|
24
24
|
const OSV_CACHE_TTL_MS = 12 * 3600 * 1000;
|
|
25
25
|
const OSV_BASE = "https://api.osv.dev";
|
|
26
26
|
const BATCH_SIZE = 800; // OSV limit is 1000; stay under for safety
|
package/lib/outdated.js
CHANGED
|
@@ -27,7 +27,7 @@ for (const [id, fw] of Object.entries(COMPOSER_FRAMEWORKS)) {
|
|
|
27
27
|
for (const name of fw.components || []) COMPOSER_FRAMEWORK_OF.set(String(name).toLowerCase(), id);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const CACHE_DIR = path.join(
|
|
30
|
+
const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
31
31
|
const EOL_CACHE_PATH = path.join(CACHE_DIR, "eol-cache.json");
|
|
32
32
|
const VERSION_CACHE_PATH = path.join(CACHE_DIR, "version-cache.json");
|
|
33
33
|
const EOL_CACHE_MAX_AGE_MS = 7 * 24 * 3600 * 1000; // 7 days
|
package/lib/packagist-audit.js
CHANGED
|
@@ -27,7 +27,7 @@ const path = require("path");
|
|
|
27
27
|
const os = require("os");
|
|
28
28
|
|
|
29
29
|
const PACKAGIST_AUDIT_API = "https://packagist.org/api/security-advisories/";
|
|
30
|
-
const DEFAULT_CACHE_DIR = path.join(
|
|
30
|
+
const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "packagist-advisories");
|
|
31
31
|
const CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
32
32
|
const BATCH_SIZE = 100; // composer audit sends 100 packages per request; stay aligned
|
|
33
33
|
|
|
@@ -45,13 +45,15 @@ const STABILITY_ALIAS = { a: "alpha", alpha: "alpha", b: "beta", beta: "beta", r
|
|
|
45
45
|
// VersionParser's classical version + modifier regex (any number of numeric parts —
|
|
46
46
|
// Composer stops at 4, but a longer one was accepted before and is still ordered sanely),
|
|
47
47
|
// optional build metadata ignored like Composer does.
|
|
48
|
-
const VERSION_RE = /^v?(\d+(?:\.\d+)*)(?:[._-]?(stable|beta|b|rc|alpha|a|patch|pl|p)((?:[.-]
|
|
48
|
+
const VERSION_RE = /^v?(\d+(?:\.\d+)*)(?:[._-]?(stable|beta|b|rc|alpha|a|patch|pl|p)(\d*(?:[.-]\d+)*))?([.-]?dev)?(?:\+\S+)?$/i;
|
|
49
49
|
|
|
50
50
|
// "1.35.0" → { nums:[1,35,0], stab:"stable", stabNums:[], dev:false, hasStab:false };
|
|
51
51
|
// "v1.7.0-beta2" → stab "beta", stabNums [2]; "1.0.0-dev" → stab "dev". Unparsable
|
|
52
52
|
// (branch "dev-main", "1.0.x-dev", an unknown suffix "1.0.0-foo") → null.
|
|
53
53
|
function parseComposerVersion(value) {
|
|
54
|
-
const
|
|
54
|
+
const input = String(value ?? "").trim();
|
|
55
|
+
if (input.length > 256) return null;
|
|
56
|
+
const m = VERSION_RE.exec(input);
|
|
55
57
|
if (!m) return null;
|
|
56
58
|
const word = m[2] ? STABILITY_ALIAS[m[2].toLowerCase()] : null;
|
|
57
59
|
const dev = !!m[4];
|
package/lib/project-client.js
CHANGED
|
@@ -5,6 +5,12 @@ const COORD = /^[A-Za-z0-9@_][A-Za-z0-9@._+~/-]*$/;
|
|
|
5
5
|
const SIMPLE = /^[A-Za-z0-9._-]{1,100}$/;
|
|
6
6
|
// Allow room for server-normalized descriptors, while bounding memory use.
|
|
7
7
|
const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
8
|
+
const MAX_DESCRIPTOR_BYTES = 500000;
|
|
9
|
+
|
|
10
|
+
function checkDescriptorSize(descriptor) {
|
|
11
|
+
if (Buffer.byteLength(JSON.stringify(descriptor), 'utf8') > MAX_DESCRIPTOR_BYTES)
|
|
12
|
+
throw new Error(`project descriptor exceeds the upload limit of ${MAX_DESCRIPTOR_BYTES} UTF-8 bytes`);
|
|
13
|
+
}
|
|
8
14
|
|
|
9
15
|
class ProjectClientError extends Error {
|
|
10
16
|
constructor(code, message, status) {
|
|
@@ -41,7 +47,6 @@ function sanitizeDescriptor(input) {
|
|
|
41
47
|
version,versions:version ? [version] : [],scope:d.scope,isDev:!!d.isDev,relation:d.relation};
|
|
42
48
|
});
|
|
43
49
|
const out={schema:"fad-deps/2",generator:"vigievuln",deps};
|
|
44
|
-
if (Buffer.byteLength(JSON.stringify(out)) > 1900000) throw new Error("project descriptor exceeds the upload limit");
|
|
45
50
|
return out;
|
|
46
51
|
}
|
|
47
52
|
async function projectRequest(path, {session, method="GET", body, fetcher=globalThis.fetch, timeoutMs=15000} = {}) {
|
|
@@ -112,10 +117,16 @@ async function projectRequest(path, {session, method="GET", body, fetcher=global
|
|
|
112
117
|
}
|
|
113
118
|
async function createProject({session,name,descriptor,fetcher}) {
|
|
114
119
|
if (typeof name !== "string" || !name.trim() || name.length>120) throw new Error("a project name is required");
|
|
115
|
-
|
|
120
|
+
checkDescriptorSize(descriptor);
|
|
121
|
+
const sanitized = sanitizeDescriptor(descriptor);
|
|
122
|
+
checkDescriptorSize(sanitized);
|
|
123
|
+
return projectRequest("/v1/projects",{session,method:"POST",body:{name,descriptor:sanitized},fetcher});
|
|
116
124
|
}
|
|
117
125
|
async function updateProject({session,id,revision,descriptor,fetcher}) {
|
|
118
126
|
if (!UUID.test(id || "") || !Number.isSafeInteger(revision) || revision<1) throw new Error("project id and current revision are required");
|
|
119
|
-
|
|
127
|
+
checkDescriptorSize(descriptor);
|
|
128
|
+
const sanitized = sanitizeDescriptor(descriptor);
|
|
129
|
+
checkDescriptorSize(sanitized);
|
|
130
|
+
return projectRequest(`/v1/projects/${id}`,{session,method:"PUT",body:{revision,descriptor:sanitized},fetcher});
|
|
120
131
|
}
|
|
121
|
-
module.exports={sanitizeDescriptor,projectRequest,createProject,updateProject,ProjectClientError,MAX_RESPONSE_BYTES};
|
|
132
|
+
module.exports={sanitizeDescriptor,checkDescriptorSize,projectRequest,createProject,updateProject,ProjectClientError,MAX_RESPONSE_BYTES,MAX_DESCRIPTOR_BYTES};
|
package/lib/provenance.js
CHANGED
|
@@ -19,7 +19,7 @@ const fs = require("fs");
|
|
|
19
19
|
const path = require("path");
|
|
20
20
|
const os = require("os");
|
|
21
21
|
|
|
22
|
-
const DEFAULT_CACHE_DIR = path.join(
|
|
22
|
+
const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
|
|
23
23
|
|
|
24
24
|
function readJson(file) {
|
|
25
25
|
try { return JSON.parse(fs.readFileSync(file, "utf8")); } catch { return null; }
|
package/lib/proxy-cache.js
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* custom/private registry URLs use the direct path.
|
|
27
27
|
*
|
|
28
28
|
* Persistence is the point: the server may be restarted and entries outlive it. The
|
|
29
|
-
* store deliberately lives in its OWN root (~/.
|
|
30
|
-
* the client cache dir ~/.
|
|
29
|
+
* store deliberately lives in its OWN root (~/.vigie-vuln-proxy-cache/), NEVER inside
|
|
30
|
+
* the client cache dir ~/.vigie-vuln/ — the scan's per-pass caches and the shared
|
|
31
31
|
* server base are two different roles and must not be bundled, swapped or merged by
|
|
32
32
|
* --export-cache / --import-cache together.
|
|
33
33
|
*
|
|
@@ -49,7 +49,7 @@ const {
|
|
|
49
49
|
const DEFAULT_PORT = 8321;
|
|
50
50
|
const DEFAULT_HOST = "127.0.0.1";
|
|
51
51
|
/** The scan's own per-pass cache root — the proxy store must never live inside it. */
|
|
52
|
-
const CLIENT_CACHE_DIR = () => path.join(
|
|
52
|
+
const CLIENT_CACHE_DIR = () => path.join(require("./cache-directory").getCacheDir());
|
|
53
53
|
|
|
54
54
|
// -------------------------------------------------------------- server ----
|
|
55
55
|
|
|
@@ -101,6 +101,15 @@ function createProxyCacheServer(opts = {}) {
|
|
|
101
101
|
|
|
102
102
|
async function handle(req, res) {
|
|
103
103
|
stats.requests++;
|
|
104
|
+
// CLI clients do not send an Origin; reject browser requests before any
|
|
105
|
+
// control or resource endpoint can be used for CSRF or DNS rebinding.
|
|
106
|
+
if (req.headers.origin || req.headers['sec-fetch-site']) return sendJson(res, 403, { error: 'browser requests are not supported' });
|
|
107
|
+
const address = server.address();
|
|
108
|
+
if (address && typeof address !== 'string' && ['127.0.0.1', '::1'].includes(address.address)) {
|
|
109
|
+
let hostname;
|
|
110
|
+
try { hostname = new URL(`http://${req.headers.host}`).hostname.toLowerCase(); } catch { return sendJson(res, 400, { error: 'invalid host' }); }
|
|
111
|
+
if (!['127.0.0.1', '[::1]', 'localhost'].includes(hostname)) return sendJson(res, 403, { error: 'invalid host' });
|
|
112
|
+
}
|
|
104
113
|
const target = req.url.replace(/^\/+/, "");
|
|
105
114
|
if (target === "__health") return sendJson(res, 200, { ok: true, uptimeMs: Date.now() - stats.startedAt });
|
|
106
115
|
if (!authorized(req)) return sendJson(res, 401, { error: "unauthorized", "x-fad-proxy": "unauthorized" });
|
|
@@ -126,7 +135,7 @@ function createProxyCacheServer(opts = {}) {
|
|
|
126
135
|
const server = http.createServer((req, res) => {
|
|
127
136
|
handle(req, res).catch(err => {
|
|
128
137
|
stats.errors++;
|
|
129
|
-
if (!res.headersSent) sendJson(res, 502, { error:
|
|
138
|
+
if (!res.headersSent) sendJson(res, 502, { error: "upstream request failed" }, { "x-fad-proxy": "error" });
|
|
130
139
|
else res.destroy();
|
|
131
140
|
});
|
|
132
141
|
});
|
|
@@ -146,6 +155,7 @@ function createProxyCacheServer(opts = {}) {
|
|
|
146
155
|
/** Convenience: create + listen. Resolves { server, url, port } once the socket is open. */
|
|
147
156
|
function startProxyCacheServer(opts = {}) {
|
|
148
157
|
const { port = DEFAULT_PORT, host = DEFAULT_HOST } = opts;
|
|
158
|
+
if (!['127.0.0.1', '::1', 'localhost'].includes(host) && !opts.token) throw new Error('a token is required when serve-cache is exposed beyond localhost');
|
|
149
159
|
const server = createProxyCacheServer(opts);
|
|
150
160
|
return new Promise((resolve, reject) => {
|
|
151
161
|
server.once("error", reject);
|
|
@@ -27,7 +27,7 @@ const path = require("path");
|
|
|
27
27
|
const os = require("os");
|
|
28
28
|
const crypto = require("crypto");
|
|
29
29
|
|
|
30
|
-
const DEFAULT_CACHE_DIR = () =>
|
|
30
|
+
const DEFAULT_CACHE_DIR = () => require('../cache-directory').getProxyCacheDir();
|
|
31
31
|
const TRANSIENT_KEEP_MS = 30 * 1000;
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -51,7 +51,9 @@ const T = {
|
|
|
51
51
|
|
|
52
52
|
const CVE = T.str(/^CVE-\d{4}-\d{4,7}$/i, 20);
|
|
53
53
|
const NAME = T.str(/^[A-Za-z0-9@][A-Za-z0-9._~\/@+-]*$/, 214);
|
|
54
|
-
|
|
54
|
+
// Separators are mandatory between runs: the old optional separator nested
|
|
55
|
+
// inside a repetition allowed exponentially many partitions of a long name.
|
|
56
|
+
const COMPOSER = T.str(/^[a-z0-9]+(?:[_.-][a-z0-9]+)*\/[a-z0-9]+(?:(?:[_.]|-{1,2})[a-z0-9]+)*$/i, 200);
|
|
55
57
|
const OSV_ECOS = ["Maven", "npm", "PyPI", "Packagist", "NuGet", "Go", "RubyGems", "crates.io", "Hex", "Pub", "CRAN", "Hackage", "SwiftURL", "GitHub Actions"];
|
|
56
58
|
const OSV_NAME = T.str(/^[\x21-\x7e]+$/, 300), OSV_VERSION = T.str(/^[\x21-\x7e]+$/, 100);
|
|
57
59
|
const OSV_PAGE_TOKEN = T.str(/^[\x21-\x7e]+$/, 2048);
|
package/lib/retire.js
CHANGED
|
@@ -25,7 +25,7 @@ const { execFile } = require("child_process");
|
|
|
25
25
|
const { promisify } = require("util");
|
|
26
26
|
const execFileP = promisify(execFile);
|
|
27
27
|
|
|
28
|
-
const RETIRE_CACHE_DIR = path.join(
|
|
28
|
+
const RETIRE_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "retire-cache");
|
|
29
29
|
const RETIRE_CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
30
30
|
|
|
31
31
|
// retire's own signature DB. By default retire caches it in /tmp/.retire-cache
|
|
@@ -33,7 +33,7 @@ const RETIRE_CACHE_TTL_MS = 24 * 3600 * 1000;
|
|
|
33
33
|
// air-gapped offline workflow we instead keep a stable local copy INSIDE ~/.fad-checker/
|
|
34
34
|
// so `--export-cache` carries it, and feed it to retire via `--jsrepo <file>`
|
|
35
35
|
// (loaded from file, never the network — no TTL).
|
|
36
|
-
const RETIRE_SIG_DIR = path.join(
|
|
36
|
+
const RETIRE_SIG_DIR = path.join(require("./cache-directory").getCacheDir(), "retire-signatures");
|
|
37
37
|
const RETIRE_SIG_FILE = path.join(RETIRE_SIG_DIR, "jsrepository-v5.json");
|
|
38
38
|
const RETIRE_REPO_URL = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-v5.json";
|
|
39
39
|
|
|
@@ -110,6 +110,12 @@ function chooseRetireLauncher({ localBin, isBun, execPath }) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function findRetireLauncher() {
|
|
113
|
+
// npm installs a .cmd shim on Windows; execFile cannot run it without a shell.
|
|
114
|
+
// Invoke the package's JS entry with the current Node executable instead.
|
|
115
|
+
if (process.platform === 'win32' && !(process.versions && process.versions.bun)) {
|
|
116
|
+
const script = path.join(__dirname, '..', 'node_modules', 'retire', 'lib', 'cli.js');
|
|
117
|
+
if (fs.existsSync(script)) return {cmd:process.execPath, env:null, args:[script]};
|
|
118
|
+
}
|
|
113
119
|
const local = path.join(__dirname, "..", "node_modules", ".bin", "retire");
|
|
114
120
|
return chooseRetireLauncher({
|
|
115
121
|
localBin: fs.existsSync(local) ? local : null,
|
|
@@ -319,6 +325,8 @@ async function runRetire(srcDir, opts = {}) {
|
|
|
319
325
|
const diag = opts.diag || {};
|
|
320
326
|
// No source tree (e.g. --import-anonymized) → nothing to scan for vendored JS.
|
|
321
327
|
if (!srcDir) { if (verbose) console.warn("retire: no source dir — skipped"); return null; }
|
|
328
|
+
try { if (!fs.statSync(srcDir).isDirectory()) throw new Error('not a directory'); }
|
|
329
|
+
catch { diag.error = 'retire.js scan failed: source directory is unavailable'; return null; }
|
|
322
330
|
const hostedOnline = !offline && require("./providers").hasHostedProxy();
|
|
323
331
|
// A result's scan time cannot prove that the signatures it used are still current.
|
|
324
332
|
if (!force && !hostedOnline) {
|
|
@@ -346,7 +354,8 @@ async function runRetire(srcDir, opts = {}) {
|
|
|
346
354
|
|
|
347
355
|
// retire.js refuses to write to /dev/stdout, so we use a real temp file
|
|
348
356
|
// and read it back. Falls back to stdout if --outputpath is rejected.
|
|
349
|
-
const
|
|
357
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vigievuln-retire-'));
|
|
358
|
+
const tmpOut = path.join(tmpDir, 'output.json');
|
|
350
359
|
|
|
351
360
|
// Pruning policy, written to a temp ignorefile so retire honors it for the tree
|
|
352
361
|
// it ACTUALLY walks (anchored to srcDir, not retire's cwd — the nested
|
|
@@ -354,11 +363,11 @@ async function runRetire(srcDir, opts = {}) {
|
|
|
354
363
|
const ignorePatterns = buildRetireIgnorePatterns({ srcDir, excludePath, defaultExcludes });
|
|
355
364
|
// retire treats a `.json` ignorefile as the structured descriptor form; keep a
|
|
356
365
|
// plain-text extension so the `@`-prefixed regex lines are read as such.
|
|
357
|
-
const tmpIgnore = ignorePatterns.length ? path.join(
|
|
358
|
-
if (tmpIgnore) fs.writeFileSync(tmpIgnore, ignorePatterns.join("\n") + "\n");
|
|
366
|
+
const tmpIgnore = ignorePatterns.length ? path.join(tmpDir, 'ignore.txt') : null;
|
|
367
|
+
try { if (tmpIgnore) fs.writeFileSync(tmpIgnore, ignorePatterns.join("\n") + "\n", { mode: 0o600, flag: 'wx' }); }
|
|
368
|
+
catch (error) { fs.rmSync(tmpDir, { recursive: true, force: true }); throw error; }
|
|
359
369
|
const cleanup = () => {
|
|
360
|
-
try { fs.
|
|
361
|
-
if (tmpIgnore) { try { fs.unlinkSync(tmpIgnore); } catch { /* best effort */ } }
|
|
370
|
+
try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
362
371
|
};
|
|
363
372
|
|
|
364
373
|
const args = buildRetireArgs({ srcDir, outPath: tmpOut, ignoreFile: tmpIgnore, jsRepo: haveSig ? RETIRE_SIG_FILE : null });
|
|
@@ -369,7 +378,7 @@ async function runRetire(srcDir, opts = {}) {
|
|
|
369
378
|
// retire.js exits with code 13 when it finds vulnerabilities — that's
|
|
370
379
|
// expected. Catch and ignore the non-zero exit; the JSON file is still
|
|
371
380
|
// produced.
|
|
372
|
-
await execFileP(launcher.cmd, args, {
|
|
381
|
+
await execFileP(launcher.cmd, [...(launcher.args || []), ...args], {
|
|
373
382
|
maxBuffer: 1024 * 1024 * 64,
|
|
374
383
|
env: launcher.env ? { ...process.env, ...launcher.env } : process.env,
|
|
375
384
|
});
|
package/lib/transitive.js
CHANGED
|
@@ -28,7 +28,7 @@ const os = require("os");
|
|
|
28
28
|
const { parseStringPromise } = require("xml2js");
|
|
29
29
|
const { normalizeHardPin, isVersionRange, resolveVersionRange, compareMavenVersions } = require("./maven-version");
|
|
30
30
|
|
|
31
|
-
const POM_CACHE_DIR = path.join(
|
|
31
|
+
const POM_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "poms-cache");
|
|
32
32
|
const MAVEN_CENTRAL = "https://repo1.maven.org/maven2";
|
|
33
33
|
|
|
34
34
|
// Maven's scope-propagation matrix (rows: direct dep scope, cols: transitive scope)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vigievuln",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "One-shot polyglot dependency auditor (10 ecosystems + 9 CMS/Frameworks). No build tools. Real & complete air-gapped mode. Private deps, binaries, certs, EOL, CVE (KEV+EPSS) - Made for professional code audits.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sca",
|
|
@@ -95,13 +95,13 @@
|
|
|
95
95
|
"js-yaml": "^4.3.2",
|
|
96
96
|
"minimatch": "^10.2.6",
|
|
97
97
|
"p-limit": "^3.1.0",
|
|
98
|
-
"retire": "^
|
|
98
|
+
"retire": "^6.1.0",
|
|
99
99
|
"rimraf": "^6.1.3",
|
|
100
100
|
"smol-toml": "^1.8.0",
|
|
101
101
|
"xml2js": "^0.6.2"
|
|
102
102
|
},
|
|
103
103
|
"engines": {
|
|
104
|
-
"node": ">=
|
|
104
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
105
105
|
},
|
|
106
106
|
"files": [
|
|
107
107
|
"vigievuln.js",
|