vigievuln 1.1.3 → 1.2.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 +26 -0
- package/README.md +50 -127
- package/completions/vigievuln.bash +1 -1
- package/completions/vigievuln.zsh +1 -0
- package/lib/advisory-compression.js +25 -0
- package/lib/advisory-fixes.js +21 -0
- package/lib/advisory-freshness.js +2 -0
- package/lib/advisory-store-sqlite.js +156 -0
- package/lib/advisory-store.js +484 -0
- package/lib/airgap-project.js +117 -0
- package/lib/application-plugins/runner.js +22 -13
- package/lib/application-plugins/wordpress.js +4 -3
- package/lib/application-providers/live-snapshot.js +1 -12
- package/lib/application-providers/snapshot-cache.js +27 -0
- package/lib/application-providers/wordfence-client.js +3 -3
- package/lib/attribution.js +2 -2
- package/lib/cache-archive-sqlite.js +215 -0
- package/lib/cache-archive.js +350 -26
- package/lib/cache-db.js +142 -0
- package/lib/cache-directory.js +18 -74
- package/lib/cache-policy.js +25 -0
- package/lib/cache-repository.js +48 -0
- package/lib/cache-startup.js +54 -0
- package/lib/certfr.js +9 -9
- package/lib/certs/analyze.js +49 -13
- package/lib/cli-command-routing.js +29 -6
- package/lib/cli-groups.js +32 -3
- package/lib/cli-project-commands.js +26 -5
- package/lib/cli-setup.js +300 -0
- package/lib/codecs/binary/pe-metadata.js +105 -0
- package/lib/codecs/binary/scan.js +39 -21
- package/lib/codecs/binary.codec.js +10 -5
- package/lib/codecs/composer/registry.js +8 -6
- package/lib/codecs/go/parse.js +17 -13
- package/lib/codecs/go/registry.js +7 -5
- package/lib/codecs/go.codec.js +28 -6
- package/lib/codecs/maven.codec.js +81 -11
- package/lib/codecs/npm/collect.js +18 -16
- package/lib/codecs/npm/parse.js +12 -5
- package/lib/codecs/npm/registry.js +40 -11
- package/lib/codecs/nuget/parse.js +16 -5
- package/lib/codecs/nuget/registry.js +8 -6
- package/lib/codecs/nuget.codec.js +2 -1
- package/lib/codecs/pypi/parse.js +56 -15
- package/lib/codecs/pypi/registry.js +8 -6
- package/lib/codecs/pypi.codec.js +2 -0
- package/lib/codecs/ruby/registry.js +7 -5
- package/lib/compression-dictionary.js +5 -0
- package/lib/coverage-diagnostics.js +26 -0
- package/lib/csaf-export.js +33 -5
- package/lib/cve-download.js +157 -41
- package/lib/cve-legacy-ranges.js +59 -0
- package/lib/cve-match.js +82 -13
- package/lib/cve-npm-proxy.js +29 -0
- package/lib/cve-report.js +142 -55
- package/lib/cve-version-verdict.js +77 -0
- package/lib/deps-descriptor.js +8 -3
- package/lib/diff.js +0 -0
- package/lib/epss.js +13 -8
- package/lib/euvd.js +32 -8
- package/lib/gcve-feed.js +103 -0
- package/lib/gcve-index.js +181 -0
- package/lib/gcve.js +1 -1
- package/lib/github-publisher-maven.js +40 -0
- package/lib/hash-id.js +5 -5
- package/lib/i18n.js +32 -8
- package/lib/json-cache.js +18 -0
- package/lib/json-export.js +66 -4
- package/lib/kev.js +7 -8
- package/lib/line-stream.js +23 -0
- package/lib/maven-airgap.js +80 -0
- package/lib/maven-cache.js +21 -0
- package/lib/maven-license.js +2 -1
- package/lib/maven-presence.js +2 -2
- package/lib/maven-reactor.js +23 -14
- package/lib/merge-sources.js +25 -18
- package/lib/native-advisories.js +268 -0
- package/lib/nvd-bulk.js +145 -0
- package/lib/nvd-package-ranges.js +109 -0
- package/lib/nvd.js +42 -16
- package/lib/osv-db.js +253 -59
- package/lib/osv-legacy.js +57 -0
- package/lib/osv.js +241 -170
- package/lib/outdated.js +11 -12
- package/lib/package-metadata.js +141 -0
- package/lib/package-versions.js +52 -0
- package/lib/packagist-audit.js +6 -6
- package/lib/provenance.js +73 -19
- package/lib/providers/common.js +11 -1
- package/lib/providers/gcve.js +17 -0
- package/lib/providers/github.js +1 -0
- package/lib/providers/index.js +33 -19
- package/lib/providers/vigievuln.js +7 -0
- package/lib/proxy-cache.js +1 -1
- package/lib/proxy-scope.js +59 -0
- package/lib/resource-cache/engine.js +25 -5
- package/lib/resource-cache/sqlite-store.js +95 -0
- package/lib/resource-cache/validate.js +5 -0
- package/lib/retire.js +24 -24
- package/lib/ruby-version.js +36 -0
- package/lib/sarif-export.js +1 -1
- package/lib/sbom-export.js +17 -7
- package/lib/snyk.js +32 -20
- package/lib/source-profile.js +67 -0
- package/lib/sqlite-driver.js +60 -0
- package/lib/suppress.js +34 -13
- package/lib/transitive.js +69 -34
- package/lib/unmanaged.js +2 -1
- package/lib/vigievuln-advisories.js +47 -0
- package/lib/xlsx-export.js +8 -2
- package/package.json +7 -6
- package/vigievuln.js +433 -136
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog — VigieVuln
|
|
2
2
|
|
|
3
|
+
## [1.2.1] — 2026-11-04
|
|
4
|
+
|
|
5
|
+
- Report unreadable Maven manifests and native binaries as incomplete coverage, preserve other inventory entries, and bound binary hashing and PE metadata reads.
|
|
6
|
+
- Keep JSON source locations relative; preserve Excel workbooks with explicitly truncated oversized cells; report output failures clearly while continuing sibling exports.
|
|
7
|
+
- Recognize ignore-rule advisory aliases, warn about global ignores and mismatched baseline projects, reject future-dated snapshots, and compare npm prereleases correctly.
|
|
8
|
+
- Read certificate signature algorithms structurally and distinguish unknown private-key encryption; suppress only Node's known SQLite initialization notice while preserving other warnings.
|
|
9
|
+
- Require explicit, unambiguous product exemptions in VEX; preserve scoped triage in CSAF and SBOM exports.
|
|
10
|
+
- Fail CI when its baseline cannot be read or a requested report cannot be written; distinguish incomplete reassessment from resolved findings and exclude development dependencies from production-only diffs.
|
|
11
|
+
- Apply Go workspace replacements, preserve conditional Python and NuGet versions, and collect Python dependency groups with explicit coverage warnings.
|
|
12
|
+
- Suggest `vigievuln setup` during direct scans and refresh the committed report samples, terminal demo and screenshots.
|
|
13
|
+
|
|
14
|
+
## [1.2.0] — Unreleased
|
|
15
|
+
|
|
16
|
+
- Match VigieVuln Maven/npm advisories through the configured official proxy and offline cache, including partial ranges and `VV:CVE-…` identifiers.
|
|
17
|
+
- Revalidate local caches after four hours, or on demand with `--force-update`; retain offline snapshots and avoid redownloading unchanged CVE releases.
|
|
18
|
+
- Keep source-wide coverage limits and the Maven depth setting in methodology; report project-specific gaps separately.
|
|
19
|
+
|
|
20
|
+
- Store local advisories, source catalogues, registry answers, resource bodies and proxy caches in SQLite. Bundles carry one preindexed database with compressed advisory bodies and a shared symbol dictionary; the transfer remains gzip-compressed. Old filesystem caches are removed on startup, while configuration and account sessions are preserved. Node.js 22.13+, 23.4+ and 24+ use the built-in SQLite module.
|
|
21
|
+
- Add interactive `setup` for source policies, proxy login and authenticated cache initialisation; existing installations retain unrestricted sources by default.
|
|
22
|
+
- Seed version-independent OSV and GCVE advisory data for matching at scan time, including offline scans, with source provenance and incomplete-coverage warnings.
|
|
23
|
+
- Preserve observed public Maven POMs and npm manifests by version in the seed; refuse conflicting observations and retain existing private repository precedence.
|
|
24
|
+
- Collect independent GCVE records conservatively, preserving typed relationships and reporting only supported package identities and version comparisons.
|
|
25
|
+
- Show unverified PE version metadata in the native-binary inventory and document its CVE correlation limitations.
|
|
26
|
+
- Preserve advisory source attribution through CVEProject, OSV and Snyk merges; use `cache` when the upstream source is unavailable.
|
|
27
|
+
- Avoid treating inclusive affected-version bounds or advisories with no known fix as verified remediation targets.
|
|
28
|
+
|
|
3
29
|
## [1.1.3] — 2026-10-29
|
|
4
30
|
|
|
5
31
|
- Reuse fresh proxy-confirmed responses locally for up to one hour, and preserve stale-source warnings when refresh fails.
|
package/README.md
CHANGED
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
|
|
13
13
|
**VigieVuln** is a polyglot dependency auditor built for **professional code audits**.
|
|
14
14
|
|
|
15
|
-
It scans
|
|
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
|
|
|
17
17
|
|
|
18
18
|
🌐 **[Project site & docs →](https://9pings.github.io/VigieVuln/)**
|
|
19
19
|
|
|
20
|
-
*Terminal demo recorded with VigieVuln 1.
|
|
20
|
+
*Terminal demo recorded with VigieVuln 1.2.1.*
|
|
21
21
|
|
|
22
22
|
<p align="center"><img src="docs/assets/demo.gif" alt="vigievuln animated terminal demo: an offline Maven audit — dependencies absent from Maven Central flagged as private/internal, the compact single-line vulnerability-database progress, then findings coloured by severity" height="500"></p>
|
|
23
23
|
|
|
24
24
|
## Features
|
|
25
25
|
|
|
26
|
-
- **
|
|
26
|
+
- **Multiple ecosystems in one pass**: Maven and Gradle, npm/Yarn/pnpm, Composer, PyPI, NuGet, Go and Ruby — plus **vendored JS**, committed **native binaries** and **embedded JARs**.
|
|
27
27
|
- **No build tools**; No `mvn`/`gradle`/`npm`/`pip`/`dotnet`/`go`, no `node_modules/` → [how](docs/COMPARISON.md#how-its-autonomous-no-build-tools)
|
|
28
28
|
- **CVE from multiple sources, merged & prioritised**; CVEProject + OSV.dev + Packagist security advisories + NVD, ranked **CISA KEV → EPSS → CVSS**.
|
|
29
|
-
- **European references
|
|
29
|
+
- **European vulnerability references**: ENISA **EUVD** id + ENISA's exploited flag, **GCVE** id, and the **CERT-FR** advisories citing it. Hosted proxy lookups send relevant CVE identifiers to the proxy.
|
|
30
30
|
- **Beyond CVEs**; Report **EOL and out-of-active-support** frameworks, deprecated/abandoned/yanked, outdated, SPDX **licenses**, and **private/internal packages**
|
|
31
31
|
- **CMS & frameworks audited as instances**; Symfony, Laravel, WordPress, Drupal, Joomla, PrestaShop, TYPO3, Magento/Adobe Commerce and SPIP with per-instance inventory (core, plugins, themes, bundles, components) → [the dedicated guide](docs/CMS-FRAMEWORKS.md)
|
|
32
32
|
- **Crypto material**; committed **certificates**, **private vs public keys** across PEM/OpenSSH/PuTTY/PGP and JKS/PKCS#12 keystores.
|
|
@@ -54,67 +54,48 @@ A free [NVD API key](https://nvd.nist.gov/developers/request-an-api-key) (instan
|
|
|
54
54
|
|
|
55
55
|
### Monitor a project
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
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.
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
|
-
vigievuln login
|
|
61
|
-
vigievuln
|
|
62
|
-
vigievuln watch ./project --name 'My Project'
|
|
63
|
-
vigievuln project status
|
|
64
|
-
vigievuln logout
|
|
60
|
+
vigievuln login # sign in and accept the terms
|
|
61
|
+
vigievuln watch ./project --export deps.json # optional: review the inventory locally
|
|
62
|
+
vigievuln watch ./project --name 'My Project' # upload or update the project
|
|
63
|
+
vigievuln project status # check the monitoring status
|
|
65
64
|
```
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
The free tier watches **one project, up to 100 direct dependencies and a 0.5 MB descriptor**, for **one month renewed by each upload**; expiry deletes the monitoring data and triggers an email.
|
|
70
|
-
|
|
71
|
-
If the current terms have not been accepted, the CLI displays their link and asks for explicit acceptance in an interactive terminal. For non-interactive use, run `vigievuln login` interactively and accept the terms first.
|
|
72
|
-
|
|
73
|
-
To review the inventory before uploading, export it locally:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
vigievuln watch ./project --export fichier.json
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
`--export` writes an offline descriptor without uploading; review package names and versions, including private packages, before sharing it.
|
|
80
|
-
|
|
81
|
-
Enable alerts in your account to receive new high, critical or known exploited vulnerabilities affecting your direct dependencies; refresh the inventory when dependencies change. [Monitoring guide](docs/USAGE.md#project-monitoring).
|
|
82
|
-
|
|
83
|
-
Existing commands remain supported: `vigievuln -s ./code`, `auth login|status|logout`, `--prepare-project` and `project push`.
|
|
66
|
+
Review the inventory before sharing, enable alerts in your account and upload again when dependencies change. The free tier covers one project, 100 direct coordinates and a 0.5 MB descriptor; each upload renews monitoring for one month. [Monitoring guide](docs/USAGE.md#project-monitoring).
|
|
84
67
|
|
|
85
68
|
### Official Vigie Vuln proxy cache
|
|
86
69
|
|
|
87
|
-
[Vigie Vuln DB](https://www.vigievuln.fr/)
|
|
88
|
-
|
|
89
|
-
Configure the proxy once, then sign in with your verified [Vigie Vuln account](https://www.vigievuln.fr/account) when prompted:
|
|
70
|
+
Use [Vigie Vuln DB](https://www.vigievuln.fr/) as a European-hosted source for scans, including reviewed VigieVuln advisories for Maven and npm.
|
|
90
71
|
|
|
91
72
|
```bash
|
|
92
|
-
vigievuln login
|
|
93
|
-
vigievuln scan ./code
|
|
73
|
+
vigievuln login # sign in and select the official proxy if none is configured
|
|
74
|
+
vigievuln scan ./code # scan using the saved proxy and key
|
|
75
|
+
vigievuln setup --mode direct --sources all # switch back to direct sources
|
|
94
76
|
```
|
|
95
77
|
|
|
96
|
-
The
|
|
78
|
+
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).
|
|
97
79
|
|
|
98
80
|
### Interactive HTML samples
|
|
99
81
|
|
|
100
|
-
- **[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.1
|
|
82
|
+
- **[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.
|
|
101
83
|
- **[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.
|
|
102
84
|
|
|
103
|
-
These are standalone reports from real source scans, generated on **2026-
|
|
85
|
+
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).
|
|
104
86
|
|
|
105
87
|
> [!WARNING]
|
|
106
88
|
> vigievuln is new and may still contain ( rare ) bugs. Treat its output as a strong first pass, **double-check anything critical**, and please [report issues](https://github.com/9pings/VigieVuln/issues); they get fixed fast.
|
|
107
89
|
|
|
108
90
|
## Why use vigievuln for code audits?
|
|
109
91
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
checkable.
|
|
92
|
+
An author-maintained comparison of audit workflows; see [`docs/COMPARISON.md`](docs/COMPARISON.md)
|
|
93
|
+
for versions, sources and limitations. `⚠️` indicates partial or conditional support.
|
|
113
94
|
|
|
114
|
-
| What an auditor actually needs to do | **
|
|
95
|
+
| What an auditor actually needs to do | **VigieVuln** | OSV | Trivy | Grype+Syft | OWASP DC | Snyk |
|
|
115
96
|
| ------------------------------------------------------------------------------------------ | :-: | :-: | :-: | :-: | :-: | :-: |
|
|
116
97
|
| Audit a **100-module polyglot monorepo in one command**, with **no toolchain installed** | ✅ 105 modules | ⚠️ reactor skipped | ⚠️ needs `~/.m2` | ⚠️ opt-in | ⚠️ Java build | ⚠️ `mvn` build |
|
|
117
|
-
| **Scan offline / air-gapped
|
|
98
|
+
| **Scan offline / air-gapped with cached data** | ⚠️ cached metadata | ⚠️ limited | ⚠️ `~/.m2` | ⚠️ opt-in | ⚠️ mirror | ❌ |
|
|
118
99
|
| **Identify the private/internal deps** across a big project | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
119
100
|
| **Extract cleaned deps descriptors** into an external directory | ✅ `-t` | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
120
101
|
| **Report EOL / deprecated frameworks & deps**, transitive ones included | ✅ | ⚠️ deprecated only | ⚠️ OS distros only | ❌ | ❌ | ⚠️ web UI only |
|
|
@@ -129,19 +110,21 @@ checkable.
|
|
|
129
110
|
| **Share one cache across the fleet**, API keys server-side | ✅ `serve-cache` | ❌ | ⚠️ local DB | ⚠️ local DB | ⚠️ local DB | ⚠️ cloud |
|
|
130
111
|
|
|
131
112
|
|
|
113
|
+
Offline dependency resolution depends on cached metadata. In the Dubbo test, a cold advisory seed alone produced 185 groups versus 734 with warm metadata and reported missing POMs; see the [benchmark](docs/BENCHMARK.md) for scope and warnings.
|
|
114
|
+
|
|
132
115
|
**Deliberately not a goal: reachability.** A finding is a vulnerable version on the dependency
|
|
133
116
|
graph, and the report says exactly that (in Methodology) instead of guessing at call paths. Deciding
|
|
134
117
|
whether the vulnerable code is reachable in *this* application is the auditor's call, made with
|
|
135
118
|
application context no scanner has.
|
|
136
119
|
|
|
137
|
-
## More
|
|
120
|
+
## More examples
|
|
138
121
|
|
|
139
122
|
```bash
|
|
140
123
|
vigievuln -s ./proj -e "^com\.acme\." # exclude private libs (coord regex)
|
|
141
124
|
vigievuln -s ./proj -t ../clean -e "^com\.acme\." # extract only: normalised descriptors, private modules flagged
|
|
142
125
|
vigievuln -s ./proj -t ../clean -e "^com\.acme\." -a snyk # same extraction + scan + merge Snyk
|
|
143
126
|
vigievuln -s ./proj --offline # fully offline (zero network, needs a warmed cache)
|
|
144
|
-
vigievuln -s ./proj -a osv-db,typosquat #
|
|
127
|
+
vigievuln -s ./proj -a osv-db,typosquat # OSV advisory matching + typosquat
|
|
145
128
|
vigievuln -s ./proj -a licenses --fail-on high # license chapter + CI gate
|
|
146
129
|
vigievuln -s ./proj --report-json --baseline last.json --fail-on-new # differential audit: fail CI on NEW findings
|
|
147
130
|
vigievuln diff last.json this.json # standalone diff of two findings JSONs
|
|
@@ -151,9 +134,10 @@ vigievuln -s ./site --app-plugins wordpress --private-component wp-content/plugi
|
|
|
151
134
|
|
|
152
135
|
> [!IMPORTANT]
|
|
153
136
|
> **`--offline` reads the cache, it doesn't replace it.** On a *cold* cache there is nothing to
|
|
154
|
-
> match against
|
|
155
|
-
>
|
|
156
|
-
>
|
|
137
|
+
> match against; an empty report is not evidence that the project is clean. Initialise it from
|
|
138
|
+
> a seed or warm it online, then review coverage and freshness warnings in the offline report.
|
|
139
|
+
> Cached advisories can match other applicable versions, but neither a partial cache nor an
|
|
140
|
+
> old snapshot guarantees complete or current results.
|
|
157
141
|
> Air-gapped machines get their cache via [`--export-cache` / `--import-cache`](#air-gapped-audits).
|
|
158
142
|
|
|
159
143
|
## What it finds
|
|
@@ -165,7 +149,7 @@ The report keeps the six root chapters. Sub-chapters appear only when they conta
|
|
|
165
149
|
| **0. Warnings** *(top)* | local heuristics | Missing lockfiles, unresolved Maven versions (BOM-managed), private packages absent from configured registries |
|
|
166
150
|
| **Δ. 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 |
|
|
167
151
|
| **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) |
|
|
168
|
-
| **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`)
|
|
152
|
+
| **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 |
|
|
169
153
|
| **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) |
|
|
170
154
|
| **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 |
|
|
171
155
|
| **5. Fix Recommendations** | computed | Per-ecosystem pin recipes: Maven `<dependencyManagement>`, Gradle `constraints { }`, npm `overrides`, yarn `resolutions`, `composer require`, `pip install`, `dotnet add package` |
|
|
@@ -195,85 +179,25 @@ vigievuln doesn't just read the `composer.json` under a WordPress or Drupal site
|
|
|
195
179
|
| **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 |
|
|
196
180
|
| **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` |
|
|
197
181
|
|
|
198
|
-
Every advisory snapshot a live lane fetches is stamped and cached in
|
|
182
|
+
Every advisory snapshot a live lane fetches is stamped and cached in the local SQLite database, **prepared from the air-gapped descriptor** by `cache prepare`, and reused automatically offline — the Wordfence API key never travels to the enclave. 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)
|
|
199
183
|
|
|
200
184
|
## Air-gapped audits
|
|
201
185
|
|
|
202
|
-
|
|
203
|
-
> whatsoever**; it reads only the warmed `~/.vigie-vuln/` caches and never transmits a
|
|
204
|
-
> dependency, path or finding off the machine. It is regression-tested
|
|
205
|
-
> (`test/offline-guarantee.test.js`, a tripwire fetcher that throws if touched) and
|
|
206
|
-
> auditor-reproducible: `unshare -rn node vigievuln.js -s ./proj --offline …` runs it in a
|
|
207
|
-
> namespace with **no network interface** and yields byte-identical findings. Unlike the
|
|
208
|
-
> mainstream OSS scanners, fad also resolves the **Maven transitive graph** offline; so on
|
|
209
|
-
> an air-gapped multi-module project it finds the transitive CVEs they can't.
|
|
210
|
-
|
|
211
|
-
When the audited system is **offline / confidential** (typical of a regulated or air-gapped audit) it
|
|
212
|
-
can't reach OSV / NVD / Maven Central / npm. Split the work across machines using a
|
|
213
|
-
descriptor of **dependency coordinates and filtered version hints**, with manifest paths
|
|
214
|
-
and registry URLs removed. Offline collection cannot distinguish private package names
|
|
215
|
-
from public ones: exclude internal dependencies and review the descriptor, including
|
|
216
|
-
parent/BOM coordinates, before transfer. The **detailed report is produced back on the
|
|
217
|
-
offline machine**.
|
|
218
|
-
|
|
219
|
-
The transfer relies on a property of vigievuln's caches: they are keyed by *coordinate*
|
|
220
|
-
or *vuln id*, never by path, so they are **machine-independent**. The online step just
|
|
221
|
-
**warms the caches**; the offline step replays the scan and gets cache hits.
|
|
186
|
+
Scan a confidential or disconnected project by preparing its advisory and dependency cache on an online machine. The source code and detailed report stay offline.
|
|
222
187
|
|
|
223
188
|
```bash
|
|
224
|
-
#
|
|
225
|
-
# Exclude private/internal packages with -e (offline we can't tell private from public).
|
|
189
|
+
# Offline: export coordinates, excluding internal packages; review before transfer
|
|
226
190
|
vigievuln -s ./proj -e "^(client|internal)\." --export-anonymized deps.json
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
vigievuln
|
|
234
|
-
|
|
235
|
-
# ── Phase 3; OFFLINE (audited machine): full report, all local context ──
|
|
236
|
-
vigievuln --import-cache fad-cache.tar.gz # merged into the enclave's own cache
|
|
237
|
-
vigievuln -s ./proj --offline # re-collect locally (real paths) + cache hits
|
|
238
|
-
# → full HTML/.doc report with manifests & structure, generated inside the enclave.
|
|
239
|
-
# CMS advisory snapshots (Drupal/PrestaShop/TYPO3 feeds, WP checksums) fetched live by
|
|
240
|
-
# the online phase ride the same archive and are consumed automatically — no flags.
|
|
191
|
+
|
|
192
|
+
# Online: prepare a project-specific cache from the reviewed descriptor
|
|
193
|
+
vigievuln cache prepare deps.json --output vigievuln-cache.tar.gz
|
|
194
|
+
|
|
195
|
+
# Offline: import the cache and generate the report locally
|
|
196
|
+
vigievuln --import-cache vigievuln-cache.tar.gz
|
|
197
|
+
vigievuln -s ./proj --offline
|
|
241
198
|
```
|
|
242
199
|
|
|
243
|
-
|
|
244
|
-
`--no-all-libs` is set). Legacy negative presence entries are discarded automatically:
|
|
245
|
-
older versions could confuse network errors with missing packages. Until verified
|
|
246
|
-
online, those entries remain **unknown**, including after a cache merge. Other warmed
|
|
247
|
-
analysis data is retained.
|
|
248
|
-
|
|
249
|
-
Unverified empty OSV cache entries are not trusted, because a failed request may have
|
|
250
|
-
been stored as “no vulnerabilities”. Re-warm and export the cache to verify these entries; until then offline reports warn about incomplete
|
|
251
|
-
OSV coverage. Existing cached advisory IDs remain usable. Offline KEV and binary identity
|
|
252
|
-
lookups reuse the last available snapshot even after 24 hours, without changing its date.
|
|
253
|
-
|
|
254
|
-
To reproduce the Docker integration check, run `node scripts/test-offline-docker.cjs`
|
|
255
|
-
with dependencies installed and the `node:22-bookworm` image available locally
|
|
256
|
-
(`FAD_DOCKER_IMAGE` overrides it). It exports a small public Maven fixture offline,
|
|
257
|
-
warms real registries/OSV/NVD/EPSS/KEV online, then imports the archive and scans the
|
|
258
|
-
source in a fresh container with `--network none`. It checks direct/transitive findings,
|
|
259
|
-
all seven report formats, the expired-KEV gate and zero attempted offline network calls.
|
|
260
|
-
No host cache is mounted. The full CVE index, EUVD and CERT-FR downloads are excluded
|
|
261
|
-
from this focused check; logs and reports are retained in the printed temporary directory.
|
|
262
|
-
|
|
263
|
-
What the descriptor (`fad-deps/1`) contains vs. drops:
|
|
264
|
-
|
|
265
|
-
| Kept (needed to scan) | Dropped (environment) |
|
|
266
|
-
| --- | --- |
|
|
267
|
-
| ecosystem, ecosystemType | manifest paths / pom paths |
|
|
268
|
-
| namespace, name | resolved registry URLs |
|
|
269
|
-
| version, versions | integrity hashes |
|
|
270
|
-
| scope, isDev | parent chains, lockfile type |
|
|
271
|
-
| application type + core version + inventoried **public** component identities | private component identities |
|
|
272
|
-
|
|
273
|
-
The online phase report is itself path-free; vendored-JavaScript (retire.js) findings are
|
|
274
|
-
produced **offline in phase 3**, since retire needs the actual `.js` files; its signature
|
|
275
|
-
DB is warmed online (phase 2) and carried by `--export-cache`. Full offline/cache control →
|
|
276
|
-
[`docs/USAGE.md`](docs/USAGE.md).
|
|
200
|
+
Review the descriptor before sharing and the report's coverage and freshness information after scanning. An incomplete or outdated cache can limit results. [Offline workflow and cache options](docs/USAGE.md).
|
|
277
201
|
|
|
278
202
|
## Docs
|
|
279
203
|
|
|
@@ -281,27 +205,26 @@ DB is warmed online (phase 2) and carried by `--export-cache`. Full offline/cach
|
|
|
281
205
|
- [`docs/CMS-FRAMEWORKS.md`](docs/CMS-FRAMEWORKS.md); the CMS/framework instance view: detection markers, per-product advisory lanes, coverage semantics and the air-gapped workflow.
|
|
282
206
|
- [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md); internals: codecs, collection, matching, report pipeline.
|
|
283
207
|
- [`docs/COMPARISON.md`](docs/COMPARISON.md); vs OSV-Scanner / Trivy / Grype / OWASP DC / Snyk, and how it stays build-free.
|
|
284
|
-
- [`docs/BENCHMARK.md`](docs/BENCHMARK.md) —
|
|
208
|
+
- [`docs/BENCHMARK.md`](docs/BENCHMARK.md) — dated scanner comparisons on pinned projects, including warm and cold offline limitations.
|
|
285
209
|
- [`docs/DATA-SOURCES.md`](docs/DATA-SOURCES.md); the public datasets vigievuln uses + their licenses.
|
|
286
|
-
- [`CHANGELOG.md`](CHANGELOG.md) · [`CLAUDE.md`](
|
|
210
|
+
- [`CHANGELOG.md`](CHANGELOG.md) · [`CLAUDE.md`](CLAUDE.md); release history · code-level orientation for contributors.
|
|
287
211
|
|
|
288
212
|
## Contributing
|
|
289
213
|
|
|
290
214
|
The most useful contribution to a young scanner is **telling it where it's wrong**: run it on a
|
|
291
215
|
real project and file a [false positive / false negative report](https://github.com/9pings/VigieVuln/issues/new?template=false_positive.yml)
|
|
292
216
|
with the coordinate and the manifest snippet that produced it. Dev setup, ground rules and the
|
|
293
|
-
codec extension point → [`CONTRIBUTING.md`](
|
|
294
|
-
itself → [`SECURITY.md`](
|
|
217
|
+
codec extension point → [`CONTRIBUTING.md`](CONTRIBUTING.md). Vulnerabilities in vigievuln
|
|
218
|
+
itself → [`SECURITY.md`](SECURITY.md) (please report privately).
|
|
295
219
|
|
|
296
|
-
**On AI assistance:** this codebase is written with heavy use of Claude Code; [`CLAUDE.md`](
|
|
220
|
+
**On AI assistance:** this codebase is written with heavy use of Claude Code; [`CLAUDE.md`](CLAUDE.md)
|
|
297
221
|
in the repo root is exactly what it looks like. The bar it's held to is the one you can check
|
|
298
|
-
yourself:
|
|
299
|
-
|
|
300
|
-
than asserted. `vigievuln` itself uses **no LLM at runtime**; findings come from public
|
|
222
|
+
yourself: the test suite (`npm test`), the zero-network guarantee enforced by a tripwire test and
|
|
223
|
+
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
|
|
301
224
|
vulnerability databases and deterministic parsers, and no report text is generated. Full
|
|
302
225
|
statement, including where review actually caught a bad finding →
|
|
303
|
-
[`AI_POLICY.md`](
|
|
226
|
+
[`AI_POLICY.md`](AI_POLICY.md). Where the code doesn't meet that bar, that's a bug report I want.
|
|
304
227
|
|
|
305
228
|
## License
|
|
306
229
|
|
|
307
|
-
|
|
230
|
+
Apache-2.0; see [`LICENSE`](LICENSE).
|
|
@@ -6,7 +6,7 @@ _fad_check_complete() {
|
|
|
6
6
|
COMPREPLY=()
|
|
7
7
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
8
8
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
9
|
-
opts="--vigievuln-proxy --proxy-cache --proxy-cache-token --src --target --exclude --verbose --no-report --no-transitive --no-all-libs --no-osv --no-nvd --no-epss --no-kev --licenses --no-retire --retire-refresh --report-output --report-html --report-doc --report-xlsx --report-sbom --report-csaf --report-json --report-sarif --fail-on --fail-on-new --baseline --no-checksums --ignore --vex --ignore-test --cve-refresh --cve-offline --snyk --transitive-depth --offline --ecosystem --no-maven --no-npm --no-yarn --no-nuget --no-composer --no-pypi --no-go --no-ruby --no-jars --no-binaries --no-certs --cert-expiry-days --retries --no-nvd-mirror --eol-support --no-eol --no-js --set-nvd-key --show-config --completion --help --version --disable --activate --report --help-all -s -t -e -h -v -d -a -r -o"
|
|
9
|
+
opts="--vigievuln-proxy --proxy-cache --proxy-cache-token --src --target --exclude --verbose --force-update --no-report --no-transitive --no-all-libs --no-osv --no-nvd --no-epss --no-kev --licenses --no-retire --retire-refresh --report-output --report-html --report-doc --report-xlsx --report-sbom --report-csaf --report-json --report-sarif --fail-on --fail-on-new --baseline --no-checksums --ignore --vex --ignore-test --cve-refresh --cve-offline --snyk --transitive-depth --offline --ecosystem --no-maven --no-npm --no-yarn --no-nuget --no-composer --no-pypi --no-go --no-ruby --no-jars --no-binaries --no-certs --cert-expiry-days --retries --no-nvd-mirror --eol-support --no-eol --no-js --set-nvd-key --show-config --completion --help --version --disable --activate --report --help-all -s -t -e -h -v -d -a -r -o"
|
|
10
10
|
case "$prev" in
|
|
11
11
|
--src|-s|--target|-t|--report-output|-o)
|
|
12
12
|
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
@@ -16,6 +16,7 @@ _fad_check() {
|
|
|
16
16
|
'--allLibs[query Maven Central]'
|
|
17
17
|
'-v[verbose]'
|
|
18
18
|
'--verbose[verbose]'
|
|
19
|
+
'--force-update[revalidate online sources]'
|
|
19
20
|
'--test[read-only]'
|
|
20
21
|
'--report[generate CVE/EOL/obsolete report]'
|
|
21
22
|
'--report-output[base dir for default-named outputs]:directory:_directories'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const zlib = require('node:zlib');
|
|
4
|
+
const { DICTIONARY } = require('./compression-dictionary');
|
|
5
|
+
|
|
6
|
+
const MAX_BYTES = 16 * 1024 * 1024;
|
|
7
|
+
|
|
8
|
+
function compress(bytes) {
|
|
9
|
+
if (bytes.length < 1 || bytes.length > MAX_BYTES) throw new Error('advisory body exceeds SQLite cache limit');
|
|
10
|
+
return zlib.deflateRawSync(bytes, { level: 1, dictionary: DICTIONARY });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function decompress(compressed, expectedBytes) {
|
|
14
|
+
if (!Number.isSafeInteger(expectedBytes) || expectedBytes < 1 || expectedBytes > MAX_BYTES) {
|
|
15
|
+
throw new Error('invalid advisory body size');
|
|
16
|
+
}
|
|
17
|
+
const body = zlib.inflateRawSync(Buffer.from(compressed), {
|
|
18
|
+
dictionary: DICTIONARY,
|
|
19
|
+
maxOutputLength: expectedBytes,
|
|
20
|
+
});
|
|
21
|
+
if (body.length !== expectedBytes) throw new Error('advisory body size mismatch');
|
|
22
|
+
return body;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = { compress, decompress };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// A shared alias does not prove that two advisories describe identical affected
|
|
4
|
+
// ranges. Without all native ranges at this reporting boundary, require agreement
|
|
5
|
+
// between evaluated targets rather than guessing a maximum/minimum version.
|
|
6
|
+
function mergeAdvisoryFixes(left, right) {
|
|
7
|
+
const candidates = [...new Set([...(left._fixCandidates || []), ...(right._fixCandidates || []), left.fixVersion, right.fixVersion].filter(value => typeof value === 'string' && value))];
|
|
8
|
+
const unknown = left.fixEvaluation === 'unknown' || right.fixEvaluation === 'unknown';
|
|
9
|
+
const conflict = left.fixConflict || right.fixConflict ||
|
|
10
|
+
(candidates.length > 1 ? 'inconsistent-advisory-targets' : candidates.length && unknown ? 'unverified-advisory' : null);
|
|
11
|
+
if (conflict) return { fixVersion: null, fixEvidence: undefined, branchFix: undefined, fixEvaluation: 'unknown', fixConflict: conflict, _fixCandidates: candidates };
|
|
12
|
+
const fixVersion = candidates[0] || null;
|
|
13
|
+
const result = { fixVersion, _fixCandidates: candidates };
|
|
14
|
+
if (fixVersion && [left, right].some(c => c.fixVersion === fixVersion && c.fixEvidence === 'explicit-unaffected-version')) result.fixEvidence = 'explicit-unaffected-version';
|
|
15
|
+
if (unknown) result.fixEvaluation = 'unknown';
|
|
16
|
+
else if (left.fixEvaluation === 'verified' || right.fixEvaluation === 'verified') result.fixEvaluation = 'verified';
|
|
17
|
+
if (left.branchFix || right.branchFix) result.branchFix = require('./maven-version').stricterBranchFix(left.branchFix, right.branchFix);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { mergeAdvisoryFixes };
|
|
@@ -27,6 +27,8 @@ function assertFresh(snapshot, label, maxAgeMs, nowMs = Date.now()) {
|
|
|
27
27
|
if (!collectedAt) throw new Error(`${label} snapshot does not declare its collection date; `
|
|
28
28
|
+ `add _fadSnapshot.collectedAt (ISO 8601) or a top-level collectedAt/generatedAt to the snapshot file`);
|
|
29
29
|
const ageMs = nowMs - collectedAt.getTime();
|
|
30
|
+
// Allow modest clock skew, consistently with the advisory cache validators.
|
|
31
|
+
if (ageMs < -5 * 60 * 1000) throw new Error(`${label} snapshot collection date ${collectedAt.toISOString()} is in the future; check the snapshot timestamp and system clock`);
|
|
30
32
|
if (ageMs > maxAgeMs) throw new Error(`${label} snapshot collected at ${collectedAt.toISOString()} is stale: `
|
|
31
33
|
+ `age ${Math.round(ageMs / 3600000)}h exceeds --max-advisory-age ${Math.round(maxAgeMs / 3600000)}h`);
|
|
32
34
|
return { collectedAt: collectedAt.toISOString() };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs=require('node:fs');
|
|
4
|
+
const path=require('node:path');
|
|
5
|
+
const {openCacheDb}=require('./cache-db');
|
|
6
|
+
const {compress,decompress}=require('./advisory-compression');
|
|
7
|
+
const rules=require('./advisory-store');
|
|
8
|
+
const {validateRecord,validateQuery,validateCoverage,packageName,packageKeys,queryKey,coverageKey,advisoryId,queryCoversRecord,isWithdrawn,revision,wins,hash,key}=rules;
|
|
9
|
+
const DEFAULT_QUERY_TTL_MS=4 * 3600e3;
|
|
10
|
+
const parse=value=>JSON.parse(value);
|
|
11
|
+
const text=value=>JSON.stringify(value);
|
|
12
|
+
|
|
13
|
+
class SqliteAdvisoryStore {
|
|
14
|
+
constructor({cacheDir=require('./cache-directory').getCacheDir()}={}){
|
|
15
|
+
this.cacheDir=cacheDir;
|
|
16
|
+
this.db=openCacheDb({cacheDir});
|
|
17
|
+
}
|
|
18
|
+
close(){this.db.close()}
|
|
19
|
+
_rowRecord(source,id){return this.db.prepare('SELECT * FROM advisory_records WHERE source=? AND id=?').get(source,id)||null}
|
|
20
|
+
_record(source,id){
|
|
21
|
+
const row=this._rowRecord(source,id);if(!row)return null;
|
|
22
|
+
const body=decompress(row.envelope_deflate,row.envelope_bytes);
|
|
23
|
+
const record=parse(body.toString('utf8'));validateRecord(record);
|
|
24
|
+
if(record.source!==source||advisoryId(record)!==id||hash(text(record.document))!==row.document_sha256)throw Error('advisory record integrity mismatch');
|
|
25
|
+
const observations=this.db.prepare('SELECT fetched_at,provenance_json FROM advisory_observations WHERE source=? AND id=? ORDER BY provenance_key').all(source,id).map(x=>({fetchedAt:x.fetched_at,provenance:parse(x.provenance_json)}));
|
|
26
|
+
return {...record,contentChangedAt:row.content_changed_at,observations};
|
|
27
|
+
}
|
|
28
|
+
_putRecord(record){
|
|
29
|
+
const source=record.source,id=advisoryId(record),previous=this._record(source,id);
|
|
30
|
+
const winner=wins(record,previous);
|
|
31
|
+
if(winner){
|
|
32
|
+
const documentHash=hash(text(record.document));
|
|
33
|
+
const changedAt=previous&&hash(text(previous.document))===documentHash?previous.contentChangedAt:record.fetchedAt;
|
|
34
|
+
const encoded=Buffer.from(text(record));
|
|
35
|
+
if(encoded.length>16777216)throw Error('advisory record exceeds SQLite cache limit');
|
|
36
|
+
this.db.prepare(`INSERT INTO advisory_records(source,id,revision_ms,withdrawn,fetched_at,content_changed_at,document_sha256,envelope_deflate,envelope_bytes)
|
|
37
|
+
VALUES (?,?,?,?,?,?,?,?,?) ON CONFLICT(source,id) DO UPDATE SET revision_ms=excluded.revision_ms,
|
|
38
|
+
withdrawn=excluded.withdrawn,fetched_at=excluded.fetched_at,content_changed_at=excluded.content_changed_at,
|
|
39
|
+
document_sha256=excluded.document_sha256,envelope_deflate=excluded.envelope_deflate,envelope_bytes=excluded.envelope_bytes`).run(source,id,revision(record),isWithdrawn(record)?1:0,record.fetchedAt,changedAt,documentHash,compress(encoded),encoded.length);
|
|
40
|
+
this.db.prepare('DELETE FROM advisory_packages WHERE source=? AND id=?').run(source,id);
|
|
41
|
+
const insert=this.db.prepare('INSERT INTO advisory_packages(ecosystem,name_key,source,id) VALUES (?,?,?,?)');
|
|
42
|
+
for(const identity of packageKeys(record)){const [ecosystem,nameKey]=parse(identity);insert.run(ecosystem,nameKey,source,id)}
|
|
43
|
+
}
|
|
44
|
+
const provenance=record.provenance||{};
|
|
45
|
+
this.db.prepare(`INSERT INTO advisory_observations(source,id,provenance_key,fetched_at,provenance_json)
|
|
46
|
+
VALUES (?,?,?,?,?) ON CONFLICT(source,id,provenance_key) DO UPDATE SET fetched_at=max(fetched_at,excluded.fetched_at)`).run(source,id,hash(text(provenance)),record.fetchedAt,text(provenance));
|
|
47
|
+
}
|
|
48
|
+
_putQuery(query){
|
|
49
|
+
const source=query.source,ecosystem=query.ecosystem,nameKey=ecosystem==='Maven'?query.name:packageName(ecosystem,query.name),version=query.version;
|
|
50
|
+
const previous=this.db.prepare('SELECT fetched_at FROM advisory_queries WHERE source=? AND ecosystem=? AND name_key=? AND version=?').get(source,ecosystem,nameKey,version);
|
|
51
|
+
if(previous&&previous.fetched_at>query.fetchedAt)return;
|
|
52
|
+
this.db.prepare(`INSERT INTO advisory_queries(source,ecosystem,name_key,version,original_name,fetched_at,stale,provenance_json)
|
|
53
|
+
VALUES (?,?,?,?,?,?,?,?) ON CONFLICT(source,ecosystem,name_key,version) DO UPDATE SET original_name=excluded.original_name,
|
|
54
|
+
fetched_at=excluded.fetched_at,stale=excluded.stale,provenance_json=excluded.provenance_json`).run(source,ecosystem,nameKey,version,query.name,query.fetchedAt,query.provenance?.stale===true?1:0,text(query.provenance||{}));
|
|
55
|
+
this.db.prepare('DELETE FROM advisory_query_ids WHERE source=? AND ecosystem=? AND name_key=? AND version=?').run(source,ecosystem,nameKey,version);
|
|
56
|
+
const insert=this.db.prepare('INSERT INTO advisory_query_ids(source,ecosystem,name_key,version,id,ordinal,document_sha256) VALUES (?,?,?,?,?,?,?)');
|
|
57
|
+
for(let i=0;i<query.ids.length;i++)insert.run(source,ecosystem,nameKey,version,query.ids[i],i,query.provenance?.documentHashes?.[query.ids[i]]||null);
|
|
58
|
+
}
|
|
59
|
+
_putCoverage(coverage){
|
|
60
|
+
const source=coverage.source,ecosystem=coverage.ecosystem;
|
|
61
|
+
const current=this.db.prepare("SELECT fetched_at FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='current'").get(source,ecosystem);
|
|
62
|
+
const put=this.db.prepare(`INSERT INTO advisory_coverage(source,ecosystem,slot,fetched_at,complete,stale,entry_json)
|
|
63
|
+
VALUES (?,?,?,?,?,?,?) ON CONFLICT(source,ecosystem,slot) DO UPDATE SET fetched_at=excluded.fetched_at,
|
|
64
|
+
complete=excluded.complete,stale=excluded.stale,entry_json=excluded.entry_json`);
|
|
65
|
+
if(!current||coverage.fetchedAt>=current.fetched_at)put.run(source,ecosystem,'current',coverage.fetchedAt,coverage.complete?1:0,coverage.provenance?.stale===true?1:0,text(coverage));
|
|
66
|
+
if(coverage.complete){
|
|
67
|
+
const last=this.db.prepare("SELECT fetched_at FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='last_complete'").get(source,ecosystem);
|
|
68
|
+
if(!last||coverage.fetchedAt>=last.fetched_at)put.run(source,ecosystem,'last_complete',coverage.fetchedAt,1,coverage.provenance?.stale===true?1:0,text(coverage));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
_commit({records=[],queries=[],coverages=[]}){
|
|
72
|
+
for(const record of records)this._putRecord(record);
|
|
73
|
+
for(const query of queries)this._putQuery(query);
|
|
74
|
+
for(const coverage of coverages)this._putCoverage(coverage);
|
|
75
|
+
}
|
|
76
|
+
commit({records=[],queries=[],coverages=[]}={}){
|
|
77
|
+
if(!Array.isArray(records)||!Array.isArray(queries)||!Array.isArray(coverages))throw Error('invalid advisory transaction');
|
|
78
|
+
const transaction=parse(text({records,queries,coverages}));
|
|
79
|
+
for(const record of transaction.records)validateRecord(record);
|
|
80
|
+
for(const query of transaction.queries)validateQuery(query);
|
|
81
|
+
for(const coverage of transaction.coverages)validateCoverage(coverage);
|
|
82
|
+
if(!records.length&&!queries.length&&!coverages.length)return;
|
|
83
|
+
return this.db.transaction(()=>{
|
|
84
|
+
const incoming=new Set(transaction.records.map(record=>key(record.source,advisoryId(record))));
|
|
85
|
+
for(const query of transaction.queries)for(const id of query.ids)if(!incoming.has(key(query.source,id))&&!this._rowRecord(query.source,id))throw Error(`missing advisory detail: ${id}`);
|
|
86
|
+
this._commit(transaction);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getRecord(source,id){return this._record(source,id)}
|
|
90
|
+
getQuery(tuple,{now=Date.now(),ttlMs=DEFAULT_QUERY_TTL_MS}={}){
|
|
91
|
+
if(!Number.isFinite(ttlMs)||ttlMs<0)throw Error('invalid advisory query TTL');
|
|
92
|
+
const source=tuple.source||'osv',ecosystem=tuple.ecosystem,nameKey=ecosystem==='Maven'?tuple.name:packageName(ecosystem,tuple.name);
|
|
93
|
+
const row=this.db.prepare('SELECT * FROM advisory_queries WHERE source=? AND ecosystem=? AND name_key=? AND version=?').get(source,ecosystem,nameKey,tuple.version);
|
|
94
|
+
if(!row)return null;
|
|
95
|
+
const ids=this.db.prepare('SELECT id FROM advisory_query_ids WHERE source=? AND ecosystem=? AND name_key=? AND version=? ORDER BY ordinal').all(source,ecosystem,nameKey,tuple.version).map(x=>x.id);
|
|
96
|
+
if(ids.some(id=>!this._rowRecord(source,id)))return null;
|
|
97
|
+
const provenance=parse(row.provenance_json);
|
|
98
|
+
return {source,ecosystem,name:row.original_name,version:row.version,ids,fetchedAt:row.fetched_at,complete:true,provenance,fresh:provenance.stale!==true&&now>=row.fetched_at&&now-row.fetched_at<ttlMs};
|
|
99
|
+
}
|
|
100
|
+
getSourceCoverage(source,ecosystem='*',options={}){return this._coverage({source,ecosystem},options)}
|
|
101
|
+
_coverage(tuple,{now=Date.now(),ttlMs=DEFAULT_QUERY_TTL_MS}={}){
|
|
102
|
+
const source=tuple.source||'osv';
|
|
103
|
+
let coverageEcosystem=tuple.ecosystem;
|
|
104
|
+
let current=this.db.prepare("SELECT * FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='current'").get(source,coverageEcosystem);
|
|
105
|
+
if(!current && source==='osv' && tuple.name){
|
|
106
|
+
coverageEcosystem=require('./airgap-project').packageScope(tuple.ecosystem,tuple.name);
|
|
107
|
+
current=this.db.prepare("SELECT * FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='current'").get(source,coverageEcosystem);
|
|
108
|
+
}
|
|
109
|
+
if(!current)return null;
|
|
110
|
+
const baseline=this.db.prepare("SELECT * FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='last_complete'").get(source,coverageEcosystem);
|
|
111
|
+
const unpack=row=>{const x=parse(row.entry_json);return {...x,fresh:x.provenance?.stale!==true&&now>=x.fetchedAt&&now-x.fetchedAt<ttlMs}};
|
|
112
|
+
return {...unpack(current),lastComplete:baseline?unpack(baseline):null};
|
|
113
|
+
}
|
|
114
|
+
getQuerySummary(source='osv',{now=Date.now(),ttlMs=DEFAULT_QUERY_TTL_MS}={}){
|
|
115
|
+
if(!Number.isFinite(ttlMs)||ttlMs<0)throw Error('invalid advisory query TTL');
|
|
116
|
+
const row=this.db.prepare(`SELECT COUNT(*) count,MIN(fetched_at) oldestFetchedAt,MAX(fetched_at) newestFetchedAt,
|
|
117
|
+
SUM(CASE WHEN stale=1 OR fetched_at>? OR fetched_at<=? THEN 1 ELSE 0 END) staleCount FROM advisory_queries WHERE source=?`).get(now,now-ttlMs,source);
|
|
118
|
+
return {count:row.count,oldestFetchedAt:row.oldestFetchedAt,newestFetchedAt:row.newestFetchedAt,staleCount:row.staleCount||0,complete:false,scope:'consulted-package-versions'};
|
|
119
|
+
}
|
|
120
|
+
getPackageRecords(ecosystem,name,{source='osv',includeWithdrawn=false}={}){
|
|
121
|
+
const pkgName=packageName(ecosystem,name);
|
|
122
|
+
const rows=source==null
|
|
123
|
+
? this.db.prepare('SELECT source,id FROM advisory_packages WHERE ecosystem=? AND name_key=? ORDER BY source,id').all(ecosystem,pkgName)
|
|
124
|
+
: this.db.prepare('SELECT source,id FROM advisory_packages WHERE ecosystem=? AND name_key=? AND source=? ORDER BY id').all(ecosystem,pkgName,source);
|
|
125
|
+
return rows.map(x=>this._record(x.source,x.id)).filter(record=>record&&(includeWithdrawn||!isWithdrawn(record)));
|
|
126
|
+
}
|
|
127
|
+
getPackageView(tuple,options={}){
|
|
128
|
+
const source=tuple.source||'osv',query=this.getQuery(tuple,options);
|
|
129
|
+
const records=this.getPackageRecords(tuple.ecosystem,tuple.name,{source,includeWithdrawn:true});
|
|
130
|
+
if(source==='osv'&&tuple.ecosystem==='Maven')for(const legacy of this.getPackageRecords(tuple.ecosystem,tuple.name,{source:'osv-legacy-maven',includeWithdrawn:true}))if(!this._rowRecord('osv',advisoryId(legacy)))records.push(legacy);
|
|
131
|
+
const queryRecords=query?query.ids.map(id=>this._record(source,id)):[];
|
|
132
|
+
const combined=new Map([...records,...queryRecords].filter(Boolean).map(record=>[key(record.source,advisoryId(record)),record]));
|
|
133
|
+
return {query,coverage:this._coverage(tuple,options),records:[...combined.values()],queryRecords,
|
|
134
|
+
querySuperseded:!!query&&[...combined.values()].some(record=>!queryCoversRecord(query,record))};
|
|
135
|
+
}
|
|
136
|
+
async importRecords(iterable,{source='osv',fetchedAt=Date.now(),provenance={transport:'seed'},batchSize=250,coverages=[],envelopes=false}={}){
|
|
137
|
+
if(!Number.isSafeInteger(batchSize)||batchSize<1||batchSize>1000)throw Error('invalid advisory import batch size');
|
|
138
|
+
for(const coverage of coverages)validateCoverage(coverage);
|
|
139
|
+
let count=0,batch=[];
|
|
140
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
141
|
+
try{
|
|
142
|
+
for await(const document of iterable){
|
|
143
|
+
const record=envelopes?document:{source,document,fetchedAt,provenance};validateRecord(record);
|
|
144
|
+
batch.push(record);count++;
|
|
145
|
+
if(batch.length>=batchSize){this._commit({records:batch});batch=[]}
|
|
146
|
+
}
|
|
147
|
+
if(batch.length)this._commit({records:batch});
|
|
148
|
+
for(const coverage of coverages)this._putCoverage(coverage);
|
|
149
|
+
this.db.exec('COMMIT');return count;
|
|
150
|
+
}catch(error){try{this.db.exec('ROLLBACK')}catch{}throw error}
|
|
151
|
+
}
|
|
152
|
+
importEnvelopes(iterable,options={}){return this.importRecords(iterable,{...options,envelopes:true})}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function openAdvisoryStore(options){return new SqliteAdvisoryStore(options)}
|
|
156
|
+
module.exports={SqliteAdvisoryStore,openAdvisoryStore};
|