vigievuln 1.3.0 → 1.3.1
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 +7 -1054
- package/README.md +36 -69
- package/lib/artifacts/applications.js +6 -2
- package/lib/artifacts/component-scope.js +31 -0
- package/lib/artifacts/enrichment.js +1 -0
- package/lib/artifacts/inventory-scope.js +50 -0
- package/lib/artifacts/report-inventory.js +1 -1
- package/lib/artifacts/report.js +14 -6
- package/lib/artifacts/scan.js +25 -15
- package/lib/charts.js +20 -3
- package/lib/cve-record-coverage.js +109 -0
- package/lib/cve-report.js +85 -26
- 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 +14 -1
- package/lib/json-export.js +5 -3
- package/lib/nvd.js +52 -16
- package/lib/providers/index.js +6 -6
- package/lib/report-notices.js +38 -3
- package/lib/source-health.js +47 -23
- package/lib/system-inventory/advisories.js +7 -6
- package/lib/system-inventory/alpine-tracker.js +5 -5
- package/lib/system-inventory/distribution-sources.js +1 -1
- package/package.json +1 -1
- package/vigievuln.js +29 -15
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.1** 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,31 @@
|
|
|
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(dep.ecosystem==='system' || dep.ecosystem==='binary')return 'direct';
|
|
23
|
+
const source=dep.installEvidence?.source;
|
|
24
|
+
if(['pypi','composer','composer-php','ruby','nuget'].includes(source))return 'transitive';
|
|
25
|
+
if(dep.provenance==='binary-module')return dep.binaryEvidence?.original?.kind==='mod'?'direct':'transitive';
|
|
26
|
+
const paths=[dep.artifactPath,dep.installEvidence?.path,...(dep.manifestPaths||[])].filter(Boolean);
|
|
27
|
+
if(paths.some(p=>String(p).includes('!/') || parts(p).some(n=>stores.has(n)) || String(p).replace(/\\/g,'/').includes('usr/share/nodejs/')))return 'transitive';
|
|
28
|
+
return 'direct';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports={IMAGE_COMPONENT_SCOPE,isNpmPackageDescriptor,isProjectDescriptor,imageComponentRole};
|
|
@@ -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,50 @@
|
|
|
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 } = 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.scope = dep.imageRole === 'transitive' ? 'transitive' : 'runtime';
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
result.warnings = (result.warnings || []).filter(w => {
|
|
33
|
+
if (w?.reason === 'installed-metadata-error' && pathsOf(w).some(isFragmentPath)) { filtered = true; return false; }
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
result.coverage = result.coverage || [];
|
|
37
|
+
result.componentCount = result.deps.length;
|
|
38
|
+
if (checkPolicy && (result.metadata?.componentScope !== IMAGE_COMPONENT_SCOPE || filtered)) {
|
|
39
|
+
const existing = result.coverage.find(c => c.collector === 'installed-applications');
|
|
40
|
+
if (existing) {
|
|
41
|
+
if (!['failed', 'partial'].includes(existing.execution)) existing.execution = 'partial';
|
|
42
|
+
existing.result = 'indeterminate';
|
|
43
|
+
existing.reason = SCOPE_MESSAGE;
|
|
44
|
+
} else result.coverage.push({artifactTargetId:result.id,capability:'inventory',collector:'installed-applications',execution:'partial',result:'indeterminate',reason:SCOPE_MESSAGE});
|
|
45
|
+
if (!result.warnings.some(w => w?.reason === SCOPE_REASON))
|
|
46
|
+
result.warnings.push({type:'dependency-coverage',capability:'inventory',reason:SCOPE_REASON,message:SCOPE_MESSAGE});
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
module.exports = { applyComponentScope, SCOPE_REASON, SCOPE_MESSAGE };
|
|
@@ -13,7 +13,7 @@ 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 => !needsAdvisory(dep) || affected.has(componentIdentity(dep)));
|
|
16
|
+
return (artifact.components || []).filter(dep => (['direct','transitive'].includes(dep.imageRole) && !['system','binary'].includes(dep.ecosystem)) || !needsAdvisory(dep) || affected.has(componentIdentity(dep)));
|
|
17
17
|
}
|
|
18
18
|
function reportArtifacts(artifacts, matches) {
|
|
19
19
|
return artifacts.map(artifact => {
|
package/lib/artifacts/report.js
CHANGED
|
@@ -164,11 +164,20 @@ function renderArtifactEvidence(projectInfo = {}, locale = 'en', matches = []) {
|
|
|
164
164
|
// by a finding. Keep its correction, and identify the source of this row.
|
|
165
165
|
for(const [key,findings] of findingIndex)if(!inventoryKeys.has(key)){inventory.push({...findings[0].dep,_fromFinding:true});inventoryKeys.add(key);}
|
|
166
166
|
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
|
-
|
|
167
|
+
const componentRows=items=>items.map(c=>{
|
|
168
|
+
const key=componentIdentity(c),updates=updateIndex.get(key)||[],findings=findingIndex.get(key)||[];
|
|
169
|
+
const fixes=[...new Set(updates.map(u=>u.fix))];
|
|
170
|
+
const advisories=[...new Set(findings.flatMap(m=>[m.advisoryId||m.cve?.id,...linkedCves(m.cve)]).filter(Boolean))];
|
|
171
|
+
const links=advisories.map(id=>/^CVE-\d{4}-\d{4,}$/i.test(id)
|
|
172
|
+
? `<a href="#${anchor}-cves">${esc(id)}</a>`
|
|
173
|
+
: `<a href="${advisoryUrl(id)}">${esc(id)}</a>`).join(', ');
|
|
174
|
+
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
175
|
}).join('');
|
|
176
|
+
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>`;
|
|
177
|
+
const direct=inventory.filter(c=>c.imageRole==='direct'),subdeps=inventory.filter(c=>c.imageRole==='transitive'),unclassified=inventory.filter(c=>!['direct','transitive'].includes(c.imageRole));
|
|
178
|
+
const componentSections=`<h5>${t('Direct image components','Composants directs de l’image')} (${direct.length})</h5>${table(direct)}`+
|
|
179
|
+
`<h5>${t('Image sub-dependencies','Sous-dépendances de l’image')} (${subdeps.length})</h5>${table(subdeps)}`+
|
|
180
|
+
(unclassified.length?`<h5>${t('Unclassified image components','Composants de l’image non classés')} (${unclassified.length})</h5>${table(unclassified)}`:'');
|
|
172
181
|
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
182
|
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
183
|
const noCve=visible(group.matches).filter(m=>m.dep?.ecosystem==='system' && !linkedCves(m.cve).length);
|
|
@@ -183,8 +192,7 @@ function renderArtifactEvidence(projectInfo = {}, locale = 'en', matches = []) {
|
|
|
183
192
|
totalsTable+
|
|
184
193
|
imageAction+
|
|
185
194
|
(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>`;
|
|
195
|
+
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('Libraries are listed with or without findings; system packages and native binaries are detailed when associated with an advisory. Roles describe the image inventory, not project dependency scope.','Les bibliothèques sont listées avec ou sans résultat ; les paquets système et binaires natifs sont détaillés 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
196
|
}).join('');
|
|
189
197
|
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+renderReferences(projectInfo,artifacts,locale);
|
|
190
198
|
}
|
package/lib/artifacts/scan.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require('node:fs');
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const crypto = require('node:crypto');
|
|
6
6
|
const { makeDepRecord } = require('../dep-record');
|
|
7
|
+
const {IMAGE_COMPONENT_SCOPE,imageComponentRole} = require('./component-scope');
|
|
7
8
|
const { openArtifact } = require('./index');
|
|
8
9
|
const { collectInstalledApplications } = require('./applications');
|
|
9
10
|
const { collectSystemInventory, assessSystemInventory, syncSystemAdvisories } = require('../system-inventory');
|
|
@@ -78,6 +79,7 @@ async function inventoryTarget(target, options = {}) {
|
|
|
78
79
|
const owned = evidence && !aggregate ? owners.get(pathKey(evidence)) : null;
|
|
79
80
|
return qualify(owned?.length ? { ...d, osPackageOwners: owned } : d, id);
|
|
80
81
|
})];
|
|
82
|
+
for(const dep of deps){dep.imageRole=imageComponentRole(dep);dep.scope=dep.imageRole==='transitive'?'transitive':'runtime';}
|
|
81
83
|
const warnings = portable(normalizeWarnings([...(system.warnings || []), ...applications.warnings, ...binaries.warnings,
|
|
82
84
|
...(target.metadata.warnings || [])]), target.root);
|
|
83
85
|
const coverage = coverageRecords(system.coverage, id, 'inventory');
|
|
@@ -90,7 +92,7 @@ async function inventoryTarget(target, options = {}) {
|
|
|
90
92
|
const acquisition = options.registry ? { kind: 'registry', reference: source } : {
|
|
91
93
|
kind: target.metadata.format === 'directory' ? 'rootfs-directory' : target.metadata.format === 'oci-layout' && target.metadata.source && fs.statSync(target.metadata.source).isDirectory() ? 'oci-layout' : 'archive', source,
|
|
92
94
|
};
|
|
93
|
-
return { id, kind: target.kind, metadata: { ...target.metadata, source, acquisition, definitions: [], definitionDiscovery: {status:'not-supplied'} },
|
|
95
|
+
return { id, kind: target.kind, metadata: { ...target.metadata, componentScope:IMAGE_COMPONENT_SCOPE, source, acquisition, definitions: [], definitionDiscovery: {status:'not-supplied'} },
|
|
94
96
|
evidence: 'content-inventory', inventoryAt: new Date().toISOString(), distribution: system.distribution,
|
|
95
97
|
packages, deps, coverage, warnings, componentCount: deps.length };
|
|
96
98
|
}
|
|
@@ -134,7 +136,7 @@ function validateSnapshot(doc) {
|
|
|
134
136
|
}
|
|
135
137
|
function readSnapshot(file, options = {}) {
|
|
136
138
|
if (fs.statSync(file).size > (options.maxSnapshotBytes ?? 128 * 1024 * 1024)) throw Error('artifact inventory exceeds configured size limit');
|
|
137
|
-
return validateSnapshot(JSON.parse(fs.readFileSync(file, 'utf8'))).map(t => ({ ...t, evidence: 'cached-inventory', originalEvidence: t.evidence }));
|
|
139
|
+
return validateSnapshot(JSON.parse(fs.readFileSync(file, 'utf8'))).map(t => ({ ...require('./inventory-scope').applyComponentScope(t), evidence: 'cached-inventory', originalEvidence: t.originalEvidence || t.evidence }));
|
|
138
140
|
}
|
|
139
141
|
async function writeSnapshot(file, targets) {
|
|
140
142
|
const absolute = path.resolve(file);
|
|
@@ -154,11 +156,12 @@ async function acquireInventories(input, options = {}) {
|
|
|
154
156
|
if (options.registry && options.offline) {
|
|
155
157
|
const saved = cache.get('image-inventory', cacheKey) || cache.get('image-inventory', legacyCacheKey);
|
|
156
158
|
if (!saved?.value || saved.value.schema !== SNAPSHOT_SCHEMA) throw Error('image inventory is not cached; import an inventory/archive or prepare this reference online');
|
|
157
|
-
const targets = validateSnapshot(saved.value);
|
|
158
|
-
return targets.map(target => ({ ...target, evidence: 'cached-inventory', originalEvidence: target.evidence,
|
|
159
|
+
const targets = validateSnapshot(saved.value).map(require('./inventory-scope').applyComponentScope);
|
|
160
|
+
return targets.map(target => ({ ...target, evidence: 'cached-inventory', originalEvidence: target.originalEvidence || target.evidence,
|
|
159
161
|
warnings: [...target.warnings, { type: 'cached-image-resolution', severity:'info', capability: 'sources', message: 'Using the prepared image digest and inventory offline; the registry tag is not re-resolved in this mode.' }] }));
|
|
160
162
|
}
|
|
161
163
|
const persist = targets => {
|
|
164
|
+
targets = targets.map(require('./inventory-scope').applyComponentScope);
|
|
162
165
|
validateSnapshot(createSnapshot(targets));
|
|
163
166
|
if (cache) cache.put('image-inventory', cacheKey, createSnapshot(targets));
|
|
164
167
|
return targets;
|
|
@@ -171,10 +174,11 @@ async function acquireInventories(input, options = {}) {
|
|
|
171
174
|
} catch { /* Invalid snapshots must be rebuilt from verified content online. */ }
|
|
172
175
|
const digest = targets?.[0]?.metadata?.acquisition?.indexDigest;
|
|
173
176
|
// Publisher SBOMs can be updated independently of the image digest.
|
|
174
|
-
|
|
177
|
+
const scoped = targets?.map(require('./inventory-scope').applyComponentScope);
|
|
178
|
+
if (digest && scoped.every(t => t.evidence === 'content-inventory' && t.metadata?.componentScope === require('./component-scope').IMAGE_COMPONENT_SCOPE && !t.warnings.some(w => w.reason === require('./inventory-scope').SCOPE_REASON) && t.metadata?.acquisition?.indexDigest === digest)) {
|
|
175
179
|
const current = ref.reference.includes(':') ? ref.reference : await require('../image-registry').fetchRegistryDigest(input,
|
|
176
180
|
{...options, fetcher:options.registryFetcher || options.fetcher, limits:options.registryLimits});
|
|
177
|
-
if (current === digest) return
|
|
181
|
+
if (current === digest) return scoped.map(target => ({...target, evidence:'cached-inventory', originalEvidence:target.originalEvidence || target.evidence}));
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
let registry = null, opened = null, sbomAttempt = null;
|
|
@@ -224,12 +228,12 @@ async function acquireInventories(input, options = {}) {
|
|
|
224
228
|
|
|
225
229
|
async function assessInventories(targets, options = {}) {
|
|
226
230
|
options.onArtifactProgress?.({stage:'Component identities'});
|
|
227
|
-
targets=targets.map(target=>
|
|
231
|
+
targets=targets.map(target=>require('./inventory-scope').applyComponentScope(target,{checkPolicy:false}));
|
|
228
232
|
for(const target of targets){
|
|
229
233
|
for(const pkg of target.packages){const origin=require('../system-inventory/distribution-sources').identifyPackageOrigin(pkg,options);if(origin)pkg.packageOrigin=origin;}
|
|
230
234
|
for(const dep of target.deps){const origin=require('../system-inventory/distribution-sources').identifyPackageOrigin(dep,options);if(origin)dep.packageOrigin=origin;}
|
|
231
235
|
const identity=await require('./go-main-identity').resolveGoMainIdentities(target,options);
|
|
232
|
-
for(const dep of identity.deps){const qualified=qualify(dep,target.id);if(!target.deps.some(d=>d.coordKey===qualified.coordKey))target.deps.push(qualified);}
|
|
236
|
+
for(const dep of identity.deps){const qualified=qualify({...dep,imageRole:'direct',scope:'runtime'},target.id);if(!target.deps.some(d=>d.coordKey===qualified.coordKey))target.deps.push(qualified);}
|
|
233
237
|
target.coverage.push({...identity.coverage,artifactTargetId:target.id,capability:'inventory'});
|
|
234
238
|
target.warnings.push(...identity.warnings);
|
|
235
239
|
}
|
|
@@ -274,7 +278,7 @@ async function assessInventories(targets, options = {}) {
|
|
|
274
278
|
}
|
|
275
279
|
for(const warning of nativePreparation.warnings)targetWarnings.push(typeof warning==='string'?{type:'source-unavailable',capability:'sources',message:warning}:{capability:'sources',...warning});
|
|
276
280
|
const nativeUnknown=native.unknown.filter(item=>!item.artifactTargetId||item.artifactTargetId===target.id);
|
|
277
|
-
if(nativeUnknown.length){coverage.push({artifactTargetId:target.id,capability:'sources',collector:'native-comparisons',execution:'
|
|
281
|
+
if(nativeUnknown.length){coverage.push({artifactTargetId:target.id,capability:'sources',collector:'native-comparisons',execution:'completed',result:'indeterminate',affectsCompleteness:false,affectsAssessment:true,count:nativeUnknown.length});targetWarnings.push({...require('../diagnostics').advisoryEvidenceDiagnostic(nativeUnknown),capability:'sources'});}
|
|
278
282
|
if (target.packages.length && options.osv === false) {
|
|
279
283
|
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'system-osv', execution: 'not-applicable', result: 'not-consulted', expected:false, reason: 'OSV is excluded by source configuration.' });
|
|
280
284
|
} else if (target.packages.length) {
|
|
@@ -351,7 +355,7 @@ async function assessInventories(targets, options = {}) {
|
|
|
351
355
|
message:`${path} is covered by its installed OS package ${owner.name}@${owner.version}; no independent Maven identity is declared.`})));
|
|
352
356
|
}
|
|
353
357
|
for (const check of coverage) {
|
|
354
|
-
if (['completed', 'not-applicable'].includes(check.execution)) continue;
|
|
358
|
+
if (check.affectsCompleteness === false || ['completed', 'not-applicable'].includes(check.execution)) continue;
|
|
355
359
|
if (check.collector==='native-binaries' || check.collector==='native-comparisons' || check.collector==='go-main-identity' || check.collector==='system-osv-vendor-scope' || check.issue==='missing-source') continue;
|
|
356
360
|
if (targetWarnings.some(w => w.capability === check.capability && !require('../diagnostics').isInformational(w))) continue;
|
|
357
361
|
targetWarnings.push({ type: check.capability === 'inventory' ? 'dependency-coverage' : 'source-unavailable',
|
|
@@ -362,7 +366,7 @@ async function assessInventories(targets, options = {}) {
|
|
|
362
366
|
originalEvidence: target.originalEvidence, distribution: target.distribution, inventoryAt: target.inventoryAt,
|
|
363
367
|
componentCount: target.deps.length, coverage, advisoryObservations:distribution.observations, components: target.deps.map(d => ({ ecosystem: d.ecosystem, packageType: d.packageType,
|
|
364
368
|
namespace: d.namespace, name: d.name, version: d.version, sourceName:d.sourceName || null, sourceVersion:d.sourceVersion || null, packageOrigin:d.packageOrigin || null, architecture: d.architecture, artifactPath: d.artifactPath,
|
|
365
|
-
provenance: d.provenance, coordKey: d.coordKey, binaryEvidence:d.binaryEvidence, osPackageOwners: d.osPackageOwners || [],
|
|
369
|
+
provenance: d.provenance, imageRole:d.imageRole || null, coordKey: d.coordKey, binaryEvidence:d.binaryEvidence, osPackageOwners: d.osPackageOwners || [],
|
|
366
370
|
purl: require('../purl').purlFor(d) })) });
|
|
367
371
|
}
|
|
368
372
|
const combined=require('../merge-sources').mergeBySource(cveMatches,native.matches);
|
|
@@ -374,9 +378,15 @@ async function assessInventories(targets, options = {}) {
|
|
|
374
378
|
const matches = cveMatches.filter(m => m.dep?.artifactTargetId === artifact.id);
|
|
375
379
|
options.onArtifactProgress?.({stage:'CVE enrichment'});
|
|
376
380
|
const enrichment = await require('./enrichment').enrichArtifactFindings(matches, options);
|
|
377
|
-
|
|
378
|
-
|
|
381
|
+
const recordSources = new Set(['nvd', 'euvd', 'euvd-details']);
|
|
382
|
+
artifact.coverage.push(...enrichment.coverage.map(c => ({ ...c, artifactTargetId: artifact.id,
|
|
383
|
+
...(recordSources.has(c.collector) ? { affectsCompleteness:false,
|
|
384
|
+
diagnostics:enrichment.warnings.filter(w => w.source === c.collector) } : {}) })));
|
|
385
|
+
warnings.push(...enrichment.warnings.filter(w => !recordSources.has(w.source)).map(w => ({ ...w, artifactTargetId: artifact.id })));
|
|
379
386
|
}
|
|
387
|
+
const recordSummary = require('../cve-record-coverage').summarizeCveRecords(cveMatches,
|
|
388
|
+
{ ...options, coverage: artifacts.flatMap(a => a.coverage) });
|
|
389
|
+
if (recordSummary.warning) warnings.push(recordSummary.warning);
|
|
380
390
|
require('../priority').attachPriority(cveMatches);
|
|
381
391
|
const diagnostics=require('../diagnostics').partitionDiagnostics(warnings);
|
|
382
392
|
return { resolvedDeps, cveMatches: require('../finding-summary').uniqueFindings(cveMatches), ...diagnostics, artifacts };
|
|
@@ -387,10 +397,10 @@ function incompleteCapabilities(result, required = ['inventory', 'advisories', '
|
|
|
387
397
|
for (const target of result.artifacts) {
|
|
388
398
|
for (const capability of required) {
|
|
389
399
|
if (capability === 'sources') {
|
|
390
|
-
if (result.warnings.some(w => w.artifactTargetId === target.id && /source|osv/.test(w.type))) gaps.push({ target: target.id, capability });
|
|
400
|
+
if (result.warnings.some(w => w.affectsCompleteness !== false && w.artifactTargetId === target.id && /source|osv/.test(w.type))) gaps.push({ target: target.id, capability });
|
|
391
401
|
} else {
|
|
392
402
|
const records = target.coverage.filter(c => c.capability === capability);
|
|
393
|
-
if (!records.length || records.some(c => !['completed', 'not-applicable'].includes(c.execution))) gaps.push({ target: target.id, capability });
|
|
403
|
+
if (!records.length || records.some(c => c.affectsCompleteness !== false && !['completed', 'not-applicable'].includes(c.execution))) gaps.push({ target: target.id, capability });
|
|
394
404
|
}
|
|
395
405
|
}
|
|
396
406
|
}
|
package/lib/charts.js
CHANGED
|
@@ -484,14 +484,14 @@ function emptyCard(id, title, note) {
|
|
|
484
484
|
/**
|
|
485
485
|
* Build the four-chart "Overview" row. Returns "" when there is nothing to plot.
|
|
486
486
|
*/
|
|
487
|
-
function
|
|
487
|
+
function renderChartsGroup(payload = {}, opts = {}) {
|
|
488
488
|
// Injected by the report so this module needs no i18n dependency of its own; identity
|
|
489
489
|
// by default, which keeps every existing caller and test rendering English.
|
|
490
490
|
const t = typeof opts.t === "function" ? opts.t : EN_T;
|
|
491
491
|
const prod = payload.prodMatches || [];
|
|
492
492
|
const imageMatches = prod.filter(m => !!m.dep?.artifactTargetId);
|
|
493
493
|
const sourceMatches = prod.filter(m => !m.dep?.artifactTargetId);
|
|
494
|
-
const hasImages = imageMatches.length > 0 || (payload.artifacts || []).length > 0;
|
|
494
|
+
const hasImages = !!payload.hasImages || imageMatches.length > 0 || (payload.artifacts || []).length > 0;
|
|
495
495
|
const imageOnly = hasImages && !sourceMatches.length;
|
|
496
496
|
const cweTitle = typeof opts.cweName === "function" ? opts.cweName : cweName;
|
|
497
497
|
// Include direct application and source findings, plus image findings, in the
|
|
@@ -515,7 +515,7 @@ function renderCharts(payload = {}, opts = {}) {
|
|
|
515
515
|
// themes and extensions count as the direct lane, their dependencies as indirect.
|
|
516
516
|
const appChart = appScan ? mostVulnerableApplications(sourceMatches, applications, payload.coverage || [], { t }) : null;
|
|
517
517
|
|
|
518
|
-
if (!(cwe.length || subs.length || scope.length || prio.length || unattr || components.length || (appChart && appChart.rows.length))) return "";
|
|
518
|
+
if (!hasImages && !payload.showEmpty && !(cwe.length || subs.length || scope.length || prio.length || unattr || components.length || (appChart && appChart.rows.length))) return "";
|
|
519
519
|
|
|
520
520
|
const interactive = opts.interactive !== false; // copy button only in the interactive HTML
|
|
521
521
|
|
|
@@ -569,6 +569,23 @@ function renderCharts(payload = {}, opts = {}) {
|
|
|
569
569
|
return `<section class="charts-row" aria-label="${esc(t("Overview charts"))}">${card1}${card2}${card3}${card4}</section>`;
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
+
// Source and image occurrences must stay in separate overview rows, even when
|
|
573
|
+
// the same package and advisory occur in both inventories.
|
|
574
|
+
function renderCharts(payload = {}, opts = {}) {
|
|
575
|
+
const matches = payload.prodMatches || [];
|
|
576
|
+
const source = matches.filter(m => !m.dep?.artifactTargetId);
|
|
577
|
+
const images = matches.filter(m => !!m.dep?.artifactTargetId);
|
|
578
|
+
const hasImages = !!payload.hasImages || images.length > 0 || (payload.artifacts || []).length > 0;
|
|
579
|
+
const sourceRow = payload.hasSourceProject === false ? "" : renderChartsGroup({...payload, prodMatches:source, artifacts:[], hasImages:false, showEmpty:hasImages && payload.hasSourceProject === true}, opts);
|
|
580
|
+
const translate = typeof opts.t === 'function' ? opts.t : EN_T;
|
|
581
|
+
const labelledSource = sourceRow ? `<h2 class="charts-heading">${esc(translate('Project overview'))}</h2>${sourceRow}` : '';
|
|
582
|
+
if (!hasImages) return labelledSource;
|
|
583
|
+
const imageRow = renderChartsGroup({...payload, prodMatches:images, applications:[], moduleNames:new Map(), descriptorCount:0, hasImages:true}, opts)
|
|
584
|
+
.replace(/id="chart-/g, 'id="image-chart-')
|
|
585
|
+
.replace(`aria-label="${esc(translate("Overview charts"))}"`, `aria-label="${esc(translate("Image overview charts"))}"`);
|
|
586
|
+
return labelledSource + `<h2 class="charts-heading">${esc(translate('Image overview'))}</h2>` + imageRow;
|
|
587
|
+
}
|
|
588
|
+
|
|
572
589
|
module.exports = {
|
|
573
590
|
cweByCriticality,
|
|
574
591
|
findingsByImage,
|