vigievuln 1.3.0 → 1.3.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 +14 -1052
- package/README.md +36 -69
- package/lib/artifacts/applications.js +6 -2
- package/lib/artifacts/component-scope.js +54 -0
- package/lib/artifacts/enrichment.js +1 -0
- package/lib/artifacts/inventory-scope.js +51 -0
- package/lib/artifacts/report-inventory.js +5 -1
- package/lib/artifacts/report.js +28 -8
- package/lib/artifacts/retire.js +80 -0
- package/lib/artifacts/scan.js +39 -21
- package/lib/charts.js +20 -3
- package/lib/cli-image.js +5 -0
- package/lib/cve-record-coverage.js +109 -0
- package/lib/cve-report.js +111 -29
- package/lib/diagnostics.js +14 -1
- package/lib/diff.js +0 -0
- package/lib/euvd.js +6 -2
- package/lib/finding-enrichment.js +8 -7
- package/lib/finding-summary.js +1 -1
- package/lib/i18n.js +16 -1
- package/lib/image-references.js +21 -1
- package/lib/json-export.js +6 -4
- package/lib/nvd.js +52 -16
- package/lib/providers/index.js +6 -6
- package/lib/report-notices.js +38 -3
- package/lib/retire.js +12 -10
- package/lib/source-health.js +47 -23
- package/lib/source-image-scan.js +1 -0
- package/lib/system-inventory/advisories.js +7 -6
- package/lib/system-inventory/alpine-tracker.js +5 -5
- package/lib/system-inventory/collect.js +1 -1
- package/lib/system-inventory/distribution-sources.js +2 -2
- package/lib/system-inventory/nginx-advisories.js +26 -8
- package/package.json +1 -1
- package/vigievuln.js +32 -16
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[](https://github.com/9pings/VigieVuln/actions/workflows/ci.yml)
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
**VigieVuln 1.3.
|
|
13
|
+
**VigieVuln 1.3.2** is a polyglot dependency auditor for code audits.
|
|
14
14
|
|
|
15
15
|
It scans dependencies and **9 CMS/frameworks** in one pass without build tools, supports **air-gapped** workflows, detects private packages, binaries and certificates, and produces HTML, JSON and other reports.
|
|
16
16
|
|
|
@@ -44,6 +44,10 @@ It scans dependencies and **9 CMS/frameworks** in one pass without build tools,
|
|
|
44
44
|
|
|
45
45
|
📖 **[Usage & all flags](docs/USAGE.md)** · **[Architecture](docs/ARCHITECTURE.md)** · **[Comparison vs other tools](docs/COMPARISON.md)** · **[Data sources](docs/DATA-SOURCES.md)**
|
|
46
46
|
|
|
47
|
+
> [!IMPORTANT]
|
|
48
|
+
> **Although VigieVuln is an excellent tool—comprehensive, rigorously tested, and regularly updated—it is still relatively new, and like any other scanner, it may occasionally produce errors.
|
|
49
|
+
> Whenever possible, cross-check important findings with another analysis tool — though, among the tools we compared, none offers reports as comprehensive as VigieVuln.**
|
|
50
|
+
|
|
47
51
|
## Quick start
|
|
48
52
|
|
|
49
53
|
```bash
|
|
@@ -51,22 +55,11 @@ npm install -g vigievuln
|
|
|
51
55
|
vigievuln scan ./code # → ./vigievuln-report/cve-report.html
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Monitor a project
|
|
57
|
-
|
|
58
|
-
Monitor your project's direct dependencies for new high, critical or known exploited vulnerabilities. Create and verify a [Vigie Vuln account](https://www.vigievuln.fr/account) first.
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
vigievuln login # sign in and accept the terms
|
|
62
|
-
vigievuln watch ./project --export deps.json # optional: review the inventory locally
|
|
63
|
-
vigievuln watch ./project --name 'My Project' # upload or update the project
|
|
64
|
-
vigievuln project status # check the monitoring status
|
|
65
|
-
```
|
|
58
|
+
### Faster scans using personal NVD API key
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
A free [NVD API key](https://nvd.nist.gov/developers/request-an-api-key) (instant) gives 10× faster enrichment: `vigievuln --set-nvd-key YOUR_KEY`. A few common runs; full list via `vigievuln --help` or [docs/USAGE.md](docs/USAGE.md)
|
|
68
61
|
|
|
69
|
-
###
|
|
62
|
+
### Faster scans using the VigieVuln DB European hosted cache
|
|
70
63
|
|
|
71
64
|
Use [Vigie Vuln DB](https://www.vigievuln.fr/) as a European-hosted source for scans, including reviewed VigieVuln advisories for Maven and npm.
|
|
72
65
|
|
|
@@ -78,22 +71,17 @@ vigievuln setup --mode direct --sources all # switch back to direct sources
|
|
|
78
71
|
|
|
79
72
|
The proxy receives package coordinates and CVE identifiers, not source code. Cached advisories remain usable offline; partial version evidence leaves other versions unknown. [Proxy guide](docs/USAGE.md#hosted-vigievuln-proxy).
|
|
80
73
|
|
|
81
|
-
###
|
|
74
|
+
### Include container images
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
- **[Multi-instance CMS & frameworks — open the report](https://9pings.github.io/VigieVuln/samples/multi-cms-frameworks.html)**: WordPress 6.4.2, Drupal 8.5.0, Symfony Demo (Symfony 7.1.1) and BookStack v24.10 (Laravel 10.48.22), with findings attributed to each instance.
|
|
76
|
+
Add `--images` to scan supported container images referenced by the project alongside its dependencies, without Docker; this option is off by default.
|
|
85
77
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- **Gradle:** without a lock, POM-based resolution can differ from Gradle. Locks cover only their recorded configurations, which may mix runtime, tests and build tools.
|
|
91
|
-
- **Python:** exact pins are checked; transitives require a supported resolved lockfile or complete inventory.
|
|
92
|
-
- **Coverage:** missing metadata or unavailable advisory sources can cause omissions or false positives. Review report warnings.
|
|
78
|
+
```bash
|
|
79
|
+
vigievuln scan ./code --images
|
|
80
|
+
```
|
|
93
81
|
|
|
94
|
-
|
|
82
|
+
The report keeps source and image findings in separate summaries and charts, highlighting vulnerable images and their most critical CVEs. [Image inputs, options and coverage](docs/IMAGES.md).
|
|
95
83
|
|
|
96
|
-
## Why use vigievuln
|
|
84
|
+
## Why use vigievuln ?
|
|
97
85
|
|
|
98
86
|
An author-maintained comparison of audit workflows; see [`docs/COMPARISON.md`](docs/COMPARISON.md)
|
|
99
87
|
for versions, sources and limitations. `⚠️` indicates partial or conditional support.
|
|
@@ -116,12 +104,7 @@ for versions, sources and limitations. `⚠️` indicates partial or conditional
|
|
|
116
104
|
| **Share one cache across the fleet**, API keys server-side | ✅ `serve-cache` | ❌ | ⚠️ local DB | ⚠️ local DB | ⚠️ local DB | ⚠️ cloud |
|
|
117
105
|
|
|
118
106
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
**Deliberately not a goal: reachability.** A finding is a vulnerable version on the dependency
|
|
122
|
-
graph, and the report says exactly that (in Methodology) instead of guessing at call paths. Deciding
|
|
123
|
-
whether the vulnerable code is reachable in *this* application is the auditor's call, made with
|
|
124
|
-
application context no scanner has.
|
|
107
|
+
**Deliberately not a goal: reachability.** ( That's an AI or human Job )
|
|
125
108
|
|
|
126
109
|
## More examples
|
|
127
110
|
|
|
@@ -140,39 +123,16 @@ vigievuln -s ./site --app-plugins wordpress --private-component wp-content/plugi
|
|
|
140
123
|
|
|
141
124
|
> [!IMPORTANT]
|
|
142
125
|
> **`--offline` reads the cache, it doesn't replace it.** On a *cold* cache there is nothing to
|
|
143
|
-
> match against;
|
|
144
|
-
> a seed or warm it online, then review coverage and freshness warnings in the offline report.
|
|
145
|
-
> Cached advisories can match other applicable versions, but neither a partial cache nor an
|
|
146
|
-
> old snapshot guarantees complete or current results.
|
|
126
|
+
> match against;
|
|
147
127
|
> Air-gapped machines get their cache via [`--export-cache` / `--import-cache`](#air-gapped-audits).
|
|
148
128
|
|
|
149
|
-
## What it finds
|
|
150
|
-
|
|
151
|
-
The report keeps the six root chapters. Sub-chapters appear only when they contain results and are numbered consecutively; application inventory and methodology remain available in scan context:
|
|
152
|
-
|
|
153
|
-
| Chapter | Source | What it catches |
|
|
154
|
-
| --- | --- | --- |
|
|
155
|
-
| **0. Warnings** *(top)* | local heuristics | Missing lockfiles, unresolved Maven versions (BOM-managed), private packages absent from configured registries |
|
|
156
|
-
| **Δ. Changes since baseline** *(top, with `--baseline`)* | diff vs prior JSON | New / fixed / unchanged findings per category + the list of **new production CVEs**; for repeat audits and `--fail-on-new` CI gating |
|
|
157
|
-
| **1. CVE** *(X direct, Y indirect, Z dev)* | CVEProject + OSV.dev + Packagist + qualified publisher feeds + NVD/CPE | **Applications first when findings exist**; CMS/framework findings by instance and owner · **Production**; public CVE / GHSA in other prod deps, per ecosystem, per manifest, **prioritised** by CISA KEV + EPSS + CVSS · **Vendored JS vulns** ([retire.js](https://retirejs.github.io/)) — one row per physical library, linked CVEs + CWEs on the row, every advisory behind a click · **Dev** (`test`/`provided`, `dev`/`optional`/`peer`) · **Likely false positives** (CPE-filtered) |
|
|
158
|
-
| **2. Unmanaged / unversioned components** | deps.dev + CIRCL (by checksum), retire.js, built-in X.509 | **Embedded binaries**; CVEs in libs shipped inside committed `.jar`/`.war`/`.ear` (fat-jars, shaded uber-jars) · **Native binaries** (`.dll`/`.exe`/`.so`/`.dylib`): available metadata and checksum evidence; metadata alone does not reliably identify a product or establish CVE applicability · **Vendored JavaScript** inventory (jQuery, Bootstrap, …) vulnerable *or not* · **Certificates & key material**; committed certs (expiry / weak key / weak signature / self-signed), **private vs public keys** (PEM/OpenSSH/PuTTY/PGP/SSH) and keystores, all parsed offline |
|
|
159
|
-
| **3. Maintenance / EOL** *(X EOL, Y obsolete, Z outdated)* | endoflife.date · curated + registry flags · Maven Central / npm / Packagist / PyPI / NuGet | **End-of-Life** frameworks (+ an "Out of active support" band with `--eol-support`; Symfony/Laravel grouped as one row per framework; PHP runtime when the Composer constraint proves it), split **direct** (declared / parent-POM-inherited — bump these) vs **transitive** (bump the dep that pulls them in) · **Obsolete / deprecated / abandoned / yanked** · **Outdated** (newer version available, with release dates; direct deps only) |
|
|
160
|
-
| **4. Licenses** *(opt-in: `--licenses`)* | registry metadata + Maven POMs → SPDX policy | Each dep's license normalised to SPDX and classified; copyleft (GPL/AGPL/LGPL/MPL), proprietary and unknown flagged for review |
|
|
161
|
-
| **5. Fix Recommendations** | computed | Per-ecosystem pin recipes: Maven `<dependencyManagement>`, Gradle `constraints { }`, npm `overrides`, yarn `resolutions`, `composer require`, `pip install`, `dotnet add package` |
|
|
162
|
-
| **6. Scan context & limitations** | provenance manifest + walk | **Scanned descriptors** (every manifest parsed) · **Ignored directories** (pruned paths + rule) · **Methodology, data sources & limitations** (data-source freshness, run config, explicit statement of **what vigievuln does *not* assess**) · **Application inventory & coverage** (also shown when no CVE matches) |
|
|
163
|
-
| **Supply-chain risk** *(cross-cutting)* | OSV `MAL-…` + name heuristic | **Known-malicious** packages (always block the CI gate, any `--fail-on` level) and **suspected typosquats** (`--typosquat`: an npm/PyPI name one edit from a popular package; `lodahs`↔`lodash`) |
|
|
164
|
-
|
|
165
|
-
The HTML report opens in any browser, contains every detail (CVSS vectors, references, full descriptions, CPE configurations, via-paths for transitives) and ships a Word-compatible `.doc` twin. Every match carries a **composite priority** (KEV-exploited > EPSS likelihood > CVSS severity), and the run can additionally emit a **CycloneDX 1.6 SBOM** (`--report-sbom`, vulnerabilities inline) and a **CSAF 2.0 VEX** (`--report-csaf`) for downstream tooling.
|
|
166
|
-
|
|
167
|
-
<p align="center"><img src="docs/assets/report.png" alt="vigievuln HTML report; executive summary with severity tiles and a detailed CVE table with CWE, descriptions and fix versions" width="900"></p>
|
|
168
|
-
|
|
169
129
|
|
|
170
130
|
## CMS & frameworks
|
|
171
131
|
|
|
172
132
|
See the [CMS coverage limits](docs/CMS-FRAMEWORKS.md#coverage-and-its-current-limits)
|
|
173
|
-
and [shared-cache operating limits](docs/USAGE.md#shared-proxy-cache-server-serve-cache
|
|
133
|
+
and [shared-cache operating limits](docs/USAGE.md#shared-proxy-cache-server-serve-cache----proxy-cache).
|
|
174
134
|
|
|
175
|
-
|
|
135
|
+
VigieVuln inventories the **instance**: core, plugins, themes, bundles and framework components with their observed versions, attributes dependency findings where ownership is established, and reports each instance in its own sub-chapter.
|
|
176
136
|
|
|
177
137
|
| Product | Inventory | Advisory lane |
|
|
178
138
|
| --- | --- | --- |
|
|
@@ -185,7 +145,7 @@ vigievuln doesn't just read the `composer.json` under a WordPress or Drupal site
|
|
|
185
145
|
| **SPIP** | core (`$spip_version_branche` in `ecrire/inc_version.php`), dist plugins (`paquet.xml`), user plugins (`paquet.xml`/legacy `plugin.xml`) | **NVD product CVEs** (`cpe:2.3:a:spip:spip`) — the only machine-readable SPIP source; plugins stay honestly not-qualified |
|
|
186
146
|
| **Joomla / Magento (Adobe Commerce)** | core, extensions/modules, themes | no machine-readable publisher feed exists; components locked as Composer packages read as covered by the **dependency lanes**, the rest stays honestly **not qualified**. A Magento source distribution reports its exact version from the root `composer.json` |
|
|
187
147
|
|
|
188
|
-
|
|
148
|
+
Private/custom components are inventoried separately and never sent to any publisher. → **[the dedicated guide](docs/CMS-FRAMEWORKS.md)** · [application usage](docs/USAGE.md#application-inventory-experimental)
|
|
189
149
|
|
|
190
150
|
## Air-gapped audits
|
|
191
151
|
|
|
@@ -213,7 +173,22 @@ Review the descriptor before sharing and the report's coverage and freshness inf
|
|
|
213
173
|
- [`docs/COMPARISON.md`](docs/COMPARISON.md); vs OSV-Scanner / Trivy / Grype / OWASP DC / Snyk, and how it stays build-free.
|
|
214
174
|
- [`docs/BENCHMARK.md`](docs/BENCHMARK.md) — dated scanner comparisons on pinned projects, including warm and cold offline limitations.
|
|
215
175
|
- [`docs/DATA-SOURCES.md`](docs/DATA-SOURCES.md); the public datasets vigievuln uses + their licenses.
|
|
216
|
-
- [`CHANGELOG.md`](CHANGELOG.md) · [`CLAUDE.md`](CLAUDE.md); release
|
|
176
|
+
- [`CHANGELOG.md`](CHANGELOG.md) · [`CLAUDE.md`](CLAUDE.md); current release notes · code-level orientation for contributors.
|
|
177
|
+
|
|
178
|
+
### Interactive HTML samples
|
|
179
|
+
|
|
180
|
+
- **[Apache Dubbo 2.7.8 — open the report](https://9pings.github.io/VigieVuln/samples/dubbo.html)**: the project used for the report screenshot below, rescanned with VigieVuln 1.2.1; 105 Maven descriptors, direct/transitive CVEs, KEV matches, EOL and fix recommendations.
|
|
181
|
+
- **[Multi-instance CMS & frameworks — open the report](https://9pings.github.io/VigieVuln/samples/multi-cms-frameworks.html)**: WordPress 6.4.2, Drupal 8.5.0, Symfony Demo (Symfony 7.1.1) and BookStack v24.10 (Laravel 10.48.22), with findings attributed to each instance.
|
|
182
|
+
|
|
183
|
+
These are standalone reports from real source scans, generated on **2026-11-04** with VigieVuln **1.2.1**. Dubbo uses the hosted proxy; the CMS sample uses its local cache offline and focuses on PHP dependencies. Missing Wordfence/Drupal advisory and WordPress checksum inputs are explicitly marked incomplete. [Sample scope, sources and reproduction commands](docs/samples/README.md).
|
|
184
|
+
|
|
185
|
+
### Resolution and coverage
|
|
186
|
+
|
|
187
|
+
- **Gradle:** without a lock, POM-based resolution can differ from Gradle. Locks cover only their recorded configurations, which may mix runtime, tests and build tools.
|
|
188
|
+
- **Python:** exact pins are checked; transitives require a supported resolved lockfile or complete inventory.
|
|
189
|
+
- **Coverage:** missing metadata or unavailable advisory sources can cause omissions or false positives. Review report warnings.
|
|
190
|
+
|
|
191
|
+
See [usage](docs/USAGE.md) and [measured results](docs/BENCHMARK.md).
|
|
217
192
|
|
|
218
193
|
## Contributing
|
|
219
194
|
|
|
@@ -223,14 +198,6 @@ with the coordinate and the manifest snippet that produced it. Dev setup, ground
|
|
|
223
198
|
codec extension point → [`CONTRIBUTING.md`](CONTRIBUTING.md). Vulnerabilities in vigievuln
|
|
224
199
|
itself → [`SECURITY.md`](SECURITY.md) (please report privately).
|
|
225
200
|
|
|
226
|
-
**On AI assistance:** this codebase is written with heavy use of Claude Code; [`CLAUDE.md`](CLAUDE.md)
|
|
227
|
-
in the repo root is exactly what it looks like. The bar it's held to is the one you can check
|
|
228
|
-
yourself: the test suite (`npm test`), the zero-network guarantee enforced by a tripwire test and
|
|
229
|
-
and the dated comparisons and limitations documented in [`docs/BENCHMARK.md`](docs/BENCHMARK.md). `vigievuln` itself uses **no LLM at runtime**; findings come from public
|
|
230
|
-
vulnerability databases and deterministic parsers, and no report text is generated. Full
|
|
231
|
-
statement, including where review actually caught a bad finding →
|
|
232
|
-
[`AI_POLICY.md`](AI_POLICY.md). Where the code doesn't meet that bar, that's a bug report I want.
|
|
233
|
-
|
|
234
201
|
## License
|
|
235
202
|
|
|
236
203
|
Apache-2.0; see [`LICENSE`](LICENSE).
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const {makeDepRecord} = require('../dep-record');
|
|
5
|
+
const {isNpmPackageDescriptor,isProjectDescriptor} = require('./component-scope');
|
|
5
6
|
const MAX_METADATA = 16 * 1024 * 1024;
|
|
6
7
|
const handlers = [
|
|
7
|
-
{id:'npm', matches:(n,fp)=>n==='package.json' && fp
|
|
8
|
+
{id:'npm', matches:(n,fp)=>n==='package.json' && isNpmPackageDescriptor(fp), parse:(text)=>{const j=JSON.parse(text);return j.name || j.version ? [{ecosystem:'npm',name:j.name,version:j.version}] : [];}},
|
|
9
|
+
{id:'composer-project', matches:(n,fp)=>n==='composer.json' && isProjectDescriptor(fp), parse:(text)=>{const j=JSON.parse(text);return j.name || j.version ? [{ecosystem:'composer',name:j.name,version:j.version}] : [];}},
|
|
10
|
+
{id:'pypi-project', matches:(n,fp)=>n==='pyproject.toml' && isProjectDescriptor(fp), parse:(text)=>{const j=require('smol-toml').parse(text),p=j.project || j.tool?.poetry || {};return p.name || p.version ? [{ecosystem:'pypi',name:p.name,version:p.version}] : [];}},
|
|
11
|
+
{id:'maven-project', matches:(n,fp)=>n==='pom.xml' && isProjectDescriptor(fp), async parse(text){const j=await require('xml2js').parseStringPromise(text),p=j.project;if(!p)return [];const parent=p.parent?.[0]||{},name=p.artifactId?.[0],namespace=p.groupId?.[0]||parent.groupId?.[0],version=p.version?.[0]||parent.version?.[0];if(!name)return [];if(!namespace || /\$\{/.test(String(namespace)+String(version)))throw Error('project coordinates are not literal');return [{ecosystem:'maven',namespace,name,version}];}},
|
|
8
12
|
{id:'pypi', matches:(n,fp)=>(n==='METADATA' && /\.dist-info$/i.test(path.basename(path.dirname(fp)))) || (n==='PKG-INFO' && /\.egg-info$/i.test(path.basename(path.dirname(fp)))), parse:(text)=>{const name=/^Name:\s*(.+)$/im.exec(text)?.[1]?.trim(), version=/^Version:\s*(.+)$/im.exec(text)?.[1]?.trim();return [{ecosystem:'pypi',name,version}];}},
|
|
9
13
|
{id:'composer', matches:(n,fp)=>n==='installed.json' && path.basename(path.dirname(fp))==='composer', parse:(text)=>{const j=JSON.parse(text), pkgs=Array.isArray(j)?j:j.packages;if(!Array.isArray(pkgs))throw Error('missing packages');return pkgs.map(p=>({ecosystem:'composer',name:p.name,version:p.version}));}},
|
|
10
14
|
{id:'composer-php', matches:(n,fp)=>n==='installed.php' && path.basename(path.dirname(fp))==='composer', parse:(text)=>{
|
|
@@ -26,7 +30,7 @@ async function collectInstalledApplications(root,opts={}) {
|
|
|
26
30
|
const deps=new Map(),warnings=[], coverage={files:0,records:0,handlers:{}}; const stack=[root], max=opts.maxMetadataBytes ?? MAX_METADATA;
|
|
27
31
|
function warning(fp,error) {warnings.push({type:'dependency-coverage',reason:'installed-metadata-error',manifestPath:fp,message:`installed metadata incomplete for ${fp}: ${error.message}`});}
|
|
28
32
|
function add(item,fp,source) {if(item.ecosystem==='composer' && typeof item.name==='string' && !item.namespace) {const slash=item.name.indexOf('/');if(slash>0)item={...item,namespace:item.name.slice(0,slash),name:item.name.slice(slash+1)};}if(!valid(item)){warning(fp,Error('missing package name or version'));return;} const dep=makeDepRecord({...item,manifestPath:fp,provenance:'installed',scope:'transitive'});dep.coordKey=`installed:${fp}:${item.ecosystem}:${item.name}@${item.version}`;dep.installEvidence={path:fp,source};deps.set(dep.coordKey,dep);}
|
|
29
|
-
while(stack.length) {const dir=stack.pop();let entries;try{entries=fs.readdirSync(dir,{withFileTypes:true})}catch(e){warning(dir,e);continue}for(const entry of entries){const fp=path.join(dir,entry.name);if(entry.isDirectory()){stack.push(fp);continue}if(!entry.isFile())continue;if(entry.name==='installed.php' && entries.some(e=>e.name==='installed.json' && e.isFile()))continue;for(const h of activeHandlers){if(!h.matches(entry.name,fp))continue;coverage.files++;coverage.handlers[h.id]=(coverage.handlers[h.id]||0)+1;try{const st=fs.statSync(fp);if(st.size>max)throw Error(`metadata exceeds ${max} bytes`);const parsed=h.parse(fs.readFileSync(fp,'utf8'));for(const item of parsed)add(item,fp,h.id)}catch(e){warning(fp,e)}break;}}}
|
|
33
|
+
while(stack.length) {const dir=stack.pop();let entries;try{entries=fs.readdirSync(dir,{withFileTypes:true})}catch(e){warning(dir,e);continue}for(const entry of entries){const fp=path.join(dir,entry.name);if(entry.isDirectory()){stack.push(fp);continue}if(!entry.isFile())continue;if(entry.name==='installed.php' && entries.some(e=>e.name==='installed.json' && e.isFile()))continue;for(const h of activeHandlers){if(!h.matches(entry.name,fp))continue;coverage.files++;coverage.handlers[h.id]=(coverage.handlers[h.id]||0)+1;try{const st=fs.statSync(fp);if(st.size>max)throw Error(`metadata exceeds ${max} bytes`);const parsed=await h.parse(fs.readFileSync(fp,'utf8'));for(const item of parsed)add(item,fp,h.id)}catch(e){warning(fp,e)}break;}}}
|
|
30
34
|
for(const collector of archives){try{const result=await collector.collect(root,opts);warnings.push(...(result.warnings||[]));coverage.handlers[collector.id]=(result.deps||[]).length;for(const item of result.deps||[]){const fp=item.manifestPaths?.[0]||root;if(!item.namespace && item.ecosystem==='maven'){warning(fp,Error('archive has no complete Maven coordinate'));continue}add({ecosystem:item.ecosystem,namespace:item.namespace,name:item.name,version:item.version},fp,collector.id);}}catch(e){warning(root,e)}}coverage.records=deps.size;coverage.complete=warnings.length===0;return {deps,warnings,coverage};
|
|
31
35
|
}
|
|
32
36
|
// Reclassify only an unidentifiable top-level JAR whose exact installed owner
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const IMAGE_COMPONENT_SCOPE='image-components/1';
|
|
4
|
+
const parts=value=>String(value||'').replace(/\\/g,'/').split('/').filter(Boolean);
|
|
5
|
+
const stores=new Set(['node_modules','vendor','site-packages','dist-packages','specifications','__pypackages__','.cache','.npm','.yarn','.m2','.gradle','.nuget']);
|
|
6
|
+
// Installed metadata is authoritative inside package stores; source manifests
|
|
7
|
+
// bundled there can be examples or fixtures belonging to the enclosing library.
|
|
8
|
+
const isProjectDescriptor=value=>!parts(value).some(n=>stores.has(n));
|
|
9
|
+
|
|
10
|
+
// Only a package root describes an installed npm component. Files such as
|
|
11
|
+
// pkg/dist/mjs/package.json set module-loading rules, not another package.
|
|
12
|
+
function isNpmPackageDescriptor(value) {
|
|
13
|
+
const names=parts(value);
|
|
14
|
+
if(names.at(-1)!=='package.json')return false;
|
|
15
|
+
const index=names.lastIndexOf('node_modules');
|
|
16
|
+
if(index<0)return true;
|
|
17
|
+
const tail=names.slice(index+1);
|
|
18
|
+
return tail[0]?.startsWith('@') ? tail.length===3 : tail.length===2 && !tail[0]?.startsWith('.');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function imageComponentRole(dep={}) {
|
|
22
|
+
if(imageComponentSource(dep).category==='global')return 'direct';
|
|
23
|
+
if(dep.ecosystem==='system' || dep.ecosystem==='binary')return 'direct';
|
|
24
|
+
const source=dep.installEvidence?.source;
|
|
25
|
+
if(['pypi','composer','composer-php','ruby','nuget','retire'].includes(source))return 'transitive';
|
|
26
|
+
if(dep.provenance==='binary-module')return dep.binaryEvidence?.original?.kind==='mod'?'direct':'transitive';
|
|
27
|
+
const paths=[dep.artifactPath,dep.installEvidence?.path,...(dep.manifestPaths||[])].filter(Boolean);
|
|
28
|
+
if(paths.some(p=>String(p).includes('!/') || parts(p).some(n=>stores.has(n)) || String(p).replace(/\\/g,'/').includes('usr/share/nodejs/')))return 'transitive';
|
|
29
|
+
return 'direct';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Paths here are relative to the image, never the temporary extraction directory.
|
|
33
|
+
// A package store is not evidence of a global install unless its prefix is known.
|
|
34
|
+
function imageComponentSource(dep={}) {
|
|
35
|
+
const p=String(dep.artifactPath || dep.installEvidence?.path || dep.manifestPaths?.[0] || '').replace(/\\/g,'/').replace(/^\/+/, '');
|
|
36
|
+
const source=dep.installEvidence?.source;
|
|
37
|
+
const os=dep.ecosystem==='system' ? dep : dep.osPackageOwners?.[0];
|
|
38
|
+
if(os)return {category:'system',manager:os.manager || os.packageType || 'system'};
|
|
39
|
+
if(source==='retire' || dep.ecosystemType==='retire')return {category:'vendored',manager:'retirejs'};
|
|
40
|
+
const npm=/^((?:(?:usr(?:\/local)?|opt\/[^/]+)\/lib|(?:root|home\/[^/]+)\/(?:\.npm-global\/lib|\.nvm\/versions\/node\/[^/]+\/lib))\/node_modules)\/(?:@[^/]+\/)?[^/]+\/package\.json$/.exec(p);
|
|
41
|
+
if(dep.ecosystem==='npm' && npm)return {category:'global',manager:'npm',root:npm[1]};
|
|
42
|
+
const python=/^((?:usr(?:\/local)?\/lib(?:64)?\/python[^/]+|(?:root|home\/[^/]+)\/\.local\/lib\/python[^/]+)\/(?:site|dist)-packages)\//.exec(p);
|
|
43
|
+
if(dep.ecosystem==='pypi' && python)return {category:'global',manager:'python',root:python[1]};
|
|
44
|
+
const ruby=/^((?:usr(?:\/local)?\/(?:lib\/ruby\/gems|share\/gems)|var\/lib\/gems|(?:root|home\/[^/]+)\/\.gem\/ruby)(?:\/[^/]+)?)\/specifications\//.exec(p);
|
|
45
|
+
if(dep.ecosystem==='ruby' && ruby)return {category:'global',manager:'ruby',root:ruby[1]};
|
|
46
|
+
const composer=/^((?:root|home\/[^/]+)\/(?:\.composer|\.config\/composer))\/vendor\/composer\/installed\.(?:json|php)$/.exec(p);
|
|
47
|
+
if(dep.ecosystem==='composer' && composer)return {category:'global',manager:'composer',root:composer[1]};
|
|
48
|
+
if(p && !p.includes('!/') && isProjectDescriptor(p) && !p.startsWith('usr/share/nodejs/') &&
|
|
49
|
+
(['composer-project','pypi-project','maven-project'].includes(source) || dep.ecosystem==='npm' && /(?:^|\/)package\.json$/.test(p)))
|
|
50
|
+
return {category:'project',manager:dep.ecosystem,root:p.includes('/')?p.slice(0,p.lastIndexOf('/')):'.'};
|
|
51
|
+
return {category:'other',manager:dep.ecosystem || 'unknown'};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports={IMAGE_COMPONENT_SCOPE,isNpmPackageDescriptor,isProjectDescriptor,imageComponentRole,imageComponentSource};
|
|
@@ -45,6 +45,7 @@ const enrichmentAdapters=[
|
|
|
45
45
|
const byId=new Map(copies.map(x=>[x.cve.id,x]));
|
|
46
46
|
for(const m of matches){
|
|
47
47
|
const ids=cveIds(m), enriched=ids.map(id=>byId.get(id)).filter(x=>x?.source?.split('+').includes('nvd'));
|
|
48
|
+
for(const id of ids){const evidence=byId.get(id)?.cve?.nvdRecordEvidence;if(evidence)cveEvidence(m.cve,id).nvdRecordEvidence=evidence;}
|
|
48
49
|
const records=enriched.map(x=>({id:x.cve.id,relationship:relationship(m.cve,x.cve.id),severity:x.cve.severity||null,score:x.cve.score??null,
|
|
49
50
|
cvssVector:x.cve.cvssVector||null,cvssVersion:x.cve.cvssVersion||null,description:x.cve.description||null,
|
|
50
51
|
cwes:x.cve.cwes||[],references:x.cve.nvdRefs||[],published:x.cve.published||null,modified:x.cve.modified||null}));
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// A saved inventory is validated before this transformation. Filtering an old
|
|
4
|
+
// snapshot cannot reconstruct descriptors that its collectors never observed.
|
|
5
|
+
const { IMAGE_COMPONENT_SCOPE, isNpmPackageDescriptor, imageComponentRole, imageComponentSource } = require('./component-scope');
|
|
6
|
+
const SCOPE_REASON = 'image-inventory-scope-outdated';
|
|
7
|
+
const SCOPE_MESSAGE = 'The saved image inventory predates the current component scope or contains package metadata fragments. Reacquire the image to establish its current inventory.';
|
|
8
|
+
|
|
9
|
+
function pathsOf(value) {
|
|
10
|
+
return [value?.artifactPath, value?.manifestPath, value?.installEvidence?.path,
|
|
11
|
+
...(Array.isArray(value?.manifestPaths) ? value.manifestPaths : [])]
|
|
12
|
+
.filter(p => typeof p === 'string');
|
|
13
|
+
}
|
|
14
|
+
function isFragmentPath(path) {
|
|
15
|
+
return /(?:^|[\\/])package\.json$/i.test(path) && !isNpmPackageDescriptor(path);
|
|
16
|
+
}
|
|
17
|
+
function isNpmFragment(dep) {
|
|
18
|
+
return dep?.ecosystem === 'npm' && dep?.installEvidence?.source === 'npm'
|
|
19
|
+
&& pathsOf(dep).some(isFragmentPath);
|
|
20
|
+
}
|
|
21
|
+
function applyComponentScope(target, { checkPolicy = true } = {}) {
|
|
22
|
+
const result = structuredClone(target);
|
|
23
|
+
// Publisher SBOM contents are explicit evidence, not filesystem descriptors.
|
|
24
|
+
if (result.kind === 'sbom') return result;
|
|
25
|
+
let filtered = false;
|
|
26
|
+
result.deps = (result.deps || []).filter(dep => {
|
|
27
|
+
if (isNpmFragment(dep)) { filtered = true; return false; }
|
|
28
|
+
dep.imageRole = imageComponentRole(dep);
|
|
29
|
+
dep.imageSource = imageComponentSource(dep);
|
|
30
|
+
dep.scope = dep.imageRole === 'transitive' ? 'transitive' : 'runtime';
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
result.warnings = (result.warnings || []).filter(w => {
|
|
34
|
+
if (w?.reason === 'installed-metadata-error' && pathsOf(w).some(isFragmentPath)) { filtered = true; return false; }
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
result.coverage = result.coverage || [];
|
|
38
|
+
result.componentCount = result.deps.length;
|
|
39
|
+
if (checkPolicy && (result.metadata?.componentScope !== IMAGE_COMPONENT_SCOPE || filtered)) {
|
|
40
|
+
const existing = result.coverage.find(c => c.collector === 'installed-applications');
|
|
41
|
+
if (existing) {
|
|
42
|
+
if (!['failed', 'partial'].includes(existing.execution)) existing.execution = 'partial';
|
|
43
|
+
existing.result = 'indeterminate';
|
|
44
|
+
existing.reason = SCOPE_MESSAGE;
|
|
45
|
+
} else result.coverage.push({artifactTargetId:result.id,capability:'inventory',collector:'installed-applications',execution:'partial',result:'indeterminate',reason:SCOPE_MESSAGE});
|
|
46
|
+
if (!result.warnings.some(w => w?.reason === SCOPE_REASON))
|
|
47
|
+
result.warnings.push({type:'dependency-coverage',capability:'inventory',reason:SCOPE_REASON,message:SCOPE_MESSAGE});
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
module.exports = { applyComponentScope, SCOPE_REASON, SCOPE_MESSAGE };
|
|
@@ -13,7 +13,11 @@ function reportedComponents(artifact, matches = []) {
|
|
|
13
13
|
(match.dep?.artifactTargetId || match.artifactTargetId) === artifact.id &&
|
|
14
14
|
!match.cpeFiltered && (match.cve?.id || match.advisoryId)
|
|
15
15
|
).map(match => componentIdentity(match.dep || {})));
|
|
16
|
-
return (artifact.components || []).filter(dep =>
|
|
16
|
+
return (artifact.components || []).filter(dep => {
|
|
17
|
+
if(affected.has(componentIdentity(dep)))return true;
|
|
18
|
+
if(dep.imageRole==='transitive')return false;
|
|
19
|
+
return !needsAdvisory(dep);
|
|
20
|
+
});
|
|
17
21
|
}
|
|
18
22
|
function reportArtifacts(artifacts, matches) {
|
|
19
23
|
return artifacts.map(artifact => {
|
package/lib/artifacts/report.js
CHANGED
|
@@ -98,11 +98,26 @@ function renderImageCves(projectInfo = {}, matches = [], locale = 'en', helpers
|
|
|
98
98
|
if(!groups.length)return explanation+`<p>${noFindings} ${t('Reference-only images have not been scanned.','Les images uniquement déclarées n’ont pas été analysées.')}</p>`;
|
|
99
99
|
return explanation+groups.map(({artifact,matches:rows})=>{
|
|
100
100
|
const anchor=artifactAnchor(artifact.id),heading=`${esc(artifactTitle(artifact,artifacts))} (${rows.length})`;
|
|
101
|
-
const detail=rows.length && typeof render==='function' ?
|
|
101
|
+
const detail=rows.length && typeof render==='function' ? groupImageSources(rows,m=>m.dep,locale).map(group=>
|
|
102
|
+
`<details class="report-subsection" open data-image-source="${esc(group.category)}"><summary><h4>${esc(group.label)} (${group.items.length})</h4></summary><div>${render(group.items,{image:artifact})}</div></details>`).join('') : `<p>${noFindings}</p>`;
|
|
102
103
|
const content=`${renderImageSummary(artifact,locale)}<p class="image-section-nav"><a class="report-section-link" href="#${anchor}">${t('Image inventory and coverage','Inventaire et couverture de l’image')}<span aria-hidden="true">→</span></a></p>${detail}`;
|
|
103
104
|
return typeof minor==='function' ? minor(heading,content,{id:anchor+'-cves'}) : `<details class="report-subsection" open id="${anchor}-cves"><summary><h3>${heading}</h3></summary><div>${content}</div></details>`;
|
|
104
105
|
}).join('');
|
|
105
106
|
}
|
|
107
|
+
function groupImageSources(items,depOf,locale) {
|
|
108
|
+
const t=tr(locale),groups=new Map(),order=['system','global','project','vendored','other'];
|
|
109
|
+
const labels={system:t('System packages','Paquets système'),global:t('Global installations','Installations globales'),project:t('Applications with a root descriptor','Applications avec un descripteur racine'),vendored:t('Bundled JavaScript (RetireJS)','JavaScript embarqué (RetireJS)'),other:t('Other components and sub-dependencies','Autres composants et sous-dépendances')};
|
|
110
|
+
const managers={dpkg:'APT / dpkg',deb:'APT / dpkg',apk:'APK',rpm:'RPM',npm:'npm -g',python:'Python',ruby:'RubyGems',composer:'Composer'};
|
|
111
|
+
for(const item of items){
|
|
112
|
+
const dep=depOf(item),source=dep.imageSource || require('./component-scope').imageComponentSource(dep);
|
|
113
|
+
const category=order.includes(source.category)?source.category:'other';
|
|
114
|
+
const suffix=['system','global'].includes(category)?managers[source.manager] || source.manager:category==='project'?source.root:'';
|
|
115
|
+
const key=JSON.stringify([category,suffix]);
|
|
116
|
+
if(!groups.has(key))groups.set(key,{category,label:labels[category]+(suffix?' — '+suffix:''),items:[]});
|
|
117
|
+
groups.get(key).items.push(item);
|
|
118
|
+
}
|
|
119
|
+
return [...groups.values()].sort((a,b)=>order.indexOf(a.category)-order.indexOf(b.category)||a.label.localeCompare(b.label));
|
|
120
|
+
}
|
|
106
121
|
function stats(group) {
|
|
107
122
|
const matches=visible(group.matches),components=new Set(),advisories=new Set(),cves=new Set(),severity={critical:0,high:0,medium:0,low:0,unknown:0},updates=new Map();
|
|
108
123
|
for(const m of matches) {
|
|
@@ -164,11 +179,17 @@ function renderArtifactEvidence(projectInfo = {}, locale = 'en', matches = []) {
|
|
|
164
179
|
// by a finding. Keep its correction, and identify the source of this row.
|
|
165
180
|
for(const [key,findings] of findingIndex)if(!inventoryKeys.has(key)){inventory.push({...findings[0].dep,_fromFinding:true});inventoryKeys.add(key);}
|
|
166
181
|
inventory.sort((left,right)=>Number(affectedKeys.has(componentIdentity(right)))-Number(affectedKeys.has(componentIdentity(left))));
|
|
167
|
-
const
|
|
168
|
-
const updates=updateIndex.get(
|
|
169
|
-
const fixes=[...new Set(updates.map(u=>u.fix))]
|
|
170
|
-
|
|
182
|
+
const componentRows=items=>items.map(c=>{
|
|
183
|
+
const key=componentIdentity(c),updates=updateIndex.get(key)||[],findings=findingIndex.get(key)||[];
|
|
184
|
+
const fixes=[...new Set(updates.map(u=>u.fix))];
|
|
185
|
+
const advisories=[...new Set(findings.flatMap(m=>[m.advisoryId||m.cve?.id,...linkedCves(m.cve)]).filter(Boolean))];
|
|
186
|
+
const links=advisories.map(id=>/^CVE-\d{4}-\d{4,}$/i.test(id)
|
|
187
|
+
? `<a href="#${anchor}-cves">${esc(id)}</a>`
|
|
188
|
+
: `<a href="${advisoryUrl(id)}">${esc(id)}</a>`).join(', ');
|
|
189
|
+
return `<tr><td><code>${esc(c.namespace?c.namespace+'/'+c.name:c.name||c.artifactId||c.coord||'')}</code><br>${esc(c.packageType||c.ecosystem||'')}${c._fromFinding?`<br><small>${t('From finding; not present in inventory','Issu d’un résultat ; absent de l’inventaire')}</small>`:''}</td><td>${esc(c.version||'—')}</td><td>${fixes.map(esc).join('<br>')||'—'}</td><td>${links||'—'}</td><td>${esc(c.architecture||'—')}</td><td>${esc(c.artifactPath||'—')}</td><td>${esc((c.osPackageOwners||[]).map(o=>`${o.name}@${o.version}`).join(', ')||'—')}</td></tr>`;
|
|
171
190
|
}).join('');
|
|
191
|
+
const table=items=>items.length?`<table class="image-inventory"><thead><tr><th>${t('Component','Composant')}</th><th>${t('Installed','Installé')}</th><th>${t('Candidate corrections','Corrections proposées')}</th><th>${t('Advisories','Avis')}</th><th>Arch</th><th>${t('Location','Emplacement')}</th><th>${t('OS package owner','Paquet système propriétaire')}</th></tr></thead><tbody>${componentRows(items)}</tbody></table>`:`<p>${t('No components observed.','Aucun composant observé.')}</p>`;
|
|
192
|
+
const componentSections=groupImageSources(inventory,c=>c,locale).map(group=>`<h5>${esc(group.label)} (${group.items.length})</h5>${table(group.items)}`).join('');
|
|
172
193
|
const totals=[[t('Components','Composants'),Number(a.componentCount ?? a.components?.length ?? 0)],[t('Affected packages','Paquets affectés'),s.components],[t('Advisories','Avis'),s.advisories],[t('Unique CVEs','CVE distinctes'),s.cves]];
|
|
173
194
|
const totalsTable=`<table class="image-totals"><thead><tr>${totals.map(([label])=>`<th scope="col">${label}</th>`).join('')}</tr></thead><tbody><tr>${totals.map(([,value])=>`<td class="image-total-value">${value}</td>`).join('')}</tr><tr><td colspan="4"><span class="image-severity-label">${t('CVE row severities','Sévérités des lignes CVE')}</span>${renderSeverityCounts(s.severity,locale)}</td></tr></tbody>${group.matches.length?`<tfoot><tr><td colspan="4"><a class="report-section-link" href="#${anchor}-cves">${t('View vulnerability details','Voir les vulnérabilités')}<span aria-hidden="true">→</span></a></td></tr></tfoot>`:''}</table>`;
|
|
174
195
|
const noCve=visible(group.matches).filter(m=>m.dep?.ecosystem==='system' && !linkedCves(m.cve).length);
|
|
@@ -183,9 +204,8 @@ function renderArtifactEvidence(projectInfo = {}, locale = 'en', matches = []) {
|
|
|
183
204
|
totalsTable+
|
|
184
205
|
imageAction+
|
|
185
206
|
(rows?`<details open><summary>${t('Coverage checks','Contrôles de couverture')}</summary><table><thead><tr><th>${t('Capability','Capacité')}</th><th>${t('Source','Source')}</th><th>${t('Execution','Exécution')}</th><th>${t('Result / limitation','Résultat / limite')}</th></tr></thead><tbody>${rows}</tbody></table></details>`:`<p>${t('Coverage information unavailable.','Informations de couverture indisponibles.')}</p>`)+
|
|
186
|
-
renderAdvisoryObservations(a,locale)+nonCveAdvisories+`<details class="report-subsection"><summary><h4>${t('Component inventory and candidate corrections','Inventaire des composants et corrections proposées')} (${inventory.length})</h4></summary><p>${t('
|
|
187
|
-
(components?`<table class="image-inventory"><thead><tr><th>${t('Component','Composant')}</th><th>${t('Installed','Installé')}</th><th>${t('Candidate corrections','Corrections proposées')}</th><th>${t('Advisories','Avis')}</th><th>Arch</th><th>${t('Location','Emplacement')}</th><th>${t('OS package owner','Paquet système propriétaire')}</th></tr></thead><tbody>${components}</tbody></table>`:`<p>${t('No component details to display.','Aucun composant à détailler.')}</p>`)+`</details></div></details>`;
|
|
207
|
+
renderAdvisoryObservations(a,locale)+nonCveAdvisories+`<details class="report-subsection"><summary><h4>${t('Component inventory and candidate corrections','Inventaire des composants et corrections proposées')} (${inventory.length})</h4></summary><p>${t('Direct applications are listed with or without findings; sub-dependencies, system packages and native binaries are detailed only when associated with an advisory. Roles describe the image inventory, not project dependency scope.','Les applications directes sont listées avec ou sans résultat ; les sous-dépendances, paquets système et binaires natifs sont détaillés uniquement lorsqu’un avis leur est associé. Les rôles décrivent l’inventaire de l’image et non la portée des dépendances du projet.')}</p><p>${t('Candidate versions come from individual advisories. Verify them in the replacement image; they do not establish that a particular image tag or digest is corrected.','Les versions proposées proviennent d’avis individuels. Vérifiez-les dans l’image de remplacement ; elles ne prouvent pas qu’un tag ou une empreinte d’image est corrigé.')}</p>${componentSections}</details></div></details>`;
|
|
188
208
|
}).join('');
|
|
189
|
-
return referenceNotice+overview+(groups.length?`<p>${t('A raw finding is an advisory affecting a component. An advisory can link several CVEs; the CVE section groups linked CVE identifiers while advisories without linked CVEs remain below.','Un résultat brut correspond à un avis affectant un composant. Un avis peut être lié à plusieurs CVE ; la section CVE regroupe les identifiants liés et les avis sans CVE liée restent ci-dessous.')}</p>`:'')+cards
|
|
209
|
+
return renderReferences(projectInfo,artifacts,locale)+referenceNotice+overview+(groups.length?`<p>${t('A raw finding is an advisory affecting a component. An advisory can link several CVEs; the CVE section groups linked CVE identifiers while advisories without linked CVEs remain below.','Un résultat brut correspond à un avis affectant un composant. Un avis peut être lié à plusieurs CVE ; la section CVE regroupe les identifiants liés et les avis sans CVE liée restent ci-dessous.')}</p>`:'')+cards;
|
|
190
210
|
}
|
|
191
211
|
module.exports={artifactAnchor,artifactTitle,artifactGroups,renderImageCves,renderArtifactEvidence};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Inspect image bytes only. Do not execute the image's JavaScript or follow its
|
|
3
|
+
// symlinks. Persist identities, then reassess them with the current signature DB.
|
|
4
|
+
const fs=require('node:fs'),path=require('node:path'),crypto=require('node:crypto');
|
|
5
|
+
const retire=require('retire/lib/retire');
|
|
6
|
+
const POLICY='image-retire/1';
|
|
7
|
+
const EXCLUDED=new Set(['node_modules','bower_components','jspm_packages','vendor','site-packages','dist-packages','__pypackages__','.git','.npm','.yarn','.pnpm-store','.cache','.m2','.gradle','.nuget']);
|
|
8
|
+
async function repository(options){
|
|
9
|
+
const helper=require('../retire');
|
|
10
|
+
const refreshed=await helper.warmRetireSignatures({...options,force:options.forceUpdate});
|
|
11
|
+
const entry=helper.cachedSignatureEntry(options.cacheDir);
|
|
12
|
+
if(!entry || !refreshed.ok && !options.offline && require('../providers').hasHostedProxy())throw Error(refreshed.error || 'RetireJS signatures are unavailable');
|
|
13
|
+
const repo=JSON.parse(retire.replaceVersion(entry.value));
|
|
14
|
+
if(!repo || typeof repo!=='object' || Array.isArray(repo))throw Error('Invalid RetireJS signatures');
|
|
15
|
+
for(const [name,record] of Object.entries(repo))if(name.startsWith('$'))delete repo[name];else if(!record?.extractors)throw Error('Invalid RetireJS extractor');
|
|
16
|
+
return {repo,signaturesAt:new Date(entry.fetchedAt).toISOString(),refreshError:refreshed.ok?null:refreshed.error || 'RetireJS signatures could not be refreshed'};
|
|
17
|
+
}
|
|
18
|
+
const warning=(error,capability='inventory')=>({type:'dependency-coverage',capability,reason:'image-retire-incomplete',message:error.message});
|
|
19
|
+
async function collectImageJs(root,options={},ownedPaths=[]){
|
|
20
|
+
const deps=[],warnings=[],coverage={collector:'image-retire',capability:'inventory',execution:'completed',result:'indeterminate',files:0,excludedDirectories:[...EXCLUDED],policy:POLICY};
|
|
21
|
+
const owned=new Set(ownedPaths.map(p=>path.posix.normalize('/'+String(p).replace(/\\/g,'/').replace(/^\/+/,''))));
|
|
22
|
+
coverage.excludedOwnedFiles=0;
|
|
23
|
+
let signatures;
|
|
24
|
+
try{signatures=await repository(options);coverage.signaturesAt=signatures.signaturesAt;if(signatures.refreshError)warnings.push(warning(Error(signatures.refreshError)));}
|
|
25
|
+
catch(error){return {deps,warnings:[warning(error)],coverage:{...coverage,execution:'not-run',reason:error.message}};}
|
|
26
|
+
const maxFile=options.maxImageJsFileBytes ?? 16*1024*1024,maxBytes=options.maxImageJsBytes ?? 128*1024*1024,maxFiles=options.maxImageJsFiles ?? 10000;
|
|
27
|
+
let bytes=0,stopped=false;const stack=[root];
|
|
28
|
+
while(stack.length && !stopped){
|
|
29
|
+
options.signal?.throwIfAborted();
|
|
30
|
+
const dir=stack.pop();let entries;
|
|
31
|
+
try{entries=fs.readdirSync(dir,{withFileTypes:true});}catch(error){warnings.push(warning(error));continue;}
|
|
32
|
+
for(const entry of entries){
|
|
33
|
+
const fp=path.join(dir,entry.name),rel=path.relative(root,fp).split(path.sep).join('/');
|
|
34
|
+
if(entry.isDirectory()){
|
|
35
|
+
if(!EXCLUDED.has(entry.name) && !['proc','sys','dev','usr/share/nodejs'].includes(rel))stack.push(fp);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if(!entry.isFile() || !/\.(?:js|mjs|cjs)$/i.test(entry.name))continue;
|
|
39
|
+
// OS-owned libraries may be backported without changing their embedded
|
|
40
|
+
// upstream version. Their distribution advisories remain authoritative.
|
|
41
|
+
if(owned.has('/'+rel)){coverage.excludedOwnedFiles++;continue;}
|
|
42
|
+
try{
|
|
43
|
+
const size=fs.statSync(fp).size;
|
|
44
|
+
if(size>maxFile){warnings.push(warning(Error(`RetireJS file exceeds ${maxFile} bytes: ${rel}`)));continue;}
|
|
45
|
+
if(++coverage.files>maxFiles || bytes+size>maxBytes){warnings.push(warning(Error('RetireJS image scan resource limit reached')));stopped=true;break;}
|
|
46
|
+
bytes+=size;
|
|
47
|
+
let results=retire.scanFileName(rel,signatures.repo);
|
|
48
|
+
if(!results.length)results=retire.scanFileContent(fs.readFileSync(fp),signatures.repo,{sha1:text=>crypto.createHash('sha1').update(text).digest('hex')});
|
|
49
|
+
for(const result of results){
|
|
50
|
+
if(!result.component || !result.version)continue;
|
|
51
|
+
const dep=require('../dep-record').makeDepRecord({ecosystem:'npm',name:result.component,version:result.version,manifestPath:rel,provenance:'vendored',scope:'vendored'});
|
|
52
|
+
dep.coordKey=`retire:${rel}:${result.component}@${result.version}`;
|
|
53
|
+
dep.ecosystemType='retire';dep.installEvidence={source:'retire',path:rel,detection:result.detection};deps.push(dep);
|
|
54
|
+
}
|
|
55
|
+
}catch(error){warnings.push(warning(Error(`${rel}: ${error.message}`)));}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
coverage.bytes=bytes;coverage.count=deps.length;if(warnings.length)coverage.execution='partial';
|
|
59
|
+
return {deps,warnings,coverage};
|
|
60
|
+
}
|
|
61
|
+
async function assessImageJs(target,options={}){
|
|
62
|
+
const coverage={artifactTargetId:target.id,capability:'advisories',collector:'image-retire',execution:'completed',result:'no-match'};
|
|
63
|
+
if(!options.imageRetire)return {matches:[],warnings:[],coverage:{...coverage,execution:'not-applicable',result:'not-consulted',expected:false}};
|
|
64
|
+
const collected=target.coverage.find(c=>c.collector==='image-retire' && c.capability==='inventory');
|
|
65
|
+
if(!collected || collected.policy!==POLICY)return {matches:[],warnings:[warning(Error('RetireJS image inventory is unavailable; reacquire image contents with --image-retire.'))],coverage:{...coverage,execution:'not-run',result:'indeterminate'}};
|
|
66
|
+
try{
|
|
67
|
+
const {repo,signaturesAt,refreshError}=await repository(options),matches=[],missing=[];
|
|
68
|
+
for(const dep of target.deps.filter(d=>d.installEvidence?.source==='retire' && !d.osPackageOwners?.length)){
|
|
69
|
+
if(!repo[dep.name]){missing.push(dep.name);continue;}
|
|
70
|
+
const raw=[{file:dep.artifactPath,results:retire.check(dep.name,dep.version,repo)}];
|
|
71
|
+
matches.push(...require('../retire').normaliseRetireResults(raw).map(m=>({...m,dep})));
|
|
72
|
+
}
|
|
73
|
+
const incomplete=collected.execution!=='completed'||missing.length>0||!!refreshError;
|
|
74
|
+
const warnings=[];
|
|
75
|
+
if(missing.length)warnings.push(warning(Error(`RetireJS no longer identifies: ${[...new Set(missing)].join(', ')}`),'advisories'));
|
|
76
|
+
if(refreshError)warnings.push(warning(Error(refreshError),'advisories'));
|
|
77
|
+
return {matches,warnings,coverage:{...coverage,signaturesAt,execution:incomplete?'partial':'completed',result:matches.length?'affected':incomplete?'indeterminate':'no-match'}};
|
|
78
|
+
}catch(error){return {matches:[],warnings:[warning(error,'advisories')],coverage:{...coverage,execution:'not-run',result:'indeterminate',reason:error.message}};}
|
|
79
|
+
}
|
|
80
|
+
module.exports={POLICY,EXCLUDED,collectImageJs,assessImageJs};
|