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
package/lib/cli-setup.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Interactive setup is additive: the old config and cache remain usable until
|
|
4
|
+
// the selected sign-in and optional cache import have succeeded.
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const os = require('node:os');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { Readable, Transform } = require('node:stream');
|
|
9
|
+
const { pipeline } = require('node:stream/promises');
|
|
10
|
+
const zlib = require('node:zlib');
|
|
11
|
+
const { ACCOUNT_ORIGIN, createAccountClient } = require('./account-client');
|
|
12
|
+
const { createAccountSessionStore } = require('./account-session');
|
|
13
|
+
const { ensureSignedIn } = require('./cli-project-commands');
|
|
14
|
+
const { importCache } = require('./cache-archive-sqlite');
|
|
15
|
+
const { ORIGINS } = require('./hosted-proxy');
|
|
16
|
+
const { proxyOrigin, HTTP_WARNING } = require('./proxy-scope');
|
|
17
|
+
|
|
18
|
+
const MAX_SEED_BYTES = 4 * 1024 * 1024 * 1024;
|
|
19
|
+
const HELP = `Usage: vigievuln setup\n vigievuln setup --mode <direct|official|server> [--sources <all|us|eu>] [--server-url <url>] [--seed] [--seed-url <url>] [--accept-terms <version>] [--allow-insecure-http]\nWithout flags, use the interactive setup. With flags, no prompt is displayed.\nAuthenticated modes use an existing session or VIGIEVULN_EMAIL and VIGIEVULN_PASSWORD.\nReview the server terms before explicitly accepting their exact version. HTTP requires confirmation, or --allow-insecure-http without a terminal.\n`;
|
|
20
|
+
|
|
21
|
+
async function prompt(label, secret = false) {
|
|
22
|
+
if (!process.stdin.isTTY || !process.stderr.isTTY) throw new Error('setup requires an interactive terminal');
|
|
23
|
+
const { Input, Password } = require('enquirer');
|
|
24
|
+
const Prompt = secret ? Password : Input;
|
|
25
|
+
try { return await new Prompt({message:label.replace(/:\s*$/, ''), stdin:process.stdin, stdout:process.stderr}).run(); }
|
|
26
|
+
catch (error) { if (!error || typeof error === 'string') throw new Error('Setup cancelled.'); throw error; }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function seedEndpoint(origin) {
|
|
30
|
+
const canonical = proxyOrigin(origin);
|
|
31
|
+
return (canonical === ORIGINS.fr || canonical === ORIGINS.com ? ACCOUNT_ORIGIN : canonical) + '/dumps/vigievuln-cli-cache.tar.gz';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Inspect only a small prefix. The manifest precedes the SQLite data in server
|
|
35
|
+
// bundles; unfamiliar layouts simply leave the database size unknown.
|
|
36
|
+
function sqliteBytesFromPrefix(bytes) {
|
|
37
|
+
try {
|
|
38
|
+
const tar = zlib.gunzipSync(bytes, {finishFlush:zlib.constants.Z_SYNC_FLUSH, maxOutputLength:1024*1024});
|
|
39
|
+
for (let offset=0; offset+512<=tar.length;) {
|
|
40
|
+
const h=tar.subarray(offset,offset+512), name=h.subarray(0,100).toString('utf8').split('\0')[0];
|
|
41
|
+
const sizeText=h.subarray(124,136).toString('ascii').split('\0')[0].trim();
|
|
42
|
+
if (!/^[0-7]+$/.test(sizeText)) return null;
|
|
43
|
+
const size=parseInt(sizeText,8), start=offset+512;
|
|
44
|
+
if (!Number.isSafeInteger(size) || size<0) return null;
|
|
45
|
+
if (name === '.vigie-vuln/cli-bundle-meta.json') {
|
|
46
|
+
if (size>65536 || start+size>tar.length) return null;
|
|
47
|
+
const m=JSON.parse(tar.subarray(start,start+size).toString('utf8'));
|
|
48
|
+
return m.format==='vigievuln-sqlite-cache' && m.payload?.file==='cache.sqlite' && Number.isSafeInteger(m.payload.bytes) && m.payload.bytes>0 ? m.payload.bytes : null;
|
|
49
|
+
}
|
|
50
|
+
offset=start+Math.ceil(size/512)*512;
|
|
51
|
+
}
|
|
52
|
+
} catch { /* optional preview; the full import still validates the archive */ }
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function estimateSeed({origin,token,anonymous=false,fetcher=globalThis.fetch}) {
|
|
57
|
+
const endpoint=seedEndpoint(origin),headers={...(token?{authorization:`Bearer ${token}`}:{ }),'x-vigievuln-client-version':require('../package.json').version};
|
|
58
|
+
const result={downloadBytes:null,sqliteBytes:null};
|
|
59
|
+
const request=extra=>({redirect:'error',credentials:'omit',cache:'no-store',signal:AbortSignal.timeout(10000),...extra,headers:{...headers,...extra.headers}});
|
|
60
|
+
const valid=r=>r && r.ok && !r.redirected && (!r.url || r.url===endpoint);
|
|
61
|
+
try {
|
|
62
|
+
const head=await fetcher(endpoint,request({method:'HEAD'}));
|
|
63
|
+
if (valid(head)) {const value=head.headers.get('content-length');if (/^\d+$/.test(value||'') && Number.isSafeInteger(Number(value))) result.downloadBytes=Number(value);}
|
|
64
|
+
if (head?.body && !head.body.locked) await head.body.cancel().catch(()=>{});
|
|
65
|
+
} catch { /* estimate is optional */ }
|
|
66
|
+
try {
|
|
67
|
+
const part=await fetcher(endpoint,request({method:'GET',headers:{range:'bytes=0-16383'}}));
|
|
68
|
+
const range=/^bytes 0-(\d+)\/(\d+)$/.exec(part.headers.get('content-range')||'');
|
|
69
|
+
if (valid(part) && part.status===206 && range && Number(range[1])<16384 && Number.isSafeInteger(Number(range[2]))) {
|
|
70
|
+
if (result.downloadBytes===null || result.downloadBytes===Number(range[2])) {
|
|
71
|
+
result.downloadBytes=Number(range[2]);
|
|
72
|
+
const reader=part.body?.getReader();let chunks=[],length=0;
|
|
73
|
+
if (reader) try { for (;;) {const {done,value}=await reader.read();if(done)break;length+=value.byteLength;if(length>16384)break;chunks.push(Buffer.from(value));} } finally {await reader.cancel().catch(()=>{});reader.releaseLock();}
|
|
74
|
+
if (length<=16384) result.sqliteBytes=sqliteBytesFromPrefix(Buffer.concat(chunks));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (part.body && !part.body.locked) await part.body.cancel().catch(()=>{});
|
|
78
|
+
} catch { /* range requests may be disabled */ }
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function downloadSeed({ origin, token, anonymous = false, targetDir, fetcher = globalThis.fetch, importFn = importCache, onProgress, requireUsableSeed = false, onEstimate, confirm }) {
|
|
83
|
+
if (!token && !anonymous) throw new Error('Sign in before importing a proxy cache.');
|
|
84
|
+
// Official API hosts only expose proxy endpoints; the bundle is served by
|
|
85
|
+
// the canonical website. Select the host explicitly, never by redirecting a
|
|
86
|
+
// request carrying the account key. Custom instances use their own origin.
|
|
87
|
+
const endpoint = seedEndpoint(origin);
|
|
88
|
+
if (onEstimate || confirm) {
|
|
89
|
+
onProgress?.({phase:'estimating'});
|
|
90
|
+
const estimate=await estimateSeed({origin,token,anonymous,fetcher});
|
|
91
|
+
onEstimate?.(estimate);
|
|
92
|
+
if (confirm && !await confirm(estimate)) return {cancelled:true};
|
|
93
|
+
}
|
|
94
|
+
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'vigievuln-setup-'));
|
|
95
|
+
const file = path.join(dir, 'seed.tar.gz');
|
|
96
|
+
let response;
|
|
97
|
+
try {
|
|
98
|
+
onProgress?.({phase:'connecting'});
|
|
99
|
+
response = await fetcher(endpoint, { redirect:'error', credentials:'omit', cache:'no-store',
|
|
100
|
+
headers:{...(token ? {authorization:`Bearer ${token}`} : {}), 'x-vigievuln-client-version':require('../package.json').version}, signal:AbortSignal.timeout(600000) });
|
|
101
|
+
if (response.redirected || (response.url && response.url !== endpoint)) throw new Error('Proxy cache redirects are not permitted.');
|
|
102
|
+
if (!response.ok || !response.body) throw new Error(`Proxy cache download failed (HTTP ${response.status}).`);
|
|
103
|
+
if (!/^application\/(?:gzip|octet-stream)(?:\s*;|$)/i.test(response.headers.get('content-type') || ''))
|
|
104
|
+
throw new Error('Proxy returned an unexpected cache content type.');
|
|
105
|
+
const length = Number(response.headers.get('content-length'));
|
|
106
|
+
if (Number.isFinite(length) && length > MAX_SEED_BYTES) throw new Error('Proxy cache exceeds the size limit.');
|
|
107
|
+
let bytes = 0;
|
|
108
|
+
onProgress?.({phase:'downloading',bytes,total:Number.isFinite(length) && length > 0 ? length : null});
|
|
109
|
+
const limit = new Transform({ transform(chunk, enc, cb) { bytes += chunk.length; onProgress?.({phase:'downloading',bytes,total:Number.isFinite(length) && length > 0 ? length : null}); cb(bytes > MAX_SEED_BYTES ? new Error('Proxy cache exceeds the size limit.') : null, chunk); } });
|
|
110
|
+
await pipeline(Readable.fromWeb(response.body), limit, fs.createWriteStream(file, {mode:0o600, flags:'wx'}));
|
|
111
|
+
onProgress?.({phase:'downloaded',bytes});
|
|
112
|
+
return await importFn(file, {replace:false, force:false, ...(targetDir ? {targetDir} : {}), ...(onProgress ? {onProgress} : {}), ...(requireUsableSeed ? {requireUsableSeed:true} : {})});
|
|
113
|
+
} finally {
|
|
114
|
+
if (response?.body && !response.body.locked) void response.body.cancel().catch(()=>{});
|
|
115
|
+
await fs.promises.rm(dir, {recursive:true, force:true});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Unknown, malformed or unreachable endpoints retain the historical authenticated
|
|
120
|
+
// behaviour. Never infer that authentication is disabled from a failed request.
|
|
121
|
+
async function authenticationRequired(origin, fetcher = globalThis.fetch) {
|
|
122
|
+
const endpoint=proxyOrigin(origin)+'/v1/proxy/capabilities';let response,reader;
|
|
123
|
+
try {
|
|
124
|
+
response=await fetcher(endpoint,{redirect:'error',credentials:'omit',cache:'no-store',signal:AbortSignal.timeout(5000)});
|
|
125
|
+
if (!response.ok || response.redirected || (response.url && response.url !== endpoint) || !/^application\/json(?:\s*;|$)/i.test(response.headers.get('content-type') || '') || !response.body) return true;
|
|
126
|
+
reader=response.body.getReader();const chunks=[];let length=0;
|
|
127
|
+
for (;;) { const {done,value}=await reader.read();if(done)break;length+=value.byteLength;if(length>8192)return true;chunks.push(Buffer.from(value)); }
|
|
128
|
+
const data=JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
129
|
+
return !(data?.service==='vigievuln-proxy' && data.schema===1 && data.authenticationRequired===false);
|
|
130
|
+
} catch { return true; }
|
|
131
|
+
finally { if (reader) { try { await reader.cancel(); } catch {} reader.releaseLock(); } else if (response?.body && !response.body.locked) void response.body.cancel().catch(()=>{}); }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function select(message, choices) {
|
|
135
|
+
const { Select } = require('enquirer');
|
|
136
|
+
try { return await new Select({ message, choices, initial: 0, stdin:process.stdin, stdout:process.stderr }).run(); }
|
|
137
|
+
catch (error) { if (!error || typeof error === 'string') throw new Error('Setup cancelled.'); throw error; }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function parseOptions(args) {
|
|
141
|
+
const opts = {};
|
|
142
|
+
for (let i=0;i<args.length;i++) {
|
|
143
|
+
const flag=args[i];
|
|
144
|
+
if (flag === '--allow-insecure-http') { if (opts.allowInsecureHttp) throw Error('duplicate --allow-insecure-http'); opts.allowInsecureHttp=true; continue; }
|
|
145
|
+
if (flag === '--seed') { if (opts.seed) throw Error('duplicate --seed'); opts.seed=true; continue; }
|
|
146
|
+
const key={'--mode':'mode','--sources':'sources','--server-url':'serverUrl','--seed-url':'seedUrl','--accept-terms':'acceptTerms'}[flag];
|
|
147
|
+
if (!key || opts[key] || !args[i+1] || args[i+1].startsWith('--')) throw Error(`invalid setup option ${flag}`);
|
|
148
|
+
opts[key]=args[++i];
|
|
149
|
+
}
|
|
150
|
+
if (!['direct','official','server'].includes(opts.mode)) throw Error('--mode must be direct, official or server');
|
|
151
|
+
if (opts.sources && (opts.mode !== 'direct' || !['all','us','eu'].includes(opts.sources))) throw Error('--sources requires direct mode and must be all, us or eu');
|
|
152
|
+
if ((opts.mode === 'server') !== !!opts.serverUrl) throw Error('--server-url is required only for server mode');
|
|
153
|
+
if (opts.seedUrl && (!opts.seed || opts.mode !== 'direct')) throw Error('--seed-url requires --seed and direct mode');
|
|
154
|
+
if (opts.acceptTerms && opts.mode === 'direct' && !opts.seed) throw Error('--accept-terms requires an authenticated mode or --seed');
|
|
155
|
+
if (opts.serverUrl) opts.serverUrl=proxyOrigin(opts.serverUrl);
|
|
156
|
+
if (opts.seedUrl) opts.seedUrl=proxyOrigin(opts.seedUrl);
|
|
157
|
+
return opts;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function run(args = [], deps = {}) {
|
|
161
|
+
if (args.length && args.every(a => a === '--help' || a === '-h')) { (deps.out || console.log)(HELP); return; }
|
|
162
|
+
const options = args.length ? parseOptions(args) : null;
|
|
163
|
+
const interactive = deps.interactive ?? !!(process.stdin.isTTY && process.stderr.isTTY);
|
|
164
|
+
if (!options && !interactive) throw new Error('setup requires an interactive terminal or explicit --mode');
|
|
165
|
+
const ask = deps.ask || prompt, choose = deps.select || select, out = deps.out || console.log, warn = deps.warn || console.error;
|
|
166
|
+
let lastProgressAt = 0, lastPhase = '';
|
|
167
|
+
const formatBytes = n => `${(n / 1024 / 1024).toFixed(1)} MiB`;
|
|
168
|
+
const reportSeedProgress = event => {
|
|
169
|
+
const now = Date.now(), changed = event.phase !== lastPhase;
|
|
170
|
+
if (!changed && (!interactive || now - lastProgressAt < 3000)) return;
|
|
171
|
+
lastPhase = event.phase; lastProgressAt = now;
|
|
172
|
+
const count = Number.isSafeInteger(event.count) ? ` (${event.count}${Number.isSafeInteger(event.total) ? `/${event.total}` : ''})` : '';
|
|
173
|
+
const message = {
|
|
174
|
+
estimating:'Checking bundle size…',
|
|
175
|
+
connecting:'Connecting to the bundle server…',
|
|
176
|
+
downloading:`Downloading bundle: ${formatBytes(event.bytes || 0)}${event.total ? ` / ${formatBytes(event.total)}` : ''}`,
|
|
177
|
+
downloaded:`Download complete: ${formatBytes(event.bytes || 0)}.`,
|
|
178
|
+
extracting:'Extracting bundle…', validating:`Validating bundle${count}…`,
|
|
179
|
+
checking:'Checking SQLite database integrity…',
|
|
180
|
+
'index-osv':`Importing and indexing OSV advisories${count}…`,
|
|
181
|
+
'index-cve':`Importing and indexing CVEProject advisories${count}…`,
|
|
182
|
+
'index-build':'Building the advisory index; this may take several minutes…',
|
|
183
|
+
'index-gcve':'Importing and indexing GCVE advisories…',
|
|
184
|
+
merging:'Merging the bundle into the local cache; this may take several minutes…',
|
|
185
|
+
}[event.phase];
|
|
186
|
+
if (message) warn(message);
|
|
187
|
+
};
|
|
188
|
+
const getSeed = deps.downloadSeed || (args => downloadSeed({...args,...(deps.fetcher ? {fetcher:deps.fetcher} : {}),onProgress:reportSeedProgress,requireUsableSeed:true,
|
|
189
|
+
onEstimate:({downloadBytes,sqliteBytes})=>{
|
|
190
|
+
const gb=n=>`${(n/1e9).toFixed(2)} GB`;
|
|
191
|
+
warn(`Bundle download: ${downloadBytes===null?'unknown size':gb(downloadBytes)} (compressed).`);
|
|
192
|
+
if (sqliteBytes!==null) warn(`SQLite data: ${gb(sqliteBytes)}. Allow roughly ${gb(sqliteBytes*2)} free for extraction and merge, plus the existing cache; the downloaded archive uses temporary space separately. SQLite journals may require more.`);
|
|
193
|
+
else warn('Disk usage is unknown; extraction and merging require additional space beyond the downloaded archive and existing cache.');
|
|
194
|
+
},
|
|
195
|
+
...(!options && interactive ? {confirm:async()=>await choose('Continue with bundle download?', [{name:'no',message:'No — skip the bundle'},{name:'yes',message:'Yes — download and import'}])==='yes'} : {})}));
|
|
196
|
+
const cfg = deps.config || require('./config');
|
|
197
|
+
const original = cfg.load();
|
|
198
|
+
(deps.banner || (() => require('./ui').banner(require('../package.json').version)))();
|
|
199
|
+
const mode = options ? (options.mode === 'server' ? 'custom' : options.mode) : await choose('How should VigieVuln obtain vulnerability data?', [
|
|
200
|
+
{name:'direct', message:'Autonomous — query sources directly'},
|
|
201
|
+
{name:'official', message:'VigieVuln database — official service'},
|
|
202
|
+
{name:'custom', message:'Local VigieVuln server — enter its URL'},
|
|
203
|
+
]);
|
|
204
|
+
let profile = 'proxy', proxy = null;
|
|
205
|
+
if (mode === 'direct') {
|
|
206
|
+
profile = options ? (options.sources || 'all') : await choose('Which services should be used? (region of the service operator)', [
|
|
207
|
+
{name:'all', message:'All sources (default)'},
|
|
208
|
+
{name:'us', message:'US services only'},
|
|
209
|
+
{name:'eu', message:'European services only'},
|
|
210
|
+
]);
|
|
211
|
+
if (profile === 'us' || profile === 'eu') warn('Regional source selection limits advisory coverage and disables CMS plugins and native-binary identification.');
|
|
212
|
+
} else if (mode === 'official') proxy = ORIGINS.fr;
|
|
213
|
+
else if (mode === 'custom') proxy = options ? options.serverUrl : proxyOrigin(String(await ask('VigieVuln server URL (include http:// or https://): ')).trim());
|
|
214
|
+
else throw new Error('Invalid setup mode.');
|
|
215
|
+
const seed = options ? !!options.seed : await choose('Initialise the local cache from a server bundle?', [
|
|
216
|
+
{name:'no', message:'No (default)'}, {name:'yes', message:'Yes — sign in and download the bundle'},
|
|
217
|
+
]) === 'yes';
|
|
218
|
+
let seedOrigin = proxy;
|
|
219
|
+
if (seed && !proxy) {
|
|
220
|
+
const source = options ? (options.seedUrl ? 'custom' : 'official') : await choose('Which server supplies the bundle?', [
|
|
221
|
+
{name:'official', message:'Official VigieVuln site (default)'},
|
|
222
|
+
{name:'custom', message:'Another VigieVuln server'},
|
|
223
|
+
]);
|
|
224
|
+
seedOrigin = source === 'official' ? ORIGINS.fr : options ? options.seedUrl : proxyOrigin(String(await ask('VigieVuln server URL (include http:// or https://): ')).trim());
|
|
225
|
+
}
|
|
226
|
+
const accountNeeded = profile === 'proxy' || seed;
|
|
227
|
+
let session, key, origin, anonymous = false;
|
|
228
|
+
if (accountNeeded) {
|
|
229
|
+
origin = seedOrigin || proxy || ORIGINS.fr;
|
|
230
|
+
const accountOrigin = origin === ORIGINS.fr || origin === ORIGINS.com ? ACCOUNT_ORIGIN : origin;
|
|
231
|
+
if (accountOrigin.startsWith('http://')) {
|
|
232
|
+
warn(HTTP_WARNING);
|
|
233
|
+
if (original.insecureHttpOrigin !== accountOrigin && !options?.allowInsecureHttp) {
|
|
234
|
+
if (options || !interactive) throw new Error('HTTP requires explicit confirmation; pass --allow-insecure-http for non-interactive setup.');
|
|
235
|
+
const answer = await choose(`Allow unencrypted HTTP to ${accountOrigin}?`, [{name:'no',message:'No (default)'},{name:'yes',message:'Yes, allow this server'}]);
|
|
236
|
+
if (answer !== 'yes') throw new Error('Setup cancelled: HTTP connection not approved.');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const official = origin === ORIGINS.fr || origin === ORIGINS.com;
|
|
240
|
+
anonymous = !official && !(await (deps.authenticationRequired || authenticationRequired)(origin, deps.fetcher));
|
|
241
|
+
if (anonymous) {
|
|
242
|
+
if (seed) {
|
|
243
|
+
warn('The current proxy bundle may be partial; its source coverage remains subject to the scan report.');
|
|
244
|
+
const targetDir = profile === 'proxy' ? (deps.proxyScope || require('./proxy-scope').proxyScope)(origin) : undefined;
|
|
245
|
+
const imported = await getSeed({origin,anonymous:true,targetDir});
|
|
246
|
+
if (imported?.cancelled) warn('Bundle download skipped.');
|
|
247
|
+
if (imported?.stats?.skipped?.length) warn(`Cache entries not imported: ${imported.stats.skipped.join(', ')}`);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
const persistent = (deps.createSessionStore || createAccountSessionStore)();
|
|
251
|
+
let staged = await persistent.read();
|
|
252
|
+
const tempStore = {read:()=>staged, write:value=>{staged=value;}, clear:()=>{staged=null;}};
|
|
253
|
+
const account = (deps.createAccountClient || createAccountClient)({sessionStore:tempStore, accountOrigin});
|
|
254
|
+
const env = deps.env || process.env;
|
|
255
|
+
if (options && (env.VIGIEVULN_EMAIL || env.VIGIEVULN_PASSWORD || options.acceptTerms)) {
|
|
256
|
+
let result;
|
|
257
|
+
if (env.VIGIEVULN_EMAIL || env.VIGIEVULN_PASSWORD) {
|
|
258
|
+
if (!env.VIGIEVULN_EMAIL || !env.VIGIEVULN_PASSWORD) throw Error('VIGIEVULN_EMAIL and VIGIEVULN_PASSWORD are both required');
|
|
259
|
+
result=await account.login({email:env.VIGIEVULN_EMAIL,password:env.VIGIEVULN_PASSWORD});
|
|
260
|
+
} else result=await account.me();
|
|
261
|
+
if (result.terms && !result.terms.accepted && options.acceptTerms) {
|
|
262
|
+
if (result.terms.version !== options.acceptTerms) throw Error('terms version does not match --accept-terms');
|
|
263
|
+
warn(`Accepting terms ${result.terms.version}: ${result.terms.url}`);
|
|
264
|
+
await account.acceptTerms(result.terms.version);
|
|
265
|
+
result={...result,terms:{...result.terms,accepted:true}};
|
|
266
|
+
}
|
|
267
|
+
await require('./account-terms').requireTerms({account,terms:result.terms,interactive:false,warn});
|
|
268
|
+
} else await (deps.ensureSignedIn || ensureSignedIn)({account, store:tempStore, ask, interactive:options ? false : interactive, warn, accountOrigin});
|
|
269
|
+
session = staged;
|
|
270
|
+
if (seed) {
|
|
271
|
+
if (!session || typeof session.token !== 'string' || !session.token) throw new Error('Account session is unavailable; sign in again.');
|
|
272
|
+
warn('The current proxy bundle may be partial; its source coverage remains subject to the scan report.');
|
|
273
|
+
const targetDir = profile === 'proxy' ? (deps.proxyScope || require('./proxy-scope').proxyScope)(origin) : undefined;
|
|
274
|
+
// Bundle download accepts the signed-in account session. Do not create a
|
|
275
|
+
// durable proxy key until the requested seed has been imported.
|
|
276
|
+
const imported = await getSeed({origin,token:session.token,targetDir});
|
|
277
|
+
if (imported?.cancelled) warn('Bundle download skipped.');
|
|
278
|
+
if (imported?.stats?.skipped?.length) warn(`Cache entries not imported: ${imported.stats.skipped.join(', ')}`);
|
|
279
|
+
}
|
|
280
|
+
if (profile === 'proxy') {
|
|
281
|
+
key = await account.createProxyKey();
|
|
282
|
+
if (!key || typeof key.token !== 'string' || !key.token) throw new Error('Proxy did not issue an account key.');
|
|
283
|
+
}
|
|
284
|
+
await persistent.write(session);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const updated = { ...original, sourceProfile:profile };
|
|
288
|
+
if (profile === 'proxy') updated.proxyCache = proxy;
|
|
289
|
+
else delete updated.proxyCache;
|
|
290
|
+
if (origin?.startsWith('http://')) updated.insecureHttpOrigin = origin;
|
|
291
|
+
if (profile === 'proxy') {
|
|
292
|
+
if (anonymous) updated.proxyAnonymousOrigin = proxy;
|
|
293
|
+
else delete updated.proxyAnonymousOrigin;
|
|
294
|
+
} else delete updated.proxyAnonymousOrigin;
|
|
295
|
+
if (key) { updated.proxyCacheToken = key.token; updated.proxyCacheTokenOrigin = origin; }
|
|
296
|
+
cfg.save(updated);
|
|
297
|
+
out(`Setup saved: ${profile}. Existing caches were preserved.`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
module.exports = { run, prompt, proxyOrigin, downloadSeed, estimateSeed, sqliteBytesFromPrefix, authenticationRequired, HELP };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Extract untrusted PE VERSIONINFO strings without loading or executing the image.
|
|
2
|
+
// Every offset and length is checked against the file/resource bounds. Malformed
|
|
3
|
+
// resources are treated as absent; no identity or vulnerability is inferred here.
|
|
4
|
+
const MAX_RESOURCE = 64 * 1024 * 1024;
|
|
5
|
+
const MAX_VERSION_INFO = 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
function extractPeMetadata(buf) {
|
|
8
|
+
try {
|
|
9
|
+
const ok = (p, n, end = buf.length) => Number.isSafeInteger(p) && p >= 0 && n >= 0 && p + n <= end;
|
|
10
|
+
const u16 = p => { if (!ok(p, 2)) throw Error('bounds'); return buf.readUInt16LE(p); };
|
|
11
|
+
const u32 = p => { if (!ok(p, 4)) throw Error('bounds'); return buf.readUInt32LE(p); };
|
|
12
|
+
if (!ok(0, 64) || buf.toString('ascii', 0, 2) !== 'MZ') return null;
|
|
13
|
+
const pe = u32(0x3c);
|
|
14
|
+
if (!ok(pe, 24) || buf.toString('binary', pe, pe + 4) !== 'PE\0\0') return null;
|
|
15
|
+
const sections = u16(pe + 6), optSize = u16(pe + 20), opt = pe + 24;
|
|
16
|
+
if (sections > 96 || !ok(opt, optSize)) return null;
|
|
17
|
+
const magic = u16(opt), dir = opt + (magic === 0x10b ? 96 : magic === 0x20b ? 112 : optSize);
|
|
18
|
+
if (dir + 24 > opt + optSize) return null;
|
|
19
|
+
const resourceRva = u32(dir + 16), resourceSize = u32(dir + 20);
|
|
20
|
+
if (!resourceRva || !resourceSize || resourceSize > MAX_RESOURCE) return null;
|
|
21
|
+
const sec = opt + optSize;
|
|
22
|
+
if (!ok(sec, sections * 40)) return null;
|
|
23
|
+
function rvaOffset(rva, length) {
|
|
24
|
+
for (let i = 0; i < sections; i++) {
|
|
25
|
+
const p = sec + i * 40, va = u32(p + 12), rawSize = u32(p + 16), raw = u32(p + 20);
|
|
26
|
+
const delta = rva - va;
|
|
27
|
+
if (delta >= 0 && delta + length <= rawSize && ok(raw + delta, length)) return raw + delta;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const root = rvaOffset(resourceRva, resourceSize);
|
|
32
|
+
if (root === null) return null;
|
|
33
|
+
const end = root + resourceSize;
|
|
34
|
+
let directoryCount = 0;
|
|
35
|
+
function directory(offset) {
|
|
36
|
+
if (++directoryCount > 256) throw Error('too many directories');
|
|
37
|
+
const p = root + offset;
|
|
38
|
+
if (!ok(p, 16, end)) throw Error('directory');
|
|
39
|
+
const count = u16(p + 12) + u16(p + 14);
|
|
40
|
+
if (count > 1024 || !ok(p + 16, count * 8, end)) throw Error('entries');
|
|
41
|
+
return Array.from({length: count}, (_, i) => [u32(p + 16 + i * 8), u32(p + 20 + i * 8)]);
|
|
42
|
+
}
|
|
43
|
+
const version = directory(0).find(([id, ref]) => id === 16 && (ref & 0x80000000));
|
|
44
|
+
if (!version) return null;
|
|
45
|
+
const values = [];
|
|
46
|
+
for (const [, nameRef] of directory(version[1] & 0x7fffffff)) {
|
|
47
|
+
if (!(nameRef & 0x80000000)) continue;
|
|
48
|
+
for (const [, langRef] of directory(nameRef & 0x7fffffff)) {
|
|
49
|
+
if (langRef & 0x80000000) continue;
|
|
50
|
+
const entry = root + langRef;
|
|
51
|
+
if (!ok(entry, 16, end)) continue;
|
|
52
|
+
const size = u32(entry + 4), data = rvaOffset(u32(entry), size);
|
|
53
|
+
if (data === null || size > MAX_VERSION_INFO || size < 6) continue;
|
|
54
|
+
const strings = {};
|
|
55
|
+
const align = n => Math.ceil(n / 4) * 4;
|
|
56
|
+
function block(p, limit, depth) {
|
|
57
|
+
if (depth > 5 || !ok(p, 6, limit)) return;
|
|
58
|
+
const length = u16(p), valueLength = u16(p + 2), type = u16(p + 4), stop = p + length;
|
|
59
|
+
if (length < 6 || stop > limit) return;
|
|
60
|
+
let q = p + 6;
|
|
61
|
+
while (ok(q, 2, stop) && u16(q) !== 0) q += 2;
|
|
62
|
+
if (!ok(q, 2, stop)) return;
|
|
63
|
+
const key = buf.toString('utf16le', p + 6, q); q = align(q + 2);
|
|
64
|
+
const bytes = type === 1 ? valueLength * 2 : valueLength;
|
|
65
|
+
if (!ok(q, bytes, stop)) return;
|
|
66
|
+
if (type === 1 && key.length <= 256 && bytes > 0 && bytes <= 8192)
|
|
67
|
+
Object.defineProperty(strings, key, { value: buf.toString('utf16le', q, q + bytes).replace(/\0+$/, ''), enumerable: true, configurable: true, writable: true });
|
|
68
|
+
q = align(q + bytes);
|
|
69
|
+
while (ok(q, 6, stop)) { const n = u16(q); if (!n || q + n > stop) break; block(q, stop, depth + 1); q = align(q + n); }
|
|
70
|
+
}
|
|
71
|
+
block(data, data + size, 0);
|
|
72
|
+
if (Object.keys(strings).length) values.push(strings);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return values.length ? { versionStrings: values } : null;
|
|
76
|
+
} catch { return null; }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = { extractPeMetadata };
|
|
@@ -23,12 +23,13 @@ const SKIP = new Set([
|
|
|
23
23
|
|
|
24
24
|
const MAGIC_BYTES = 8; // enough for every signature we sniff
|
|
25
25
|
|
|
26
|
-
function hashFile(fp) {
|
|
26
|
+
function hashFile(fp, kind) {
|
|
27
27
|
const buf = fs.readFileSync(fp);
|
|
28
28
|
return {
|
|
29
29
|
size: buf.length,
|
|
30
30
|
sha1: crypto.createHash("sha1").update(buf).digest("hex"),
|
|
31
31
|
sha256: crypto.createHash("sha256").update(buf).digest("hex"),
|
|
32
|
+
metadata: kind === "pe" ? require("./pe-metadata").extractPeMetadata(buf) : null,
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -61,8 +62,8 @@ function scanBinaries(dir, opts = {}) {
|
|
|
61
62
|
if (!ext) continue; // not an allowlisted extension
|
|
62
63
|
if (sniffKind(readMagic(fp)) !== ext) continue; // magic must confirm the extension
|
|
63
64
|
if (onProgress) onProgress(fp);
|
|
64
|
-
const h = hashFile(fp);
|
|
65
|
-
out.push({ path: fp, kind: ext, size: h.size, sha1: h.sha1, sha256: h.sha256, declaredName: e.name });
|
|
65
|
+
const h = hashFile(fp, ext);
|
|
66
|
+
out.push({ path: fp, kind: ext, size: h.size, sha1: h.sha1, sha256: h.sha256, metadata: h.metadata, declaredName: e.name });
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
return out;
|
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
|
31
31
|
try { records = scanBinaries(dir, { onProgress: opts.onBinaryProgress, srcRoot: opts.srcRoot || dir, excludePath: opts.excludePath, defaultExcludes: opts.defaultExcludes }); }
|
|
32
32
|
catch (e) { return { deps: out, warnings: [{ type: "scan-error", message: `binary scan failed: ${e.message}` }] }; }
|
|
33
33
|
for (const r of records) {
|
|
34
|
-
|
|
34
|
+
const record = makeDepRecord({
|
|
35
35
|
ecosystem: "binary",
|
|
36
36
|
name: r.declaredName,
|
|
37
37
|
version: null,
|
|
@@ -39,7 +39,9 @@ module.exports = {
|
|
|
39
39
|
provenance: "binary",
|
|
40
40
|
hashes: { sha1: r.sha1, sha256: r.sha256 },
|
|
41
41
|
declaredName: r.declaredName,
|
|
42
|
-
})
|
|
42
|
+
});
|
|
43
|
+
if (r.metadata) record.binaryMetadata = r.metadata;
|
|
44
|
+
out.set(`binary:${r.path}`, record);
|
|
43
45
|
}
|
|
44
46
|
return { deps: out, warnings };
|
|
45
47
|
},
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* API: https://packagist.org/packages/{vendor}/{pkg}.json
|
|
6
6
|
* → { package: { abandoned: bool|string, versions: { "<v>": {...} } } }
|
|
7
7
|
*
|
|
8
|
-
* Cached in ~/.fad-checker/packagist-cache.json for
|
|
8
|
+
* Cached in ~/.fad-checker/packagist-cache.json for 4h.
|
|
9
9
|
*
|
|
10
10
|
* @author: N.BRAUN
|
|
11
11
|
* @email: pp9ping@gmail.com
|
|
@@ -20,11 +20,11 @@ const { belongsToOtherComposerRegistry } = require("../../packagist-audit");
|
|
|
20
20
|
|
|
21
21
|
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
22
22
|
const CACHE_PATH = path.join(CACHE_DIR, "packagist-cache.json");
|
|
23
|
-
const CACHE_MAX_AGE_MS =
|
|
23
|
+
const CACHE_MAX_AGE_MS = 4 * 3600 * 1000;
|
|
24
24
|
const API = "https://packagist.org/packages";
|
|
25
25
|
|
|
26
|
-
function loadCache() {
|
|
27
|
-
function saveCache(d) {
|
|
26
|
+
function loadCache() { return require('../../json-cache').load(CACHE_DIR,'packagist',{ entries: {}, meta: {} }); }
|
|
27
|
+
function saveCache(d) { require('../../json-cache').save(CACHE_DIR,'packagist',d); }
|
|
28
28
|
|
|
29
29
|
function isStable(v) { return /^\d+(\.\d+)*$/.test(String(v || "").replace(/^v/, "")); }
|
|
30
30
|
function cmp(a, b) {
|
|
@@ -113,7 +113,8 @@ async function checkComposerRegistryDeps(deps, opts = {}) {
|
|
|
113
113
|
const result = { deprecated: [], outdated: [], licensed: [], private: [] };
|
|
114
114
|
if (!targets.length) return result;
|
|
115
115
|
const cache = loadCache();
|
|
116
|
-
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && (
|
|
116
|
+
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && require('../../cache-policy').fresh(cache.meta.fetchedAt, CACHE_MAX_AGE_MS);
|
|
117
|
+
const previous = !fresh && !offline ? {entries:cache.entries, fetchedAt:cache.meta?.fetchedAt} : null;
|
|
117
118
|
if (!fresh && !offline) cache.entries = {};
|
|
118
119
|
const limit = pLimit(concurrency);
|
|
119
120
|
await Promise.all(targets.map(t => limit(async () => {
|
|
@@ -145,7 +146,8 @@ async function checkComposerRegistryDeps(deps, opts = {}) {
|
|
|
145
146
|
})));
|
|
146
147
|
if (!offline) {
|
|
147
148
|
if (!fresh) cache.meta = { fetchedAt: Date.now() };
|
|
148
|
-
|
|
149
|
+
require('../../cache-policy').preserveEntries(cache, previous);
|
|
150
|
+
saveCache(cache);
|
|
149
151
|
}
|
|
150
152
|
return result;
|
|
151
153
|
}
|
package/lib/codecs/go/parse.js
CHANGED
|
@@ -106,19 +106,17 @@ function parseGoSum(text) {
|
|
|
106
106
|
const m = raw.trim().match(/^(\S+)\s+(v\S+?)(\/go\.mod)?\s+h1:/);
|
|
107
107
|
if (!m) continue;
|
|
108
108
|
// go.sum records two kinds of line per module:
|
|
109
|
-
// mod ver h1:…
|
|
109
|
+
// mod ver h1:… checksum of the downloaded module ZIP
|
|
110
110
|
// mod ver/go.mod h1:… only its go.mod was read, during minimal version selection
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
// them put gin, echo AND go-restful in one report, three mutually exclusive web
|
|
116
|
-
// frameworks. 70% of that project's Go production findings came from modules that
|
|
117
|
-
// were never built.
|
|
111
|
+
// Neither kind proves that a version belongs to the current build. Keep ZIP
|
|
112
|
+
// checksums as a best-effort inventory and do not turn metadata-only records
|
|
113
|
+
// into installed dependencies. The codec warns when this fallback is used;
|
|
114
|
+
// a resolved module graph is needed to establish selection and completeness.
|
|
118
115
|
if (m[3]) continue;
|
|
119
116
|
const name = m[1];
|
|
120
117
|
const ver = stripV(m[2]);
|
|
121
|
-
//
|
|
118
|
+
// Historical downloads may contain several versions; highest is a fallback,
|
|
119
|
+
// not proof of the version selected by the Go resolver.
|
|
122
120
|
const prev = byMod.get(name);
|
|
123
121
|
if (!prev || compareMavenVersions(ver, prev) > 0) byMod.set(name, ver);
|
|
124
122
|
}
|
|
@@ -18,10 +18,10 @@ const { withPublic, authHeaderFor, normalise } = require("../../registries");
|
|
|
18
18
|
|
|
19
19
|
const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
|
|
20
20
|
const CACHE_PATH = path.join(CACHE_DIR, "go-proxy-cache.json");
|
|
21
|
-
const CACHE_MAX_AGE_MS =
|
|
21
|
+
const CACHE_MAX_AGE_MS = 4 * 3600 * 1000;
|
|
22
22
|
|
|
23
|
-
function loadCache() {
|
|
24
|
-
function saveCache(d) {
|
|
23
|
+
function loadCache() { return require('../../json-cache').load(CACHE_DIR,'go-proxy',{ entries: {}, meta: {} }); }
|
|
24
|
+
function saveCache(d) { require('../../json-cache').save(CACHE_DIR,'go-proxy',d); }
|
|
25
25
|
|
|
26
26
|
// proxy.golang.org case-encoding: uppercase letters → "!" + lowercase.
|
|
27
27
|
function escapeModule(mod) {
|
|
@@ -62,7 +62,8 @@ async function checkGoRegistryDeps(deps, opts = {}) {
|
|
|
62
62
|
const result = { deprecated: [], outdated: [], licensed: [], private: [] };
|
|
63
63
|
if (!targets.length || !allLibs) return result;
|
|
64
64
|
const cache = loadCache();
|
|
65
|
-
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && (
|
|
65
|
+
const fresh = (offline || !require("../../providers").hasHostedProxy()) && cache.meta?.fetchedAt && require('../../cache-policy').fresh(cache.meta.fetchedAt, CACHE_MAX_AGE_MS);
|
|
66
|
+
const previous = !fresh && !offline ? {entries:cache.entries, fetchedAt:cache.meta?.fetchedAt} : null;
|
|
66
67
|
if (!fresh && !offline) cache.entries = {};
|
|
67
68
|
const limit = pLimit(concurrency);
|
|
68
69
|
await Promise.all(targets.map(t => limit(async () => {
|
|
@@ -85,7 +86,8 @@ async function checkGoRegistryDeps(deps, opts = {}) {
|
|
|
85
86
|
// fresh to the next ONLINE run and skip its refetch.
|
|
86
87
|
if (!offline) {
|
|
87
88
|
if (!fresh) cache.meta = { fetchedAt: Date.now() };
|
|
88
|
-
|
|
89
|
+
require('../../cache-policy').preserveEntries(cache, previous);
|
|
90
|
+
saveCache(cache);
|
|
89
91
|
}
|
|
90
92
|
return result;
|
|
91
93
|
}
|
package/lib/codecs/go.codec.js
CHANGED
|
@@ -88,6 +88,11 @@ module.exports = {
|
|
|
88
88
|
// go.sum graph for anything go.mod didn't select — skipping it silently
|
|
89
89
|
// dropped every transitive dep of a pre-1.17 module.
|
|
90
90
|
const needSum = !modHadDeps || goMinor == null || goMinor < 17;
|
|
91
|
+
if (needSum && (goMinor == null || goMinor < 17 || g.names.has('go.sum'))) {
|
|
92
|
+
warnings.push({ type: 'go-coverage', ecosystem: 'go', reason: 'module-graph-not-resolved',
|
|
93
|
+
manifestPath: path.join(g.dir, g.names.has('go.mod') ? 'go.mod' : 'go.sum'),
|
|
94
|
+
message: 'Go module graph was not resolved: this manifest does not establish the full pruned graph, and go.sum records checksums rather than selected build dependencies. Transitive inventory may be incomplete or include historical versions.' });
|
|
95
|
+
}
|
|
91
96
|
if (needSum && g.names.has("go.sum")) {
|
|
92
97
|
const fp = path.join(g.dir, "go.sum");
|
|
93
98
|
parsedManifests.push(fp);
|