vigievuln 1.3.1 → 1.3.3
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 +15 -0
- package/README.md +1 -1
- package/data/fingerprints/index.js +80 -0
- package/data/fingerprints/interpreters/javascript/bun.json +23 -0
- package/data/fingerprints/interpreters/javascript/deno.json +10 -0
- package/data/fingerprints/interpreters/javascript/electron.json +20 -0
- package/data/fingerprints/interpreters/javascript/gjs.json +8 -0
- package/data/fingerprints/interpreters/javascript/javascriptcore.json +14 -0
- package/data/fingerprints/interpreters/javascript/jscgtk.json +10 -0
- package/data/fingerprints/interpreters/javascript/node.json +26 -0
- package/data/fingerprints/interpreters/javascript/nwjs.json +8 -0
- package/data/fingerprints/interpreters/javascript/webkitgtk.json +10 -0
- package/data/fingerprints/interpreters/javascript/wpewebkit.json +10 -0
- package/data/fingerprints/interpreters/languages/dotnet.json +8 -0
- package/data/fingerprints/interpreters/languages/erlang.json +9 -0
- package/data/fingerprints/interpreters/languages/gawk.json +10 -0
- package/data/fingerprints/interpreters/languages/guile.json +9 -0
- package/data/fingerprints/interpreters/languages/java.json +8 -0
- package/data/fingerprints/interpreters/languages/julia.json +9 -0
- package/data/fingerprints/interpreters/languages/lua.json +11 -0
- package/data/fingerprints/interpreters/languages/luajit.json +10 -0
- package/data/fingerprints/interpreters/languages/perl.json +11 -0
- package/data/fingerprints/interpreters/languages/php.json +22 -0
- package/data/fingerprints/interpreters/languages/powershell.json +17 -0
- package/data/fingerprints/interpreters/languages/pypy.json +8 -0
- package/data/fingerprints/interpreters/languages/python.json +24 -0
- package/data/fingerprints/interpreters/languages/r.json +9 -0
- package/data/fingerprints/interpreters/languages/racket.json +9 -0
- package/data/fingerprints/interpreters/languages/raku.json +8 -0
- package/data/fingerprints/interpreters/languages/ruby.json +21 -0
- package/data/fingerprints/interpreters/languages/tcl.json +9 -0
- package/data/fingerprints/interpreters/shells/bash.json +10 -0
- package/data/fingerprints/interpreters/shells/dash.json +8 -0
- package/data/fingerprints/interpreters/shells/fish.json +9 -0
- package/data/fingerprints/interpreters/shells/ksh.json +8 -0
- package/data/fingerprints/interpreters/shells/zsh.json +9 -0
- package/data/fingerprints/services/databases/clickhouse.json +8 -0
- package/data/fingerprints/services/databases/elasticsearch.json +8 -0
- package/data/fingerprints/services/databases/etcd.json +9 -0
- package/data/fingerprints/services/databases/mariadb.json +9 -0
- package/data/fingerprints/services/databases/memcached.json +9 -0
- package/data/fingerprints/services/databases/mongo.json +8 -0
- package/data/fingerprints/services/databases/mysql.json +9 -0
- package/data/fingerprints/services/databases/opensearch.json +8 -0
- package/data/fingerprints/services/databases/postgres.json +18 -0
- package/data/fingerprints/services/databases/redis.json +9 -0
- package/data/fingerprints/services/databases/valkey.json +8 -0
- package/data/fingerprints/services/dns-directory/bind.json +8 -0
- package/data/fingerprints/services/dns-directory/dnsmasq.json +8 -0
- package/data/fingerprints/services/dns-directory/slapd.json +8 -0
- package/data/fingerprints/services/dns-directory/unbound.json +8 -0
- package/data/fingerprints/services/mail/cyrus.json +8 -0
- package/data/fingerprints/services/mail/dovecot.json +8 -0
- package/data/fingerprints/services/mail/exim.json +9 -0
- package/data/fingerprints/services/mail/opendkim.json +8 -0
- package/data/fingerprints/services/mail/opensmtpd.json +8 -0
- package/data/fingerprints/services/mail/postfix.json +8 -0
- package/data/fingerprints/services/mail/rspamd.json +8 -0
- package/data/fingerprints/services/mail/sendmail.json +8 -0
- package/data/fingerprints/services/messaging/kafka.json +8 -0
- package/data/fingerprints/services/messaging/mosquitto.json +8 -0
- package/data/fingerprints/services/messaging/nats.json +9 -0
- package/data/fingerprints/services/messaging/rabbitmq.json +8 -0
- package/data/fingerprints/services/remote-access/dropbear.json +8 -0
- package/data/fingerprints/services/remote-access/openssh.json +10 -0
- package/data/fingerprints/services/remote-access/proftpd.json +8 -0
- package/data/fingerprints/services/remote-access/samba.json +8 -0
- package/data/fingerprints/services/remote-access/vsftpd.json +8 -0
- package/data/fingerprints/services/web-proxies/apache.json +18 -0
- package/data/fingerprints/services/web-proxies/caddy.json +9 -0
- package/data/fingerprints/services/web-proxies/envoy.json +8 -0
- package/data/fingerprints/services/web-proxies/haproxy.json +10 -0
- package/data/fingerprints/services/web-proxies/lighttpd.json +8 -0
- package/data/fingerprints/services/web-proxies/nginx.json +14 -0
- package/data/fingerprints/services/web-proxies/squid.json +8 -0
- package/data/fingerprints/services/web-proxies/tomcat.json +8 -0
- package/data/fingerprints/services/web-proxies/traefik.json +9 -0
- package/data/fingerprints/services/web-proxies/varnish.json +8 -0
- package/lib/artifacts/component-scope.js +26 -3
- package/lib/artifacts/elf-product.js +215 -0
- package/lib/artifacts/image-products.js +180 -0
- package/lib/artifacts/install-version.js +44 -0
- package/lib/artifacts/inventory-scope.js +2 -1
- package/lib/artifacts/pe-product.js +28 -0
- package/lib/artifacts/product-advisories.js +207 -0
- package/lib/artifacts/product-catalog.js +62 -0
- package/lib/artifacts/report-inventory.js +7 -1
- package/lib/artifacts/report.js +42 -7
- package/lib/artifacts/retire.js +80 -0
- package/lib/artifacts/scan.js +40 -13
- package/lib/cli-image.js +6 -1
- package/lib/codecs/binary/elf-metadata.js +6 -0
- package/lib/codecs/binary/metadata.js +1 -1
- package/lib/codecs/binary/pe-metadata.js +47 -11
- package/lib/codecs/binary/scan.js +1 -1
- package/lib/cve-report.js +26 -3
- package/lib/i18n.js +2 -0
- package/lib/image-references.js +21 -1
- package/lib/json-export.js +2 -2
- package/lib/providers/nvd.js +16 -2
- package/lib/report-notices.js +1 -1
- package/lib/resource-cache/engine.js +3 -2
- package/lib/resource-cache/validate.js +1 -0
- package/lib/retire.js +12 -10
- package/lib/source-image-scan.js +1 -0
- package/lib/system-inventory/collect.js +1 -1
- package/lib/system-inventory/distribution-sources.js +1 -1
- package/lib/system-inventory/nginx-advisories.js +26 -8
- package/package.json +1 -1
- package/vigievuln.js +3 -1
package/lib/providers/nvd.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
const { cveId, requestKey } = require("./common");
|
|
2
2
|
module.exports = {
|
|
3
|
-
id: "nvd", ttlMs: 7 * 24 * 3600 * 1000, revalidateTypes: ['cve','cve-mirror'],
|
|
4
|
-
key(type, params, scope) {
|
|
3
|
+
id: "nvd", ttlMs: 7 * 24 * 3600 * 1000, revalidateTypes: ['cve','cve-mirror','image-product'],
|
|
4
|
+
key(type, params, scope) {
|
|
5
|
+
if (type === "image-product") {
|
|
6
|
+
const { product, version, cpe } = params;
|
|
7
|
+
return requestKey("nvd", type, { product, version, cpe }, scope);
|
|
8
|
+
}
|
|
9
|
+
return requestKey("nvd", type, type === "spip-advisories" ? {} : { id: cveId(params?.id) }, scope);
|
|
10
|
+
},
|
|
5
11
|
build(operation, params) {
|
|
12
|
+
if (operation === "image-product") {
|
|
13
|
+
const product = require("../artifacts/product-catalog").catalog.get(params?.product);
|
|
14
|
+
const cpe = params?.cpe;
|
|
15
|
+
if (!cpe || !product || ![product.cpe, ...(product.cpeAliases || [])].includes(cpe)) throw Error("Unknown image product CPE");
|
|
16
|
+
if (typeof params.version !== "string" || !/^\d{1,8}(?:\.\d{1,8}){1,3}$/.test(params.version)) throw Error("Invalid image product version");
|
|
17
|
+
const query = new URLSearchParams({virtualMatchString: "cpe:2.3:a:" + cpe + ":" + params.version, resultsPerPage: "2000", startIndex: "0"});
|
|
18
|
+
return {url: "https://services.nvd.nist.gov/rest/json/cves/2.0?" + query};
|
|
19
|
+
}
|
|
6
20
|
if (operation === "spip-advisories") return {
|
|
7
21
|
url: "https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:a:spip:spip&resultsPerPage=2000&startIndex=0",
|
|
8
22
|
};
|
package/lib/report-notices.js
CHANGED
|
@@ -23,7 +23,7 @@ function partitionReportNotices(values=[]){
|
|
|
23
23
|
// identified by their explicit image identity or image-specific type.
|
|
24
24
|
function warningScope(item) {
|
|
25
25
|
if(item?.type==='cve-enrichment-summary')return 'global';
|
|
26
|
-
if(item?.artifactTargetId || item?.artifactTargetIds?.length || item?.type==='image-source-unavailable' || item?.type==='image-scan-failed')return 'image';
|
|
26
|
+
if(item?.artifactTargetId || item?.artifactTargetIds?.length || item?.type==='image-unpinned' || item?.type==='image-source-unavailable' || item?.type==='image-scan-failed')return 'image';
|
|
27
27
|
return 'project';
|
|
28
28
|
}
|
|
29
29
|
// Group causes for presentation, retaining every distinct location and detail.
|
|
@@ -93,7 +93,7 @@ function validateResourceJson(resource, data) {
|
|
|
93
93
|
const text = v => typeof v === "string";
|
|
94
94
|
const language = v => object(v) && text(v.lang) && text(v.value);
|
|
95
95
|
const date = v => text(v) && /^\d{4}-\d{2}-\d{2}T/.test(v) && Number.isFinite(Date.parse(v));
|
|
96
|
-
const expectedId =
|
|
96
|
+
const expectedId = ["spip-advisories","image-product"].includes(resource.type) ? null : String(resource.params?.id || "").toUpperCase();
|
|
97
97
|
const node = (v, depth = 0) => {
|
|
98
98
|
if (!object(v) || depth > 64 || (v.operator !== undefined && !["AND", "OR"].includes(v.operator)) ||
|
|
99
99
|
(v.negate !== undefined && typeof v.negate !== "boolean")) return false;
|
|
@@ -128,7 +128,7 @@ function validateResourceJson(resource, data) {
|
|
|
128
128
|
if (!record(data)) invalid();
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
if (!["cve", "cve-mirror", "spip-advisories"].includes(resource.type) ||
|
|
131
|
+
if (!["cve", "cve-mirror", "spip-advisories", "image-product"].includes(resource.type) ||
|
|
132
132
|
!array(data.vulnerabilities, row => object(row) && record(row.cve))) invalid();
|
|
133
133
|
const count = data.vulnerabilities.length;
|
|
134
134
|
if (expectedId && count > 1) invalid();
|
|
@@ -773,6 +773,7 @@ function createResourceEngine(opts = {}) {
|
|
|
773
773
|
}
|
|
774
774
|
|
|
775
775
|
module.exports = {
|
|
776
|
+
validateResourceJson,
|
|
776
777
|
createResourceEngine, upstreamHeadersFor, ttlForUrl, sendJson, UpstreamDenied,
|
|
777
778
|
DEFAULT_TTL_MS, TTL_BY_SOURCE, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_TRANSFER_BYTES, DEFAULT_MAX_STORE_BYTES,
|
|
778
779
|
DEFAULT_UPSTREAM_TIMEOUT_MS, DEFAULT_MAX_CONCURRENT, DEFAULT_MAX_ENTRIES, FAILURE_RETRY_MS,
|
|
@@ -73,6 +73,7 @@ const RESOURCES = {
|
|
|
73
73
|
"nvd/cve": T.obj({ id: CVE }),
|
|
74
74
|
"nvd/cve-mirror": T.obj({ id: CVE }),
|
|
75
75
|
"nvd/spip-advisories": NONE,
|
|
76
|
+
"nvd/image-product": T.obj({product:T.oneOf([...require('../artifacts/product-catalog').catalog.values()].filter(p=>p.cpe).map(p=>p.id)),cpe:T.str(/^[a-z0-9_.-]+:[a-z0-9_.-]+$/,100),version:T.str(/^\d+(?:\.\d+){1,3}$/,40)}),
|
|
76
77
|
"osv/vuln": T.obj({ id: T.str(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, 100) }),
|
|
77
78
|
"osv/packages": T.obj({ queries: T.arr(OSV_QUERY, 1, 1000) }),
|
|
78
79
|
"epss/scores": T.obj({ ids: T.arr(CVE, 1, 100) }),
|
package/lib/retire.js
CHANGED
|
@@ -77,11 +77,11 @@ function writeCache(srcDir, body) {
|
|
|
77
77
|
{ _schema: RETIRE_CACHE_SCHEMA, _fetchedAt: Date.now(), body });
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function cachedSignatureEntry(){
|
|
81
|
-
try{return require('./cache-repository').createCacheRepository(path.dirname(RETIRE_SIG_DIR)).get('auxiliary','retire-signatures')||null}
|
|
80
|
+
function cachedSignatureEntry(cacheDir){
|
|
81
|
+
try{return require('./cache-repository').createCacheRepository(cacheDir || path.dirname(RETIRE_SIG_DIR)).get('auxiliary','retire-signatures')||null}
|
|
82
82
|
catch{return null}
|
|
83
83
|
}
|
|
84
|
-
function cachedSignatures(){return cachedSignatureEntry()?.value || null}
|
|
84
|
+
function cachedSignatures(cacheDir){return cachedSignatureEntry(cacheDir)?.value || null}
|
|
85
85
|
|
|
86
86
|
function findRetireBin() {
|
|
87
87
|
const local = path.join(__dirname, "..", "node_modules", ".bin", "retire");
|
|
@@ -134,11 +134,11 @@ function findRetireLauncher() {
|
|
|
134
134
|
*/
|
|
135
135
|
async function warmRetireSignatures(opts = {}) {
|
|
136
136
|
const { verbose, force, offline } = opts;
|
|
137
|
-
const present = !!cachedSignatures();
|
|
137
|
+
const present = !!cachedSignatures(opts.cacheDir);
|
|
138
138
|
if (offline) return present ? { ok: true, cached: true }
|
|
139
139
|
: { ok: false, error: "offline: no local retire signatures" };
|
|
140
140
|
const hostedOnline = require("./providers").hasHostedProxy();
|
|
141
|
-
if (!force && !hostedOnline && present && require('./cache-policy').fresh(cachedSignatureEntry()?.fetchedAt)) {
|
|
141
|
+
if (!force && !hostedOnline && present && require('./cache-policy').fresh(cachedSignatureEntry(opts.cacheDir)?.fetchedAt)) {
|
|
142
142
|
if (verbose) console.log(`retire: signatures already present (${RETIRE_SIG_FILE})`);
|
|
143
143
|
return { ok: true, cached: true };
|
|
144
144
|
}
|
|
@@ -149,7 +149,7 @@ async function warmRetireSignatures(opts = {}) {
|
|
|
149
149
|
const text = await res.text();
|
|
150
150
|
const repo = JSON.parse(text);
|
|
151
151
|
if (!repo || typeof repo !== "object" || Array.isArray(repo)) throw new Error("invalid retire signatures");
|
|
152
|
-
require('./cache-repository').createCacheRepository(path.dirname(RETIRE_SIG_DIR)).put('auxiliary','retire-signatures',text);
|
|
152
|
+
require('./cache-repository').createCacheRepository(opts.cacheDir || path.dirname(RETIRE_SIG_DIR)).put('auxiliary','retire-signatures',text);
|
|
153
153
|
if (verbose) console.log('retire: signatures warmed into SQLite cache');
|
|
154
154
|
return { ok: true };
|
|
155
155
|
} catch (e) {
|
|
@@ -160,10 +160,11 @@ async function warmRetireSignatures(opts = {}) {
|
|
|
160
160
|
|
|
161
161
|
// Hosted online: always consult the proxy (including its stale/source-health signal).
|
|
162
162
|
// Offline: only report local availability, even with --force and a configured proxy.
|
|
163
|
-
async function ensureSignatures(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
async function ensureSignatures(opts = {}) {
|
|
164
|
+
const { offline } = opts;
|
|
165
|
+
if (offline) return !!cachedSignatures(opts.cacheDir);
|
|
166
|
+
const r = await warmRetireSignatures(opts);
|
|
167
|
+
return !!r.ok || (!require('./providers').hasHostedProxy() && !!cachedSignatures(opts.cacheDir));
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
// Directories retire never needs to walk. Mirrors the per-walker default SKIP sets
|
|
@@ -524,6 +525,7 @@ module.exports = {
|
|
|
524
525
|
findRetireLauncher,
|
|
525
526
|
chooseRetireLauncher,
|
|
526
527
|
warmRetireSignatures,
|
|
528
|
+
cachedSignatureEntry,
|
|
527
529
|
ensureSignatures,
|
|
528
530
|
buildRetireArgs,
|
|
529
531
|
buildRetireIgnorePatterns,
|
package/lib/source-image-scan.js
CHANGED
|
@@ -13,6 +13,7 @@ function eligible(ref){return ref?.scanEligible!==false && (!ref?.classification
|
|
|
13
13
|
async function scanSourceImages(input,options={}){
|
|
14
14
|
const references=(input||[]).map(ref=>({...ref,boundArtifactIds:[]})),warnings=[],notices=[],empty={artifacts:[],matches:[],resolvedDeps:new Map(),warnings,notices,references};
|
|
15
15
|
if(options.images===false)return empty;
|
|
16
|
+
warnings.push(...require('./image-references').unpinnedImageWarnings(references));
|
|
16
17
|
const groups=new Map();
|
|
17
18
|
for(const ref of references){
|
|
18
19
|
if(!eligible(ref)){ref.scanStatus='not-scannable';ref.imageScan={status:'not-scannable',reasonCode:ref.classification||'unresolved',message:ref.blockReason||'The image declaration cannot be resolved to a registry image.',artifactIds:[]};continue;}
|
|
@@ -53,7 +53,7 @@ const apk={id:'apk', async collect(root,opts={}) {
|
|
|
53
53
|
if(!stanza.trim())continue;const f=fields(stanza); if(!f.P || !f.V){warnings.push('Malformed APK installed record');continue;}
|
|
54
54
|
let dir='';const ownedPaths=[];
|
|
55
55
|
for(const line of stanza.split(/\r?\n/)){if(line.startsWith('F:'))dir=line.slice(2);else if(line.startsWith('R:')){const name=line.slice(2),fp='/'+[dir,name].filter(Boolean).join('/');if(!fp.split('/').includes('..'))ownedPaths.push(fp);}}
|
|
56
|
-
packages.push(base(f.P,f.V,f.A,'apk',p,{sourceName:f.o || f.P,sourceVersion:f.V,ownedPaths}));
|
|
56
|
+
packages.push(base(f.P,f.V,f.A,'apk',p,{sourceName:f.o || f.P,sourceVersion:f.V,ownedPaths,packageMetadata:{maintainer:f.m||null,homepage:f.U||null}}));
|
|
57
57
|
}
|
|
58
58
|
return {packages,coverage:{collector:'apk',status:warnings.length?'incomplete':'complete',count:packages.length},warnings};
|
|
59
59
|
}};
|
|
@@ -3,7 +3,7 @@ const {createCacheRepository}=require('../cache-repository');
|
|
|
3
3
|
// Each adapter owns its scope, comparisons and evidence. Failed consultations
|
|
4
4
|
// never prevent the independent adapters or OSV from returning their results.
|
|
5
5
|
const adapters=[
|
|
6
|
-
{id:'nginx-vendor-advisories',supports:(d,inventory)=>inventory?.packages?.some(
|
|
6
|
+
{id:'nginx-vendor-advisories',supports:(d,inventory)=>inventory?.packages?.some(require('./nginx-advisories').isNginxPackage),identifyPackageOrigin:(pkg,options)=>require('./nginx-advisories').nginxPackageOrigin(pkg,options),async assess(inventory,options){return require('./nginx-advisories').assessNginxAdvisories(inventory.packages,options);}},
|
|
7
7
|
{id:'debian-security-tracker-history',supports:d=>d?.id==='debian',async assess(inventory,options){
|
|
8
8
|
const source=require('./historical-debian');
|
|
9
9
|
try{source.checkDistribution(inventory.distribution);}catch{return {matches:[],observations:[],warnings:[],coverage:[{source:this.id,execution:'not-applicable',result:'indeterminate',reason:'Exact Debian release codename is unavailable.'}]};}
|
|
@@ -4,19 +4,36 @@
|
|
|
4
4
|
const crypto=require('node:crypto');
|
|
5
5
|
const {createCacheRepository}=require('../cache-repository');
|
|
6
6
|
const {getCacheDir}=require('../cache-directory');
|
|
7
|
+
const PARSER_VERSION=2;
|
|
7
8
|
const SOURCE='nginx-vendor-advisories',URL='https://raw.githubusercontent.com/nginx/nginx.org/master/xml/en/security_advisories.xml',PAGE='https://nginx.org/en/security_advisories.html';
|
|
8
9
|
function ver(s){const m=/^(\d+)\.(\d+)\.(\d+)$/.exec(String(s));return m?m.slice(1).map(Number):null;}
|
|
9
10
|
function cmp(a,b){for(let i=0;i<3;i++)if(a[i]!==b[i])return a[i]-b[i];return 0;}
|
|
10
11
|
function inRange(version,text){const v=ver(version);if(!v)return null;const pieces=String(text||'').split(',').map(s=>s.trim());let unknown=false;for(const piece of pieces){if(piece==='all')return true;const m=/^(\d+\.\d+\.\d+)(?:-(\d+\.\d+\.\d+))?$/.exec(piece);if(!m){unknown=true;continue;}const low=ver(m[1]),high=ver(m[2]||m[1]);if(cmp(v,low)>=0&&cmp(v,high)<=0)return true;}return unknown?null:false;}
|
|
11
|
-
function
|
|
12
|
+
function isNginxPackage(p){return ['dpkg','apk'].includes(p?.manager)&&p.sourceName==='nginx';}
|
|
13
|
+
function fixedInBranch(version,text){
|
|
14
|
+
const current=ver(version);if(!current)return false;
|
|
15
|
+
// Stable fixes are exceptions to the broad vulnerable range, not fixes for
|
|
16
|
+
// a later mainline branch (e.g. 1.30.7 does not fix 1.31.8).
|
|
17
|
+
return String(text||'').split(',').some(piece=>{
|
|
18
|
+
const match=/^(\d+\.\d+\.\d+)\+$/.exec(piece.trim()),fixed=match&&ver(match[1]);
|
|
19
|
+
return fixed&&fixed[0]===current[0]&&fixed[1]===current[1]&&cmp(current,fixed)>=0;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function vendor(p,domains){
|
|
23
|
+
const meta=p.packageMetadata||{},origin=String(meta.origin||'').trim().toLowerCase(),maintainer=String(meta.maintainer||'');
|
|
24
|
+
const email=/<[^<>@\s]+@([^<>\s]+)>\s*$/.exec(maintainer)?.[1]?.toLowerCase();
|
|
25
|
+
// APK origin is a source package name, unlike the dpkg vendor Origin field.
|
|
26
|
+
const vendorOrigin=p.manager==='dpkg'&&(origin==='nginx'||origin==='nginx, inc.');
|
|
27
|
+
return vendorOrigin||!!email&&domains.includes(email)?{status:'third-party',source:vendorOrigin?'dpkg-origin':`${p.manager}-maintainer`,declared:vendorOrigin?meta.origin:meta.maintainer,signatureVerified:false}:null;
|
|
28
|
+
}
|
|
12
29
|
async function parseNginxAdvisories(input,{maxBytes=4*1024*1024}={}){
|
|
13
30
|
const bytes=Buffer.isBuffer(input)?input:Buffer.from(String(input));if(!bytes.length||bytes.length>maxBytes)throw Error('NGINX advisory XML exceeds size limit or is empty');let text=bytes.toString('utf8');
|
|
14
31
|
if(/<!ENTITY\b/i.test(text)||/<!DOCTYPE\s+[^>]*\[/i.test(text))throw Error('NGINX advisory XML contains entity declarations');
|
|
15
32
|
text=text.replace(/<!DOCTYPE\s+article\s+SYSTEM\s+["']\.\.\/\.\.\/dtd\/article\.dtd["']\s*>/i,'');if(/<!DOCTYPE\b/i.test(text))throw Error('unsupported NGINX XML doctype');
|
|
16
33
|
const doc=await require('xml2js').parseStringPromise(text,{strict:true}),sections=doc?.article?.section;if(!Array.isArray(sections))throw Error('invalid NGINX advisory XML');
|
|
17
34
|
const items=sections.flatMap(s=>s.security||[]).flatMap(s=>s.item||[]);if(!items.length)throw Error('NGINX advisory XML has no records');
|
|
18
|
-
const records=[];for(const item of items){const a=item.$||{},
|
|
19
|
-
if(!records.length)throw Error('NGINX advisory XML has no identified records');return {records,sha256:crypto.createHash('sha256').update(bytes).digest('hex')};
|
|
35
|
+
const records=[];for(const item of items){const a=item.$||{},cve=/^(?:CVE-)?(\d{4}-\d{4,})$/.exec(a.cve||''),id=cve?`CVE-${cve[1]}`:null;if(!id)continue;if(typeof a.name!=='string'||typeof a.vulnerable!=='string')throw Error('invalid NGINX advisory record');records.push({id,title:a.name,severity:a.severity||null,vulnerable:a.vulnerable,good:a.good||null,sourceDetails:{attributes:a,content:Object.fromEntries(Object.entries(item).filter(([key])=>key!=='$'))},advisory:typeof a.advisory==='string'&&/^https:\/\//.test(a.advisory)?a.advisory:PAGE});}
|
|
36
|
+
if(!records.length)throw Error('NGINX advisory XML has no identified records');return {records,parserVersion:PARSER_VERSION,sha256:crypto.createHash('sha256').update(bytes).digest('hex')};
|
|
20
37
|
}
|
|
21
38
|
async function syncNginxAdvisories(options={}){
|
|
22
39
|
if(options.offline)throw Error('cannot refresh NGINX advisories offline');const timeout=AbortSignal.timeout(options.timeoutMs??30000),signal=options.signal?AbortSignal.any([options.signal,timeout]):timeout;const res=await require('../providers').getResource('nginx','advisories',{}, {fetcher:options.fetcher,signal,streaming:true,noStore:true});if(!res.ok){await res.body?.cancel();throw Error(`NGINX advisory HTTP ${res.status}`);}let size=0,chunks=[];for await(const chunk of res.body){size+=chunk.length;if(size>(options.maxBytes??4*1024*1024))throw Error('NGINX advisory XML exceeds size limit');chunks.push(Buffer.from(chunk));}const parsed=await parseNginxAdvisories(Buffer.concat(chunks),options),now=Date.now(),stamp=Date.parse(res.headers.get('x-fad-proxy-fetched-at')||''),proxy=require('../providers').hasProxyRoute(),valid=Number.isFinite(stamp)&&stamp>0&&stamp<=now;
|
|
@@ -24,16 +41,17 @@ async function syncNginxAdvisories(options={}){
|
|
|
24
41
|
}
|
|
25
42
|
async function assessNginxAdvisories(packages,options={}){
|
|
26
43
|
const matches=[],observations=[],warnings=[],repo=options.cacheRepository||createCacheRepository(options.cacheDir||getCacheDir()),domains=options.allowedMaintainerDomains||['nginx.org','nginx.com','f5.com'];if(!Array.isArray(domains)||domains.some(d=>typeof d!=='string'||!/^[a-z0-9.-]+$/.test(d)))throw Error('invalid NGINX maintainer domains');
|
|
27
|
-
const candidates=(packages||[]).filter(
|
|
44
|
+
const candidates=(packages||[]).filter(isNginxPackage),cached=repo.get('catalogue','nginx-advisories')?.value,ttl=options.ttlMs??86400000;if(!Number.isSafeInteger(ttl)||ttl<=0)throw Error('invalid NGINX advisory TTL');let snapshot=Array.isArray(cached?.records)&&/^[a-f0-9]{64}$/.test(cached.sha256||'')&&Number.isFinite(cached.observedAt)?cached:null;
|
|
28
45
|
if(!candidates.length)return {matches,observations,coverage:[{source:SOURCE,execution:'not-applicable',result:'not-applicable'}],warnings};
|
|
29
|
-
if(!options.offline&&(!snapshot||snapshot.stale||Date.now()-snapshot.observedAt>=ttl||Date.now()<snapshot.observedAt)){try{snapshot=await syncNginxAdvisories(options);}catch(error){warnings.push({type:'source-unavailable',source:SOURCE,message:`NGINX advisories: ${error.message}`});}}
|
|
46
|
+
if(!options.offline&&(!snapshot||snapshot.parserVersion!==PARSER_VERSION||snapshot.stale||Date.now()-snapshot.observedAt>=ttl||Date.now()<snapshot.observedAt)){try{snapshot=await syncNginxAdvisories(options);}catch(error){warnings.push({type:'source-unavailable',source:SOURCE,message:`NGINX advisories: ${error.message}`});}}
|
|
30
47
|
if(!snapshot){if(options.offline)warnings.push({type:'source-unavailable',source:SOURCE,message:'NGINX vendor advisory snapshot is not cached.'});return {matches,observations,coverage:[{source:SOURCE,execution:'partial',result:'indeterminate',reason:'NGINX vendor advisory snapshot unavailable.'}],warnings};}
|
|
31
|
-
|
|
48
|
+
if(snapshot.parserVersion!==PARSER_VERSION)warnings.push({type:'source-unavailable',source:SOURCE,message:'Cached NGINX advisories use an older parser; refresh the catalogue online to restore complete advisory parsing.'});
|
|
49
|
+
for(const p of candidates){const identity=p.packageOrigin?.status==='ambiguous'?null:vendor(p,domains),upstream=/^(\d+\.\d+\.\d+)(?:-[A-Za-z0-9.+~]+)?$/.exec(p.sourceVersion||'')?.[1];for(const record of snapshot.records){const affected=inRange(upstream,record.vulnerable);if(affected===false||fixedInBranch(upstream,record.good))continue;const evidence={sourceURL:URL,sha256:snapshot.sha256,observedAt:snapshot.observedAt,advisoryURL:record.advisory,upstreamVersion:upstream||null,versionRange:record.vulnerable,fixedVersions:record.good,vendorSeverity:record.severity,packageOrigin:identity,signatureVerified:false,configurationApplicability:'unknown',sourceDetails:record.sourceDetails||null};
|
|
32
50
|
if(!identity||affected===null){observations.push({dep:p,cveId:record.id,status:'unknown',reason:!identity?'Vendor package origin is not established.':'Upstream version range cannot be evaluated.',evidence});continue;}
|
|
33
51
|
const current=ver(upstream),fix=(record.good||'').split(',').map(s=>s.trim()).map(s=>/^(\d+\.\d+\.\d+)\+$/.exec(s)?.[1]).filter(Boolean).filter(s=>{const v=ver(s);return v[0]===current[0]&&v[1]===current[1]&&cmp(v,current)>0;}).sort((a,b)=>cmp(ver(a),ver(b)))[0]||null;
|
|
34
52
|
matches.push({dep:{...p,packageOrigin:identity},source:SOURCE,advisoryId:record.id,cve:{id:record.id,summary:record.title,description:record.title,severity:'UNKNOWN',fixVersion:fix,advisorySource:record.advisory,vendorEvidence:evidence}});
|
|
35
53
|
}}
|
|
36
54
|
return {matches,observations,coverage:[{source:SOURCE,execution:snapshot.stale||warnings.length?'partial':'completed',result:'consulted',scope:'upstream-nginx-version',fetchedAt:snapshot.observedAt,sha256:snapshot.sha256,reason:'Version applicability is assessed from vendor declarations; runtime configuration and package signature remain unverified.'}],warnings};
|
|
37
55
|
}
|
|
38
|
-
function nginxPackageOrigin(pkg,options={}){if(pkg
|
|
39
|
-
module.exports={SOURCE,URL,nginxPackageOrigin,parseNginxAdvisories,syncNginxAdvisories,assessNginxAdvisories};
|
|
56
|
+
function nginxPackageOrigin(pkg,options={}){if(!isNginxPackage(pkg))return null;return vendor(pkg,options.allowedMaintainerDomains||['nginx.org','nginx.com','f5.com']);}
|
|
57
|
+
module.exports={SOURCE,URL,isNginxPackage,nginxPackageOrigin,parseNginxAdvisories,syncNginxAdvisories,assessNginxAdvisories};
|
package/package.json
CHANGED
package/vigievuln.js
CHANGED
|
@@ -587,6 +587,8 @@ program
|
|
|
587
587
|
.option("--no-go", "skip the Go codec")
|
|
588
588
|
.option("--no-ruby", "skip the Ruby (Bundler) codec")
|
|
589
589
|
.option("--no-binaries", "skip scanning committed native binaries (.dll/.exe/.so/.dylib)")
|
|
590
|
+
.option("--no-image-retire", "disable RetireJS inspection of image contents")
|
|
591
|
+
.option("--image-retire", "scan bundled JavaScript in image contents with RetireJS (excludes package stores)", false)
|
|
590
592
|
.option("--images", "enable image analysis in source-tree scans (off by default)", false)
|
|
591
593
|
.option("--no-images", "skip image declaration discovery and image analysis in source-tree scans")
|
|
592
594
|
.option("--image-platform <os/arch[/variant]>", "image platform when no platform is declared", "linux/amd64")
|
|
@@ -621,7 +623,7 @@ if (!process.argv.includes("--help-all")) {
|
|
|
621
623
|
const { foldedFlags } = require("./lib/cli-groups");
|
|
622
624
|
const { ADMIN_FLAGS, REPORTS } = require("./lib/cli-groups");
|
|
623
625
|
const folded = new Set([...foldedFlags(), ...ADMIN_FLAGS, ...REPORTS.map(r => `--report-${r}`),
|
|
624
|
-
"--images", "--image-platform", "--reuse-stable-advisories", "--no-reuse-stable-advisories", "--stable-advisory-age-days", "--proxy-rate-limit-wait-ms",
|
|
626
|
+
"--images", "--image-retire", "--no-image-retire", "--image-platform", "--reuse-stable-advisories", "--no-reuse-stable-advisories", "--stable-advisory-age-days", "--proxy-rate-limit-wait-ms",
|
|
625
627
|
"--source", "--list-app-plugins", "--scan-context", "--private-component", "--public-component", "--wordfence-live", "--wordfence-feed", "--drupal-advisories", "--wordfence-feed-url", "--drupal-advisories-live", "--prestashop-advisories", "--prestashop-advisories-live", "--typo3-advisories", "--typo3-advisories-live", "--spip-advisories", "--spip-advisories-live", "--wp-checksums", "--wp-checksums-live", "--wp-checksums-locale", "--max-advisory-age", "--fail-on-incomplete", "--proxy-cache-token", "--advisory-query-ttl", "--prepare-offline", "--output"]);
|
|
626
628
|
for (const opt of program.options) if (folded.has(opt.long)) opt.hidden = true;
|
|
627
629
|
} else {
|