Offline vulnerability matching: inventory in collectors, signed OSV/NVD/KEV/EPSS bundle builder, matcher in the app, tests
Browse files- .gitignore +2 -0
- README.md +11 -0
- app/main.cjs +22 -3
- app/package.json +1 -1
- app/test/version-pairs.json +149 -0
- app/test/vulndb.mjs +94 -0
- app/vulndb-public-key.pem +3 -0
- app/vulndb.cjs +308 -0
- collectors/linux/audit.sh +20 -1
- collectors/macos/audit.sh +23 -3
- collectors/windows/audit.ps1 +12 -3
- docs/CONTROLS.md +2 -2
- tools/build_controls_doc.py +2 -2
- tools/match_vulns.cjs +24 -0
- vulndb/build_bundle.py +395 -0
- vulndb/products.json +39 -0
- vulndb/sign-bundle.mjs +38 -0
.gitignore
CHANGED
|
@@ -13,3 +13,5 @@ training/models/
|
|
| 13 |
app/node_modules/
|
| 14 |
synthetic/out-v0.2/
|
| 15 |
training/out-v0.2/
|
|
|
|
|
|
|
|
|
| 13 |
app/node_modules/
|
| 14 |
synthetic/out-v0.2/
|
| 15 |
training/out-v0.2/
|
| 16 |
+
vulndb/cache/
|
| 17 |
+
vulndb/out/
|
README.md
CHANGED
|
@@ -150,12 +150,23 @@ npm start # run the app
|
|
| 150 |
|
| 151 |
Offline fine-tuning on CPU: `training/train_lora.py` (LoRA on Qwen2.5-0.5B-Instruct; see `--benchmark` and `--resume`).
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
## Version status
|
| 154 |
|
| 155 |
| Part | Version | Notes |
|
| 156 |
|---|---|---|
|
| 157 |
| Catalog, library, synthetic data, training data | **0.2** | 68 checks: adds signed-in user account type, USB device access, pending security updates, outdated apps, known vulnerabilities, Windows screen lock line; screen lock limit 5 minutes |
|
| 158 |
| Collectors (Windows, Linux, macOS) | **0.2** | macOS tested on a real Mac; Linux tested on Ubuntu 24.04 and Fedora 42 containers; Windows parse-checked only (needs a real Windows test). Known vulnerabilities: inventory only, matching comes with the offline vulnerability bundle |
|
|
|
|
| 159 |
| Fine-tuned model | training on 0.1 data | First run in progress on CPU |
|
| 160 |
|
| 161 |
## Test status (collector version 0.1.0)
|
|
|
|
| 150 |
|
| 151 |
Offline fine-tuning on CPU: `training/train_lora.py` (LoRA on Qwen2.5-0.5B-Instruct; see `--benchmark` and `--resume`).
|
| 152 |
|
| 153 |
+
## Vulnerability matching (offline)
|
| 154 |
+
|
| 155 |
+
`vuln.known_vulnerabilities` is decided by exact version comparison, never by the model:
|
| 156 |
+
|
| 157 |
+
1. The collector saves a software inventory next to the evidence (`*-inventory.json`: names and versions only; it stays on the computer).
|
| 158 |
+
2. The app matches it against a **signed vulnerability bundle** (`app/vulndb.cjs`): Linux packages against OSV advisories for Ubuntu, Debian, RHEL, AlmaLinux and Rocky (with dpkg/rpm version rules), Windows and macOS applications against NVD version ranges for 33 common business apps (`vulndb/products.json`), with CISA KEV ("actively exploited") and EPSS scores for priority.
|
| 159 |
+
3. Only vulnerabilities with an available fix are counted. Distributions or apps outside the bundle are reported as not covered, never as "0 vulnerabilities". Data older than 14 days is flagged in the finding.
|
| 160 |
+
|
| 161 |
+
Devseis builds the bundle with `python3 vulndb/build_bundle.py` (needs internet; about 1 GB of source downloads, 5 MB result) and signs it with `node vulndb/sign-bundle.mjs` (private key in `~/.devseis/`, never in the repository). Test a run without the app: `node tools/match_vulns.cjs <evidence.json>`. Packaging must ship `vulndb/out/` inside the app's `audit` resources.
|
| 162 |
+
|
| 163 |
## Version status
|
| 164 |
|
| 165 |
| Part | Version | Notes |
|
| 166 |
|---|---|---|
|
| 167 |
| Catalog, library, synthetic data, training data | **0.2** | 68 checks: adds signed-in user account type, USB device access, pending security updates, outdated apps, known vulnerabilities, Windows screen lock line; screen lock limit 5 minutes |
|
| 168 |
| Collectors (Windows, Linux, macOS) | **0.2** | macOS tested on a real Mac; Linux tested on Ubuntu 24.04 and Fedora 42 containers; Windows parse-checked only (needs a real Windows test). Known vulnerabilities: inventory only, matching comes with the offline vulnerability bundle |
|
| 169 |
+
| Vulnerability matcher and bundle | 0.1 | Tested: this Mac (Chrome 154 → 58 critical/high, fixed in 155), Ubuntu 24.04 (OpenSSL), Rocky 9 (25 of 25 packages agree with dnf's own security list), Fedora reported as not covered |
|
| 170 |
| Fine-tuned model | training on 0.1 data | First run in progress on CPU |
|
| 171 |
|
| 172 |
## Test status (collector version 0.1.0)
|
app/main.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const crypto = require('node:crypto');
|
|
| 8 |
const fs = require('node:fs');
|
| 9 |
const os = require('node:os');
|
| 10 |
const path = require('node:path');
|
|
|
|
| 11 |
|
| 12 |
// WebGPU (used by WebLLM) is still behind a flag on Linux.
|
| 13 |
if (process.platform === 'linux') {
|
|
@@ -19,6 +20,8 @@ if (process.platform === 'linux') {
|
|
| 19 |
const AUDIT_ROOT = app.isPackaged ? path.join(process.resourcesPath, 'audit') : path.join(__dirname, '..');
|
| 20 |
const OS_FAMILY = { win32: 'windows', darwin: 'macos', linux: 'linux' }[process.platform];
|
| 21 |
const readJson = (...parts) => JSON.parse(fs.readFileSync(path.join(AUDIT_ROOT, ...parts), 'utf8'));
|
|
|
|
|
|
|
| 22 |
let mainWindow = null;
|
| 23 |
|
| 24 |
function createWindow() {
|
|
@@ -31,6 +34,8 @@ function createWindow() {
|
|
| 31 |
|
| 32 |
app.whenReady().then(() => {
|
| 33 |
createWindow();
|
|
|
|
|
|
|
| 34 |
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); });
|
| 35 |
});
|
| 36 |
app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
|
|
@@ -115,9 +120,23 @@ ipcMain.handle('audit:run', async (event, { elevated }) => {
|
|
| 115 |
reject(new Error(cancelled ? 'The administrator prompt was cancelled.' : `The audit did not finish (exit ${code}). ${stderr.slice(-300)} ${log}`.trim()));
|
| 116 |
return;
|
| 117 |
}
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
});
|
| 122 |
});
|
| 123 |
});
|
|
|
|
| 8 |
const fs = require('node:fs');
|
| 9 |
const os = require('node:os');
|
| 10 |
const path = require('node:path');
|
| 11 |
+
const vulndb = require('./vulndb.cjs');
|
| 12 |
|
| 13 |
// WebGPU (used by WebLLM) is still behind a flag on Linux.
|
| 14 |
if (process.platform === 'linux') {
|
|
|
|
| 20 |
const AUDIT_ROOT = app.isPackaged ? path.join(process.resourcesPath, 'audit') : path.join(__dirname, '..');
|
| 21 |
const OS_FAMILY = { win32: 'windows', darwin: 'macos', linux: 'linux' }[process.platform];
|
| 22 |
const readJson = (...parts) => JSON.parse(fs.readFileSync(path.join(AUDIT_ROOT, ...parts), 'utf8'));
|
| 23 |
+
// Vulnerability data: the downloaded copy first, then the one shipped with the app (or built locally during development).
|
| 24 |
+
const vulndbDirs = () => [path.join(app.getPath('userData'), 'vulndb'), path.join(AUDIT_ROOT, 'vulndb', 'out')];
|
| 25 |
let mainWindow = null;
|
| 26 |
|
| 27 |
function createWindow() {
|
|
|
|
| 34 |
|
| 35 |
app.whenReady().then(() => {
|
| 36 |
createWindow();
|
| 37 |
+
// Fetch newer vulnerability data in the background; the audit uses the last good copy if this fails.
|
| 38 |
+
vulndb.refresh(vulndbDirs()[0]).catch(error => console.warn(`Vulnerability data not refreshed: ${error.message}`));
|
| 39 |
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); });
|
| 40 |
});
|
| 41 |
app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
|
|
|
|
| 120 |
reject(new Error(cancelled ? 'The administrator prompt was cancelled.' : `The audit did not finish (exit ${code}). ${stderr.slice(-300)} ${log}`.trim()));
|
| 121 |
return;
|
| 122 |
}
|
| 123 |
+
let evidenceText = fs.readFileSync(done.evidencePath, 'utf8');
|
| 124 |
+
let evidence = JSON.parse(evidenceText.replace(/^/, ''));
|
| 125 |
+
// Match the software inventory against the offline vulnerability data (on this computer only).
|
| 126 |
+
const inventoryPath = done.evidencePath.replace(/\.json$/, '-inventory.json');
|
| 127 |
+
if (fs.existsSync(inventoryPath)) {
|
| 128 |
+
try {
|
| 129 |
+
const inventory = JSON.parse(fs.readFileSync(inventoryPath, 'utf8').replace(/^/, ''));
|
| 130 |
+
const maxSevere = parseInt((evidence.baseline || {}).MAX_CRITICAL_HIGH_VULNERABILITIES || '0', 10) || 0;
|
| 131 |
+
evidence = vulndb.apply(evidence, inventory, vulndb.load(vulndbDirs()), maxSevere);
|
| 132 |
+
evidenceText = JSON.stringify(evidence, null, 2);
|
| 133 |
+
const r = evidence.results.find(x => x.id === 'vuln.known_vulnerabilities');
|
| 134 |
+
if (r) event.sender.send('audit:progress', { id: r.id, status: r.status, name: r.name });
|
| 135 |
+
} catch (error) {
|
| 136 |
+
console.warn(`Vulnerability matching skipped: ${error.message}`);
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
resolve({ evidence, evidenceText, sha256: crypto.createHash('sha256').update(evidenceText).digest('hex'), workDir });
|
| 140 |
});
|
| 141 |
});
|
| 142 |
});
|
app/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"main": "main.cjs",
|
| 10 |
"scripts": {
|
| 11 |
"start": "electron .",
|
| 12 |
-
"test": "node test/prompt-parity.mjs"
|
| 13 |
},
|
| 14 |
"devDependencies": {
|
| 15 |
"electron": "^44.6.0"
|
|
|
|
| 9 |
"main": "main.cjs",
|
| 10 |
"scripts": {
|
| 11 |
"start": "electron .",
|
| 12 |
+
"test": "node test/prompt-parity.mjs && node test/vulndb.mjs"
|
| 13 |
},
|
| 14 |
"devDependencies": {
|
| 15 |
"electron": "^44.6.0"
|
app/test/version-pairs.json
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_comment": "Expected ordering produced by real dpkg --compare-versions (Ubuntu 24.04) and rpm.vercmp (Fedora 42), 2026-10-08: [a, b, dpkg, rpm]",
|
| 3 |
+
"pairs": [
|
| 4 |
+
[
|
| 5 |
+
"1.0",
|
| 6 |
+
"1.0-1",
|
| 7 |
+
-1,
|
| 8 |
+
-1
|
| 9 |
+
],
|
| 10 |
+
[
|
| 11 |
+
"1.0-1",
|
| 12 |
+
"1.0-2",
|
| 13 |
+
-1,
|
| 14 |
+
-1
|
| 15 |
+
],
|
| 16 |
+
[
|
| 17 |
+
"1:1.0",
|
| 18 |
+
"2.0",
|
| 19 |
+
1,
|
| 20 |
+
1
|
| 21 |
+
],
|
| 22 |
+
[
|
| 23 |
+
"1.0~rc1",
|
| 24 |
+
"1.0",
|
| 25 |
+
-1,
|
| 26 |
+
-1
|
| 27 |
+
],
|
| 28 |
+
[
|
| 29 |
+
"1.0~rc1-1",
|
| 30 |
+
"1.0-1",
|
| 31 |
+
-1,
|
| 32 |
+
-1
|
| 33 |
+
],
|
| 34 |
+
[
|
| 35 |
+
"3.0.13-0ubuntu3.4",
|
| 36 |
+
"3.0.13-0ubuntu3.10",
|
| 37 |
+
-1,
|
| 38 |
+
-1
|
| 39 |
+
],
|
| 40 |
+
[
|
| 41 |
+
"3.0.13-0ubuntu3.4",
|
| 42 |
+
"3.0.13-0ubuntu3.4+esm1",
|
| 43 |
+
-1,
|
| 44 |
+
-1
|
| 45 |
+
],
|
| 46 |
+
[
|
| 47 |
+
"2.39-0ubuntu8.3",
|
| 48 |
+
"2.39-0ubuntu8",
|
| 49 |
+
1,
|
| 50 |
+
1
|
| 51 |
+
],
|
| 52 |
+
[
|
| 53 |
+
"1.2.3a",
|
| 54 |
+
"1.2.3",
|
| 55 |
+
1,
|
| 56 |
+
1
|
| 57 |
+
],
|
| 58 |
+
[
|
| 59 |
+
"1.2.3a",
|
| 60 |
+
"1.2.3b",
|
| 61 |
+
-1,
|
| 62 |
+
-1
|
| 63 |
+
],
|
| 64 |
+
[
|
| 65 |
+
"1.2.3+dfsg-1",
|
| 66 |
+
"1.2.3-1",
|
| 67 |
+
1,
|
| 68 |
+
1
|
| 69 |
+
],
|
| 70 |
+
[
|
| 71 |
+
"148.0.7778.215-1~deb12u1",
|
| 72 |
+
"148.0.7778.215-1",
|
| 73 |
+
-1,
|
| 74 |
+
-1
|
| 75 |
+
],
|
| 76 |
+
[
|
| 77 |
+
"7.88.1-10+deb12u8",
|
| 78 |
+
"7.88.1-10+deb12u12",
|
| 79 |
+
-1,
|
| 80 |
+
-1
|
| 81 |
+
],
|
| 82 |
+
[
|
| 83 |
+
"2:9.2.390-1.fc42",
|
| 84 |
+
"2:9.2.390-1.fc42",
|
| 85 |
+
0,
|
| 86 |
+
0
|
| 87 |
+
],
|
| 88 |
+
[
|
| 89 |
+
"0:1.10.2-2.fc42",
|
| 90 |
+
"1.10.2-1.fc42",
|
| 91 |
+
1,
|
| 92 |
+
1
|
| 93 |
+
],
|
| 94 |
+
[
|
| 95 |
+
"1.21.3-7.fc42",
|
| 96 |
+
"1.21.3-10.fc42",
|
| 97 |
+
-1,
|
| 98 |
+
-1
|
| 99 |
+
],
|
| 100 |
+
[
|
| 101 |
+
"1:3.2.6-4.fc42",
|
| 102 |
+
"1:3.2.6-4.fc42.1",
|
| 103 |
+
-1,
|
| 104 |
+
-1
|
| 105 |
+
],
|
| 106 |
+
[
|
| 107 |
+
"5.14.0-427.13.1.el9_4",
|
| 108 |
+
"5.14.0-427.13.1.el9_4.x",
|
| 109 |
+
-1,
|
| 110 |
+
-1
|
| 111 |
+
],
|
| 112 |
+
[
|
| 113 |
+
"6.12.0-124.56.5.el10_1",
|
| 114 |
+
"6.12.0-124.8.1.el10_0",
|
| 115 |
+
1,
|
| 116 |
+
1
|
| 117 |
+
],
|
| 118 |
+
[
|
| 119 |
+
"1.0",
|
| 120 |
+
"1.0.0",
|
| 121 |
+
-1,
|
| 122 |
+
-1
|
| 123 |
+
],
|
| 124 |
+
[
|
| 125 |
+
"1.0.a",
|
| 126 |
+
"1.0.1",
|
| 127 |
+
1,
|
| 128 |
+
-1
|
| 129 |
+
],
|
| 130 |
+
[
|
| 131 |
+
"2.4.57-5.el9_4",
|
| 132 |
+
"2.4.57-11.el9_4.1",
|
| 133 |
+
-1,
|
| 134 |
+
-1
|
| 135 |
+
],
|
| 136 |
+
[
|
| 137 |
+
"1.0^git1-1",
|
| 138 |
+
"1.0-1",
|
| 139 |
+
1,
|
| 140 |
+
1
|
| 141 |
+
],
|
| 142 |
+
[
|
| 143 |
+
"1.0~beta-1",
|
| 144 |
+
"1.0-1",
|
| 145 |
+
-1,
|
| 146 |
+
-1
|
| 147 |
+
]
|
| 148 |
+
]
|
| 149 |
+
}
|
app/test/vulndb.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Tests for app/vulndb.cjs: version ordering (expected values come from the real dpkg and rpm tools),
|
| 2 |
+
// matching rules, and rejection of tampered bundles. Run: node test/vulndb.mjs
|
| 3 |
+
import { createRequire } from 'node:module';
|
| 4 |
+
import { createHash, generateKeyPairSync, sign } from 'node:crypto';
|
| 5 |
+
import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
| 6 |
+
import { tmpdir } from 'node:os';
|
| 7 |
+
import path from 'node:path';
|
| 8 |
+
import { gzipSync } from 'node:zlib';
|
| 9 |
+
import { fileURLToPath } from 'node:url';
|
| 10 |
+
import assert from 'node:assert/strict';
|
| 11 |
+
|
| 12 |
+
const require = createRequire(import.meta.url);
|
| 13 |
+
const v = require('../vulndb.cjs');
|
| 14 |
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
| 15 |
+
let passed = 0;
|
| 16 |
+
const check = (name, fn) => { fn(); passed++; };
|
| 17 |
+
|
| 18 |
+
const { pairs } = JSON.parse(readFileSync(path.join(here, 'version-pairs.json'), 'utf8'));
|
| 19 |
+
for (const [a, b, dpkg, rpm] of pairs) {
|
| 20 |
+
check(`dpkg ${a} ${b}`, () => assert.equal(Math.sign(v.dpkgCompare(a, b)), dpkg, `dpkg ${a} vs ${b}`));
|
| 21 |
+
check(`rpm ${a} ${b}`, () => assert.equal(Math.sign(v.rpmCompare(a, b)), rpm, `rpm ${a} vs ${b}`));
|
| 22 |
+
}
|
| 23 |
+
check('app versions', () => {
|
| 24 |
+
assert.ok(v.appCompare('154.0.8037.98', '155.0.8059.39') < 0);
|
| 25 |
+
assert.equal(v.appCompare('6.2.5 (42037)', '6.2.5'), 0);
|
| 26 |
+
assert.ok(v.appCompare('24.003.20180', '24.3.20112') > 0);
|
| 27 |
+
});
|
| 28 |
+
|
| 29 |
+
const bundle = {
|
| 30 |
+
releases: {
|
| 31 |
+
'ubuntu:24.04': { openssl: [['CVE-1', '', '3.0.13-0ubuntu3.16', 'high'], ['CVE-2', '', '3.0.13-0ubuntu3.2', 'critical']] },
|
| 32 |
+
'rocky:9': {
|
| 33 |
+
openssl: [['CVE-3', 'RLSA-1', '1:3.5.8-1.el9_8', 'critical']],
|
| 34 |
+
nodejs: [['CVE-4', 'RLSA-2', '1:20.20.2-2.module+el9.6.0+1+abc', 'high']],
|
| 35 |
+
},
|
| 36 |
+
},
|
| 37 |
+
apps: [{ id: 'chrome', name: 'Google Chrome', windows: '^Google Chrome$', macos: '^Google Chrome$',
|
| 38 |
+
cves: [['CVE-5', 'high', '', '', '', '155.0.8059.39', ''], ['CVE-6', 'medium', '100.0', '', '120.0', '', ''], ['CVE-7', 'critical', '', '', '', '', '154.0.8037.98']] }],
|
| 39 |
+
kev: ['CVE-5'], epss: { 'CVE-5': 0.5 },
|
| 40 |
+
};
|
| 41 |
+
check('deb: source package and fixed version', () => {
|
| 42 |
+
const m = v.matchLinux({ kind: 'deb', distro_id: 'ubuntu', version_id: '24.04', packages: [
|
| 43 |
+
{ name: 'libssl3t64', version: '3.0.13-0ubuntu3.15', source: 'openssl', source_version: '3.0.13-0ubuntu3.15' },
|
| 44 |
+
{ name: 'openssl', version: '3.0.13-0ubuntu3.15', source: '', source_version: '' }] }, bundle);
|
| 45 |
+
assert.deepEqual(m.hits.map(h => h.cves[0]), ['CVE-1']); // CVE-2 is fixed in an older build
|
| 46 |
+
assert.equal(m.checked, 1); // two binaries, one source package
|
| 47 |
+
});
|
| 48 |
+
check('rpm: sub-package matched through its source; module stream of another major skipped', () => {
|
| 49 |
+
const m = v.matchLinux({ kind: 'rpm', distro_id: 'rocky', version_id: '9.8', packages: [
|
| 50 |
+
{ name: 'openssl-libs', version: '1:3.5.5-2.el9_8', source: 'openssl' },
|
| 51 |
+
{ name: 'nodejs', version: '1:22.1.0-1.module+el9.6.0+2+def', source: 'nodejs' }] }, bundle);
|
| 52 |
+
assert.deepEqual(m.hits.map(h => `${h.software}:${h.cves[0]}`), ['openssl:CVE-3']);
|
| 53 |
+
});
|
| 54 |
+
check('unsupported distribution is reported as not covered', () => {
|
| 55 |
+
assert.equal(v.matchLinux({ kind: 'rpm', distro_id: 'fedora', version_id: '42', packages: [] }, bundle).covered, false);
|
| 56 |
+
});
|
| 57 |
+
check('apps: ranges, exact versions, KEV grouping', () => {
|
| 58 |
+
const m = v.matchApps({ apps: [{ name: 'Google Chrome', version: '154.0.8037.98' }, { name: 'Google Chrome Beta', version: '1.0' }] }, bundle, 'macos');
|
| 59 |
+
assert.deepEqual(m.hits.map(h => h.cves[0]).sort(), ['CVE-5', 'CVE-7']);
|
| 60 |
+
const s = v.summarise(m, bundle);
|
| 61 |
+
assert.equal(s.severeCount, 2);
|
| 62 |
+
assert.equal(s.groups[0].exploited, true);
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
// Signed bundle round trip with a throwaway key (the real public key file is swapped for the test).
|
| 66 |
+
check('signature and checksum are enforced', () => {
|
| 67 |
+
const dir = mkdtempSync(path.join(tmpdir(), 'vulndb-test-'));
|
| 68 |
+
const { privateKey, publicKey } = generateKeyPairSync('ed25519');
|
| 69 |
+
const data = gzipSync(Buffer.from(JSON.stringify(bundle)));
|
| 70 |
+
const sha = createHash('sha256').update(data).digest('hex');
|
| 71 |
+
writeFileSync(path.join(dir, 'b.json.gz'), data);
|
| 72 |
+
const manifest = { file: 'b.json.gz', sha256: sha, built_at: '2026-10-08T00:00:00Z', signature: sign(null, Buffer.from(sha), privateKey).toString('base64') };
|
| 73 |
+
writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifest));
|
| 74 |
+
const keyFile = path.join(path.dirname(require.resolve('../vulndb.cjs')), 'vulndb-public-key.pem');
|
| 75 |
+
const realKey = readFileSync(keyFile);
|
| 76 |
+
try {
|
| 77 |
+
writeFileSync(keyFile, publicKey.export({ type: 'spki', format: 'pem' }));
|
| 78 |
+
assert.ok(v.load([dir]).bundle);
|
| 79 |
+
writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify({ ...manifest, signature: Buffer.alloc(64).toString('base64') }));
|
| 80 |
+
assert.match(v.load([dir]).error, /signature/);
|
| 81 |
+
writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifest));
|
| 82 |
+
writeFileSync(path.join(dir, 'b.json.gz'), Buffer.concat([data, Buffer.from('x')]));
|
| 83 |
+
assert.match(v.load([dir]).error, /checksum/);
|
| 84 |
+
} finally {
|
| 85 |
+
writeFileSync(keyFile, realKey);
|
| 86 |
+
}
|
| 87 |
+
});
|
| 88 |
+
check('stale data is flagged in the finding', () => {
|
| 89 |
+
const evidence = { host: { os_family: 'macos' }, results: [{ id: 'vuln.known_vulnerabilities', status: 'Pending', name: 'x', actual: '', expected: '' }] };
|
| 90 |
+
v.apply(evidence, { apps: [] }, { bundle, manifest: { built_at: '2026-01-01T00:00:00Z' } }, 0, Date.parse('2026-03-01'));
|
| 91 |
+
assert.equal(evidence.results[0].status, 'Compliant');
|
| 92 |
+
assert.match(evidence.results[0].detail, /days old/);
|
| 93 |
+
});
|
| 94 |
+
console.log(`${passed} vulnerability matcher checks passed`);
|
app/vulndb-public-key.pem
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN PUBLIC KEY-----
|
| 2 |
+
MCowBQYDK2VwAyEAbVVVE8GRRa+xfM4Zle6WZVTT9X2m2CQ0OkWlrg3NRTY=
|
| 3 |
+
-----END PUBLIC KEY-----
|
app/vulndb.cjs
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Offline vulnerability matching: installed software (from the collector's inventory file) against the
|
| 2 |
+
// signed Devseis vulnerability bundle (vulndb/build_bundle.py). Matching is exact version comparison;
|
| 3 |
+
// the language model never decides whether a CVE applies. Nothing leaves the computer.
|
| 4 |
+
'use strict';
|
| 5 |
+
const crypto = require('node:crypto');
|
| 6 |
+
const fs = require('node:fs');
|
| 7 |
+
const https = require('node:https');
|
| 8 |
+
const path = require('node:path');
|
| 9 |
+
const zlib = require('node:zlib');
|
| 10 |
+
|
| 11 |
+
// Ed25519 public key that signs bundles (private key stays with Devseis, outside the repository).
|
| 12 |
+
const PUBLIC_KEY_FILE = path.join(__dirname, 'vulndb-public-key.pem');
|
| 13 |
+
// Where clients download bundles from; null until the bundle is hosted publicly.
|
| 14 |
+
const VULNDB_URL = null;
|
| 15 |
+
const MAX_AGE_DAYS = 14;
|
| 16 |
+
const SEVERE = new Set(['critical', 'high']);
|
| 17 |
+
|
| 18 |
+
// --- Version comparison ----------------------------------------------------------------------
|
| 19 |
+
// Debian policy 5.6.12: [epoch:]upstream[-revision]; letters sort before non-letters, '~' before everything.
|
| 20 |
+
function dpkgOrder(c) {
|
| 21 |
+
if (c === '~') return -1;
|
| 22 |
+
if (/\d/.test(c)) return 0;
|
| 23 |
+
if (!c) return 0;
|
| 24 |
+
if (/[A-Za-z]/.test(c)) return c.charCodeAt(0);
|
| 25 |
+
return c.charCodeAt(0) + 256;
|
| 26 |
+
}
|
| 27 |
+
function dpkgPart(a, b) {
|
| 28 |
+
let i = 0, j = 0;
|
| 29 |
+
while (i < a.length || j < b.length) {
|
| 30 |
+
let diff = 0;
|
| 31 |
+
while ((i < a.length && !/\d/.test(a[i])) || (j < b.length && !/\d/.test(b[j]))) {
|
| 32 |
+
const ac = dpkgOrder(a[i] || ''), bc = dpkgOrder(b[j] || '');
|
| 33 |
+
if (ac !== bc) return ac - bc;
|
| 34 |
+
i++; j++;
|
| 35 |
+
}
|
| 36 |
+
while (a[i] === '0') i++;
|
| 37 |
+
while (b[j] === '0') j++;
|
| 38 |
+
while (/\d/.test(a[i] || '') && /\d/.test(b[j] || '')) {
|
| 39 |
+
if (!diff) diff = a.charCodeAt(i) - b.charCodeAt(j);
|
| 40 |
+
i++; j++;
|
| 41 |
+
}
|
| 42 |
+
if (/\d/.test(a[i] || '')) return 1;
|
| 43 |
+
if (/\d/.test(b[j] || '')) return -1;
|
| 44 |
+
if (diff) return diff;
|
| 45 |
+
}
|
| 46 |
+
return 0;
|
| 47 |
+
}
|
| 48 |
+
function splitDeb(v) {
|
| 49 |
+
let epoch = 0, rest = v;
|
| 50 |
+
const colon = v.indexOf(':');
|
| 51 |
+
if (colon > 0) { epoch = parseInt(v.slice(0, colon), 10) || 0; rest = v.slice(colon + 1); }
|
| 52 |
+
const dash = rest.lastIndexOf('-');
|
| 53 |
+
return dash > 0 ? [epoch, rest.slice(0, dash), rest.slice(dash + 1)] : [epoch, rest, ''];
|
| 54 |
+
}
|
| 55 |
+
function dpkgCompare(a, b) {
|
| 56 |
+
const [ea, ua, ra] = splitDeb(a), [eb, ub, rb] = splitDeb(b);
|
| 57 |
+
if (ea !== eb) return ea - eb;
|
| 58 |
+
return dpkgPart(ua, ub) || dpkgPart(ra, rb);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
// rpmvercmp, with epoch:version-release handling.
|
| 62 |
+
function rpmSegment(a, b) {
|
| 63 |
+
if (a === b) return 0;
|
| 64 |
+
const sa = a.match(/~|\^|[A-Za-z]+|\d+/g) || [], sb = b.match(/~|\^|[A-Za-z]+|\d+/g) || [];
|
| 65 |
+
for (let k = 0; k < Math.max(sa.length, sb.length); k++) {
|
| 66 |
+
const x = sa[k], y = sb[k];
|
| 67 |
+
if (x === '~' || y === '~') { if (x !== y) return x === '~' ? -1 : 1; continue; }
|
| 68 |
+
if (x === '^' || y === '^') {
|
| 69 |
+
if (x === undefined) return -1;
|
| 70 |
+
if (y === undefined) return 1;
|
| 71 |
+
if (x !== y) return x === '^' ? 1 : -1;
|
| 72 |
+
continue;
|
| 73 |
+
}
|
| 74 |
+
if (x === undefined) return -1;
|
| 75 |
+
if (y === undefined) return 1;
|
| 76 |
+
const xn = /^\d/.test(x), yn = /^\d/.test(y);
|
| 77 |
+
if (xn !== yn) return xn ? 1 : -1;
|
| 78 |
+
if (xn) {
|
| 79 |
+
const xs = x.replace(/^0+/, ''), ys = y.replace(/^0+/, '');
|
| 80 |
+
if (xs.length !== ys.length) return xs.length - ys.length;
|
| 81 |
+
if (xs !== ys) return xs < ys ? -1 : 1;
|
| 82 |
+
} else if (x !== y) return x < y ? -1 : 1;
|
| 83 |
+
}
|
| 84 |
+
return 0;
|
| 85 |
+
}
|
| 86 |
+
function splitRpm(v) {
|
| 87 |
+
let epoch = 0, rest = v;
|
| 88 |
+
const colon = v.indexOf(':');
|
| 89 |
+
if (colon > 0) { epoch = parseInt(v.slice(0, colon), 10) || 0; rest = v.slice(colon + 1); }
|
| 90 |
+
const dash = rest.lastIndexOf('-');
|
| 91 |
+
return dash > 0 ? [epoch, rest.slice(0, dash), rest.slice(dash + 1)] : [epoch, rest, ''];
|
| 92 |
+
}
|
| 93 |
+
function rpmCompare(a, b) {
|
| 94 |
+
const [ea, va, ra] = splitRpm(a), [eb, vb, rb] = splitRpm(b);
|
| 95 |
+
if (ea !== eb) return ea - eb;
|
| 96 |
+
return rpmSegment(va, vb) || rpmSegment(ra, rb);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
// Desktop application versions: compare the numbers ("6.2.5 (42037)" -> 6.2.5.42037 is avoided by
|
| 100 |
+
// cutting at the first space or parenthesis).
|
| 101 |
+
function appNumbers(v) { return (String(v).split(/[\s(]/)[0].match(/\d+/g) || []).map(Number); }
|
| 102 |
+
function appCompare(a, b) {
|
| 103 |
+
const x = appNumbers(a), y = appNumbers(b);
|
| 104 |
+
for (let k = 0; k < Math.max(x.length, y.length); k++) {
|
| 105 |
+
const d = (x[k] || 0) - (y[k] || 0);
|
| 106 |
+
if (d) return d;
|
| 107 |
+
}
|
| 108 |
+
return 0;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
// --- Bundle loading -------------------------------------------------------------------------------
|
| 112 |
+
function verifyBundle(dir) {
|
| 113 |
+
const manifest = JSON.parse(fs.readFileSync(path.join(dir, 'manifest.json'), 'utf8'));
|
| 114 |
+
const data = fs.readFileSync(path.join(dir, manifest.file));
|
| 115 |
+
const sha = crypto.createHash('sha256').update(data).digest('hex');
|
| 116 |
+
if (sha !== manifest.sha256) throw new Error('vulnerability bundle checksum does not match');
|
| 117 |
+
if (!manifest.signature) throw new Error('vulnerability bundle is not signed');
|
| 118 |
+
const key = crypto.createPublicKey(fs.readFileSync(PUBLIC_KEY_FILE));
|
| 119 |
+
if (!crypto.verify(null, Buffer.from(sha), key, Buffer.from(manifest.signature, 'base64'))) {
|
| 120 |
+
throw new Error('vulnerability bundle signature is not valid');
|
| 121 |
+
}
|
| 122 |
+
return { manifest, bundle: JSON.parse(zlib.gunzipSync(data).toString('utf8')) };
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function get(url) {
|
| 126 |
+
return new Promise((resolve, reject) => {
|
| 127 |
+
https.get(url, { headers: { 'User-Agent': 'Devseis-Endpoint-Auditor' } }, res => {
|
| 128 |
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { res.resume(); return resolve(get(new URL(res.headers.location, url).href)); }
|
| 129 |
+
if (res.statusCode !== 200) { res.resume(); return reject(new Error(`HTTP ${res.statusCode}`)); }
|
| 130 |
+
const chunks = [];
|
| 131 |
+
res.on('data', c => chunks.push(c));
|
| 132 |
+
res.on('end', () => resolve(Buffer.concat(chunks)));
|
| 133 |
+
}).on('error', reject);
|
| 134 |
+
});
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
// Download a newer bundle into cacheDir when one is published. Failure is not fatal: the last good bundle is used.
|
| 138 |
+
async function refresh(cacheDir) {
|
| 139 |
+
if (!VULNDB_URL) return 'no download location configured';
|
| 140 |
+
const manifest = JSON.parse((await get(`${VULNDB_URL}/manifest.json`)).toString('utf8'));
|
| 141 |
+
let current = null;
|
| 142 |
+
try { current = JSON.parse(fs.readFileSync(path.join(cacheDir, 'manifest.json'), 'utf8')); } catch { /* none yet */ }
|
| 143 |
+
if (current && current.sha256 === manifest.sha256) return 'up to date';
|
| 144 |
+
const data = await get(`${VULNDB_URL}/${manifest.file}`);
|
| 145 |
+
const staging = `${cacheDir}.new`;
|
| 146 |
+
fs.rmSync(staging, { recursive: true, force: true });
|
| 147 |
+
fs.mkdirSync(staging, { recursive: true });
|
| 148 |
+
fs.writeFileSync(path.join(staging, manifest.file), data);
|
| 149 |
+
fs.writeFileSync(path.join(staging, 'manifest.json'), JSON.stringify(manifest, null, 2));
|
| 150 |
+
verifyBundle(staging); // throws if tampered with
|
| 151 |
+
fs.rmSync(cacheDir, { recursive: true, force: true });
|
| 152 |
+
fs.renameSync(staging, cacheDir);
|
| 153 |
+
return 'updated';
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// First valid bundle among the candidate folders (downloaded copy first, then the one shipped with the app).
|
| 157 |
+
function load(dirs) {
|
| 158 |
+
const errors = [];
|
| 159 |
+
for (const dir of dirs) {
|
| 160 |
+
if (!fs.existsSync(path.join(dir, 'manifest.json'))) continue;
|
| 161 |
+
try { return verifyBundle(dir); } catch (error) { errors.push(`${dir}: ${error.message}`); }
|
| 162 |
+
}
|
| 163 |
+
return { error: errors.join('; ') || 'no vulnerability bundle found' };
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
// --- Matching ------------------------------------------------------------------------------------
|
| 167 |
+
// Linux release key in the bundle, from the inventory's os-release fields.
|
| 168 |
+
function releaseKey(inventory) {
|
| 169 |
+
const id = String(inventory.distro_id || '').toLowerCase();
|
| 170 |
+
const version = String(inventory.version_id || '');
|
| 171 |
+
const major = version.split('.')[0];
|
| 172 |
+
if (id === 'ubuntu') return `ubuntu:${version}`;
|
| 173 |
+
if (id === 'debian') return `debian:${major}`;
|
| 174 |
+
if (id === 'rhel') return `rhel:${major}`;
|
| 175 |
+
if (id === 'almalinux') return `almalinux:${major}`;
|
| 176 |
+
if (id === 'rocky') return `rocky:${major}`;
|
| 177 |
+
return null;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
function matchLinux(inventory, bundle) {
|
| 181 |
+
const key = releaseKey(inventory);
|
| 182 |
+
const advisories = key && bundle.releases[key];
|
| 183 |
+
if (!advisories) return { covered: false, reason: `${inventory.pretty_name || inventory.distro_id || 'this distribution'} is not in the vulnerability data (covered: ${Object.keys(bundle.releases).join(', ')})` };
|
| 184 |
+
const deb = inventory.kind === 'deb';
|
| 185 |
+
const compare = deb ? dpkgCompare : rpmCompare;
|
| 186 |
+
// Group installed packages by source package: Debian/Ubuntu advisories name source packages; Red Hat-family
|
| 187 |
+
// advisories name binary packages, sometimes only the main one (openssl) when sub-packages (openssl-libs) are installed.
|
| 188 |
+
const installed = new Map();
|
| 189 |
+
for (const pkg of inventory.packages || []) {
|
| 190 |
+
const group = pkg.source || pkg.name;
|
| 191 |
+
const version = deb ? (pkg.source_version || pkg.version) : pkg.version;
|
| 192 |
+
const names = deb ? [group] : [pkg.name, group];
|
| 193 |
+
const prev = installed.get(group);
|
| 194 |
+
if (!prev) installed.set(group, { version, names: new Set(names) });
|
| 195 |
+
else {
|
| 196 |
+
names.forEach(n => prev.names.add(n));
|
| 197 |
+
if (compare(version, prev.version) > 0) prev.version = version;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
const hits = [];
|
| 201 |
+
for (const [group, { version, names }] of installed) {
|
| 202 |
+
const seen = new Set();
|
| 203 |
+
for (const name of names) {
|
| 204 |
+
for (const [cves, advisory, fixed, severity] of advisories[name] || []) {
|
| 205 |
+
const key = `${cves}|${fixed}`;
|
| 206 |
+
if (seen.has(key)) continue;
|
| 207 |
+
seen.add(key);
|
| 208 |
+
// Red Hat module streams: only compare within the same major version (nodejs 20 fix does not apply to nodejs 22).
|
| 209 |
+
if (!deb && /\.module[+_]/.test(fixed) && splitRpm(fixed)[1].split('.')[0] !== splitRpm(version)[1].split('.')[0]) continue;
|
| 210 |
+
if (compare(version, fixed) < 0) hits.push({ software: group, version, fixed, severity, cves: cves.split('|'), advisory });
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
return { covered: true, source: key, checked: installed.size, hits };
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
function matchApps(inventory, bundle, osFamily) {
|
| 218 |
+
const hits = [];
|
| 219 |
+
const matched = new Set();
|
| 220 |
+
for (const app of inventory.apps || []) {
|
| 221 |
+
if (!app.version) continue;
|
| 222 |
+
for (const product of bundle.apps) {
|
| 223 |
+
const pattern = product[osFamily];
|
| 224 |
+
if (!pattern || !new RegExp(pattern, 'i').test(app.name)) continue;
|
| 225 |
+
matched.add(product.id);
|
| 226 |
+
for (const [cve, severity, si, se, ei, ee, exact] of product.cves) {
|
| 227 |
+
const c = bound => appCompare(app.version, bound);
|
| 228 |
+
const affected = exact ? c(exact) === 0
|
| 229 |
+
: (!si || c(si) >= 0) && (!se || c(se) > 0) && (!ei || c(ei) <= 0) && (!ee || c(ee) < 0);
|
| 230 |
+
if (affected) hits.push({ software: app.name, version: app.version, fixed: ee ? ee : '', severity, cves: [cve], advisory: '' });
|
| 231 |
+
}
|
| 232 |
+
break;
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
return { covered: true, source: 'nvd', checked: (inventory.apps || []).length, recognised: matched.size, hits };
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
// Group hits per software and CVE; flag actively exploited CVEs (CISA KEV) and likely ones (EPSS).
|
| 239 |
+
function summarise(result, bundle) {
|
| 240 |
+
const kev = new Set(bundle.kev);
|
| 241 |
+
const rank = { critical: 0, high: 1, medium: 2, low: 3, unknown: 4 };
|
| 242 |
+
const perCve = new Map();
|
| 243 |
+
for (const hit of result.hits) {
|
| 244 |
+
for (const cve of hit.cves) {
|
| 245 |
+
const id = `${hit.software}|${cve}`;
|
| 246 |
+
const prev = perCve.get(id);
|
| 247 |
+
if (!prev || rank[hit.severity] < rank[prev.severity]) perCve.set(id, { ...hit, cve, exploited: kev.has(cve), epss: bundle.epss[cve] || 0 });
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
const all = [...perCve.values()];
|
| 251 |
+
const severe = all.filter(h => SEVERE.has(h.severity) || h.exploited);
|
| 252 |
+
const bySoftware = new Map();
|
| 253 |
+
for (const h of severe) {
|
| 254 |
+
const s = bySoftware.get(h.software) || { software: h.software, version: h.version, fixed: '', cves: [], worst: 'unknown', exploited: false, epss: 0 };
|
| 255 |
+
s.cves.push(h.cve);
|
| 256 |
+
if (rank[h.severity] < rank[s.worst]) s.worst = h.severity;
|
| 257 |
+
s.exploited = s.exploited || h.exploited;
|
| 258 |
+
s.epss = Math.max(s.epss, h.epss);
|
| 259 |
+
if (h.fixed && (!s.fixed || appCompare(h.fixed, s.fixed) > 0 || /[~+]/.test(h.fixed))) s.fixed = h.fixed;
|
| 260 |
+
bySoftware.set(h.software, s);
|
| 261 |
+
}
|
| 262 |
+
const groups = [...bySoftware.values()].sort((a, b) => (b.exploited - a.exploited) || (rank[a.worst] - rank[b.worst]) || (b.cves.length - a.cves.length));
|
| 263 |
+
return { severeCount: new Set(severe.map(h => h.cve)).size, otherCount: new Set(all.filter(h => !severe.includes(h)).map(h => h.cve)).size, groups };
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
function ageDays(isoDate, now) { return Math.floor((now - Date.parse(isoDate)) / 86400000); }
|
| 267 |
+
|
| 268 |
+
// Replace the collector's "Pending" vuln.known_vulnerabilities result with the matched one.
|
| 269 |
+
function apply(evidence, inventory, loaded, maxSevere, now = Date.now()) {
|
| 270 |
+
const result = evidence.results.find(r => r.id === 'vuln.known_vulnerabilities');
|
| 271 |
+
if (!result || !inventory) return evidence;
|
| 272 |
+
if (loaded.error) {
|
| 273 |
+
result.status = 'Pending';
|
| 274 |
+
result.detail = `${result.detail || ''} No vulnerability data available: ${loaded.error}.`.trim();
|
| 275 |
+
return evidence;
|
| 276 |
+
}
|
| 277 |
+
const { bundle, manifest } = loaded;
|
| 278 |
+
const dataDate = manifest.built_at.slice(0, 10);
|
| 279 |
+
const age = ageDays(manifest.built_at, now);
|
| 280 |
+
const ageNote = age > MAX_AGE_DAYS ? ` Warning: the vulnerability data is ${age} days old; newer vulnerabilities are not included.` : '';
|
| 281 |
+
const osFamily = evidence.host && evidence.host.os_family;
|
| 282 |
+
const matched = osFamily === 'linux' ? matchLinux(inventory, bundle) : matchApps(inventory, bundle, osFamily);
|
| 283 |
+
if (!matched.covered) {
|
| 284 |
+
result.status = 'Pending';
|
| 285 |
+
result.actual = 'not covered';
|
| 286 |
+
result.detail = `${matched.reason}.`;
|
| 287 |
+
return evidence;
|
| 288 |
+
}
|
| 289 |
+
const s = summarise(matched, bundle);
|
| 290 |
+
const scope = osFamily === 'linux'
|
| 291 |
+
? `${matched.checked} ${inventory.kind === 'deb' ? 'source packages' : 'packages'} checked against ${matched.source} advisories`
|
| 292 |
+
: `${matched.checked} applications inventoried, ${matched.recognised} recognised (${bundle.apps.length} common applications covered)`;
|
| 293 |
+
const listed = s.groups.slice(0, 5).map(g => {
|
| 294 |
+
const tags = [`${g.cves.length} CVE${g.cves.length > 1 ? 's' : ''}`, g.worst];
|
| 295 |
+
if (g.exploited) tags.push('actively exploited');
|
| 296 |
+
return `${g.software} ${g.version} (${tags.join(', ')}${g.fixed ? `; fixed in ${g.fixed}` : ''}; e.g. ${g.cves.slice(0, 2).join(', ')})`;
|
| 297 |
+
});
|
| 298 |
+
result.actual = `${s.severeCount} critical/high`;
|
| 299 |
+
result.status = s.severeCount <= maxSevere ? 'Compliant' : 'Non-Compliant';
|
| 300 |
+
result.detail = `Matched against offline OSV/NVD data from ${dataDate}. ${scope}.`
|
| 301 |
+
+ (listed.length ? ` ${listed.join('; ')}${s.groups.length > 5 ? `; and ${s.groups.length - 5} more` : ''}.` : '')
|
| 302 |
+
+ ` ${s.otherCount} medium/low.${ageNote}`;
|
| 303 |
+
evidence.summary = { Compliant: 0, 'Non-Compliant': 0, NotApplicable: 0, Pending: 0, Error: 0 };
|
| 304 |
+
for (const r of evidence.results) evidence.summary[r.status] += 1;
|
| 305 |
+
return evidence;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
module.exports = { dpkgCompare, rpmCompare, appCompare, verifyBundle, refresh, load, releaseKey, matchLinux, matchApps, summarise, apply, MAX_AGE_DAYS };
|
collectors/linux/audit.sh
CHANGED
|
@@ -504,7 +504,7 @@ else
|
|
| 504 |
fi
|
| 505 |
|
| 506 |
# Known vulnerabilities: inventory now; matching against offline OSV data comes in a later version.
|
| 507 |
-
add vuln.known_vulnerabilities $S "Known vulnerabilities in installed software" Pending "$pkg_count packages inventoried" "<= ${B[MAX_CRITICAL_HIGH_VULNERABILITIES]} critical/high" "
|
| 508 |
|
| 509 |
# ---------------------------------------------------------------------------
|
| 510 |
# 2. GDPR technical controls
|
|
@@ -755,6 +755,24 @@ evidence_json() {
|
|
| 755 |
"$(count Compliant)" "$(count Non-Compliant)" "$(count NotApplicable)" "$(count Pending)" "$(count Error)"
|
| 756 |
}
|
| 757 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 758 |
is_root || echo "Warning: not running as root. Some checks will report Error. Run: sudo $0" >&2
|
| 759 |
|
| 760 |
STAMP=$(date '+%Y%m%d-%H%M%S')
|
|
@@ -762,6 +780,7 @@ BASENAME="audit-linux-$HOSTNAME_VALUE-$STAMP"
|
|
| 762 |
if mkdir -p "$OUTPUT_DIR" 2>/dev/null && [ -w "$OUTPUT_DIR" ]; then
|
| 763 |
report | tee "$OUTPUT_DIR/$BASENAME.txt"
|
| 764 |
evidence_json > "$OUTPUT_DIR/$BASENAME.json"
|
|
|
|
| 765 |
echo "Report: $OUTPUT_DIR/$BASENAME.txt" >&2
|
| 766 |
echo "Evidence: $OUTPUT_DIR/$BASENAME.json" >&2
|
| 767 |
[ -n "$PROGRESS_FILE" ] && printf 'DONE\t%s\t%s\n' "$OUTPUT_DIR/$BASENAME.json" "$OUTPUT_DIR/$BASENAME.txt" >> "$PROGRESS_FILE"
|
|
|
|
| 504 |
fi
|
| 505 |
|
| 506 |
# Known vulnerabilities: inventory now; matching against offline OSV data comes in a later version.
|
| 507 |
+
add vuln.known_vulnerabilities $S "Known vulnerabilities in installed software" Pending "$pkg_count packages inventoried" "<= ${B[MAX_CRITICAL_HIGH_VULNERABILITIES]} critical/high" "Inventory saved for the Devseis app, which matches it against its offline OSV/NVD vulnerability data; the collector on its own does not match."
|
| 508 |
|
| 509 |
# ---------------------------------------------------------------------------
|
| 510 |
# 2. GDPR technical controls
|
|
|
|
| 755 |
"$(count Compliant)" "$(count Non-Compliant)" "$(count NotApplicable)" "$(count Pending)" "$(count Error)"
|
| 756 |
}
|
| 757 |
|
| 758 |
+
# Software inventory for the app's offline vulnerability matching (names and versions only).
|
| 759 |
+
write_inventory() {
|
| 760 |
+
local kind="" list=""
|
| 761 |
+
if have dpkg-query; then
|
| 762 |
+
kind=deb
|
| 763 |
+
list=$(dpkg-query -W -f '${db:Status-Abbrev}\t${Package}\t${Version}\t${source:Package}\t${source:Version}\n' 2>/dev/null | awk -F'\t' '$1 ~ /^ii/ { print $2 "\t" $3 "\t" $4 "\t" $5 }')
|
| 764 |
+
elif have rpm; then
|
| 765 |
+
kind=rpm
|
| 766 |
+
# Advisories may name the source package (openssl) while only sub-packages (openssl-libs) are installed.
|
| 767 |
+
list=$(rpm -qa --qf '%{NAME}\t%{EPOCHNUM}:%{VERSION}-%{RELEASE}\t%{SOURCERPM}\n' 2>/dev/null | grep -v '^gpg-pubkey' |
|
| 768 |
+
awk -F'\t' '{ s = $3; sub(/-[^-]+-[^-]+\.src\.rpm$/, "", s); if (s == "(none)") s = ""; print $1 "\t" $2 "\t" s "\t" }')
|
| 769 |
+
fi
|
| 770 |
+
printf '{"format": 1, "os_family": "linux", "distro_id": "%s", "version_id": "%s", "pretty_name": "%s", "kind": "%s", "packages": [' \
|
| 771 |
+
"$(json_escape "$OS_ID")" "$(json_escape "$OS_VERSION")" "$(json_escape "$OS_PRETTY")" "$kind"
|
| 772 |
+
printf '%s\n' "$list" | awk -F'\t' 'NF >= 2 { gsub(/[\\"]/, ""); printf "%s{\"name\":\"%s\",\"version\":\"%s\",\"source\":\"%s\",\"source_version\":\"%s\"}", (n++ ? "," : ""), $1, $2, $3, $4 }'
|
| 773 |
+
printf ']}\n'
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
is_root || echo "Warning: not running as root. Some checks will report Error. Run: sudo $0" >&2
|
| 777 |
|
| 778 |
STAMP=$(date '+%Y%m%d-%H%M%S')
|
|
|
|
| 780 |
if mkdir -p "$OUTPUT_DIR" 2>/dev/null && [ -w "$OUTPUT_DIR" ]; then
|
| 781 |
report | tee "$OUTPUT_DIR/$BASENAME.txt"
|
| 782 |
evidence_json > "$OUTPUT_DIR/$BASENAME.json"
|
| 783 |
+
write_inventory > "$OUTPUT_DIR/$BASENAME-inventory.json"
|
| 784 |
echo "Report: $OUTPUT_DIR/$BASENAME.txt" >&2
|
| 785 |
echo "Evidence: $OUTPUT_DIR/$BASENAME.json" >&2
|
| 786 |
[ -n "$PROGRESS_FILE" ] && printf 'DONE\t%s\t%s\n' "$OUTPUT_DIR/$BASENAME.json" "$OUTPUT_DIR/$BASENAME.txt" >> "$PROGRESS_FILE"
|
collectors/macos/audit.sh
CHANGED
|
@@ -474,9 +474,14 @@ else
|
|
| 474 |
fi
|
| 475 |
|
| 476 |
# Known vulnerabilities: the software inventory is collected here; matching against offline OSV/NVD data comes in a later version.
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
|
| 481 |
# ---------------------------------------------------------------------------
|
| 482 |
# 2. GDPR technical controls
|
|
@@ -759,6 +764,20 @@ evidence_json() {
|
|
| 759 |
"$(count Compliant)" "$(count Non-Compliant)" "$(count NotApplicable)" "$(count Pending)" "$(count Error)"
|
| 760 |
}
|
| 761 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 762 |
is_root || echo "Warning: not running as root. Some checks will report Error. Run: sudo $0" >&2
|
| 763 |
|
| 764 |
STAMP=$(date '+%Y%m%d-%H%M%S')
|
|
@@ -766,6 +785,7 @@ BASENAME="audit-macos-$HOSTNAME_VALUE-$STAMP"
|
|
| 766 |
if mkdir -p "$OUTPUT_DIR" 2>/dev/null && [ -w "$OUTPUT_DIR" ]; then
|
| 767 |
report | tee "$OUTPUT_DIR/$BASENAME.txt"
|
| 768 |
evidence_json > "$OUTPUT_DIR/$BASENAME.json"
|
|
|
|
| 769 |
echo "Report: $OUTPUT_DIR/$BASENAME.txt" >&2
|
| 770 |
echo "Evidence: $OUTPUT_DIR/$BASENAME.json" >&2
|
| 771 |
[ -n "$PROGRESS_FILE" ] && printf 'DONE\t%s\t%s\n' "$OUTPUT_DIR/$BASENAME.json" "$OUTPUT_DIR/$BASENAME.txt" >> "$PROGRESS_FILE"
|
|
|
|
| 474 |
fi
|
| 475 |
|
| 476 |
# Known vulnerabilities: the software inventory is collected here; matching against offline OSV/NVD data comes in a later version.
|
| 477 |
+
# Applications in /Applications (one folder level deep, e.g. "Adobe Acrobat DC/") and the signed-in user's ~/Applications.
|
| 478 |
+
APP_BUNDLES=()
|
| 479 |
+
CONSOLE_HOME=""; [ -n "$CONSOLE_USER" ] && CONSOLE_HOME=$(dscl . -read "/Users/$CONSOLE_USER" NFSHomeDirectory 2>/dev/null | awk '{ print $2 }')
|
| 480 |
+
for app in /Applications/*.app /Applications/*/*.app ${CONSOLE_HOME:+"$CONSOLE_HOME"/Applications/*.app}; do
|
| 481 |
+
[ -f "$app/Contents/Info.plist" ] && APP_BUNDLES+=("$app")
|
| 482 |
+
done
|
| 483 |
+
app_count=${#APP_BUNDLES[@]}
|
| 484 |
+
add vuln.known_vulnerabilities $S "Known vulnerabilities in installed software" Pending "$app_count applications inventoried" "<= $B_MAX_CRITICAL_HIGH_VULNERABILITIES critical/high" "Inventory saved for the Devseis app, which matches it against its offline OSV/NVD vulnerability data; the collector on its own does not match."
|
| 485 |
|
| 486 |
# ---------------------------------------------------------------------------
|
| 487 |
# 2. GDPR technical controls
|
|
|
|
| 764 |
"$(count Compliant)" "$(count Non-Compliant)" "$(count NotApplicable)" "$(count Pending)" "$(count Error)"
|
| 765 |
}
|
| 766 |
|
| 767 |
+
# Software inventory for the app's offline vulnerability matching (names and versions only).
|
| 768 |
+
write_inventory() {
|
| 769 |
+
local first=1 app name version
|
| 770 |
+
printf '{"format": 1, "os_family": "macos", "os_version": "%s", "apps": [' "$(json_escape "$OS_VERSION")"
|
| 771 |
+
for app in ${APP_BUNDLES[@]+"${APP_BUNDLES[@]}"}; do
|
| 772 |
+
name=$(basename "$app" .app)
|
| 773 |
+
version=$(plutil -extract CFBundleShortVersionString raw -o - "$app/Contents/Info.plist" 2>/dev/null)
|
| 774 |
+
[ -z "$version" ] && version=$(plutil -extract CFBundleVersion raw -o - "$app/Contents/Info.plist" 2>/dev/null)
|
| 775 |
+
[ "$first" -eq 1 ] && first=0 || printf ','
|
| 776 |
+
printf '{"name":"%s","version":"%s","path":"%s"}' "$(json_escape "$name")" "$(json_escape "$version")" "$(json_escape "$app")"
|
| 777 |
+
done
|
| 778 |
+
printf ']}\n'
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
is_root || echo "Warning: not running as root. Some checks will report Error. Run: sudo $0" >&2
|
| 782 |
|
| 783 |
STAMP=$(date '+%Y%m%d-%H%M%S')
|
|
|
|
| 785 |
if mkdir -p "$OUTPUT_DIR" 2>/dev/null && [ -w "$OUTPUT_DIR" ]; then
|
| 786 |
report | tee "$OUTPUT_DIR/$BASENAME.txt"
|
| 787 |
evidence_json > "$OUTPUT_DIR/$BASENAME.json"
|
| 788 |
+
write_inventory > "$OUTPUT_DIR/$BASENAME-inventory.json"
|
| 789 |
echo "Report: $OUTPUT_DIR/$BASENAME.txt" >&2
|
| 790 |
echo "Evidence: $OUTPUT_DIR/$BASENAME.json" >&2
|
| 791 |
[ -n "$PROGRESS_FILE" ] && printf 'DONE\t%s\t%s\n' "$OUTPUT_DIR/$BASENAME.json" "$OUTPUT_DIR/$BASENAME.txt" >> "$PROGRESS_FILE"
|
collectors/windows/audit.ps1
CHANGED
|
@@ -392,11 +392,18 @@ Check 'vuln.outdated_apps' $S 'Outdated third-party applications' "<= $maxOutdat
|
|
| 392 |
Pass ($rows.Count -le $maxOutdated) "$($rows.Count) outdated" $detail
|
| 393 |
}
|
| 394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
Check 'vuln.known_vulnerabilities' $S 'Known vulnerabilities in installed software' "<= $($B.MAX_CRITICAL_HIGH_VULNERABILITIES) critical/high" {
|
| 396 |
# Inventory now; matching against offline OSV/NVD data comes in a later version.
|
| 397 |
-
$
|
| 398 |
-
$apps = @(Get-ItemProperty -Path $keys -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -and -not $_.SystemComponent } | Select-Object -ExpandProperty DisplayName -Unique)
|
| 399 |
-
State 'Pending' "$($apps.Count) applications inventoried" 'Matching installed versions against offline OSV/NVD vulnerability data is not available in collector 0.2.'
|
| 400 |
}
|
| 401 |
|
| 402 |
# ---------------------------------------------------------------------------
|
|
@@ -644,6 +651,8 @@ try {
|
|
| 644 |
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
| 645 |
[IO.File]::WriteAllText("$base.txt", $ReportText, $utf8)
|
| 646 |
[IO.File]::WriteAllText("$base.json", ($Evidence | ConvertTo-Json -Depth 6), $utf8)
|
|
|
|
|
|
|
| 647 |
Write-Host "Report: $base.txt"
|
| 648 |
Write-Host "Evidence: $base.json"
|
| 649 |
if ($Progress) { [IO.File]::AppendAllText($Progress, "DONE`t$base.json`t$base.txt`n") }
|
|
|
|
| 392 |
Pass ($rows.Count -le $maxOutdated) "$($rows.Count) outdated" $detail
|
| 393 |
}
|
| 394 |
|
| 395 |
+
# Software inventory for the app's offline vulnerability matching: machine-wide and per-user installs (names and versions only).
|
| 396 |
+
$UninstallKeys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
|
| 397 |
+
foreach ($hive in Get-ChildItem -Path 'Registry::HKEY_USERS' -ErrorAction SilentlyContinue) {
|
| 398 |
+
if ($hive.PSChildName -match '^S-1-(5-21|12-1)-[\d-]+$') { $UninstallKeys += "Registry::HKEY_USERS\$($hive.PSChildName)\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" }
|
| 399 |
+
}
|
| 400 |
+
$Inventory = @(Get-ItemProperty -Path $UninstallKeys -ErrorAction SilentlyContinue |
|
| 401 |
+
Where-Object { $_.DisplayName -and -not $_.SystemComponent -and -not $_.ParentKeyName } |
|
| 402 |
+
ForEach-Object { [ordered]@{ name = "$($_.DisplayName)".Trim(); version = "$($_.DisplayVersion)".Trim(); publisher = "$($_.Publisher)".Trim() } } |
|
| 403 |
+
Sort-Object { $_.name + '|' + $_.version } -Unique)
|
| 404 |
Check 'vuln.known_vulnerabilities' $S 'Known vulnerabilities in installed software' "<= $($B.MAX_CRITICAL_HIGH_VULNERABILITIES) critical/high" {
|
| 405 |
# Inventory now; matching against offline OSV/NVD data comes in a later version.
|
| 406 |
+
State 'Pending' "$($Inventory.Count) applications inventoried" 'Inventory saved for the Devseis app, which matches it against its offline OSV/NVD vulnerability data; the collector on its own does not match.'
|
|
|
|
|
|
|
| 407 |
}
|
| 408 |
|
| 409 |
# ---------------------------------------------------------------------------
|
|
|
|
| 651 |
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
| 652 |
[IO.File]::WriteAllText("$base.txt", $ReportText, $utf8)
|
| 653 |
[IO.File]::WriteAllText("$base.json", ($Evidence | ConvertTo-Json -Depth 6), $utf8)
|
| 654 |
+
$InventoryDoc = [ordered]@{ format = 1; os_family = 'windows'; os_build = "$($OsInfo.BuildNumber)"; apps = @($Inventory) }
|
| 655 |
+
[IO.File]::WriteAllText("$base-inventory.json", ($InventoryDoc | ConvertTo-Json -Depth 4), $utf8)
|
| 656 |
Write-Host "Report: $base.txt"
|
| 657 |
Write-Host "Evidence: $base.json"
|
| 658 |
if ($Progress) { [IO.File]::AppendAllText($Progress, "DONE`t$base.json`t$base.txt`n") }
|
docs/CONTROLS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
Catalog version 0.2.0 · 68 checks. Generated by `tools/build_controls_doc.py` — do not edit by hand.
|
| 4 |
|
| 5 |
-
All sources are read-only. Internet is only used by *Pending security updates* on Windows and macOS.
|
| 6 |
|
| 7 |
## COMPLIANCE RESULTS (43)
|
| 8 |
|
|
@@ -50,7 +50,7 @@ All sources are read-only. Internet is only used by *Pending security updates* o
|
|
| 50 |
| Signed-in user account type | windows, linux, macos | ISO A.8.2; ISO A.5.15; GDPR Art. 32(1)(b) | The everyday signed-in user is a Standard account (not an administrator), unless listed in APPROVED_ADMINS. | signed-in user (Win32_ComputerSystem) vs Administrators group | session users (loginctl) vs sudo/admin/wheel | console user (stat /dev/console) + dsmemberutil checkmembership |
|
| 51 |
| Pending security updates | windows, linux, macos | ISO A.8.8; GDPR Art. 32(1)(b); GDPR Art. 32(1)(d) | Security updates offered by the OS vendor but not yet installed <= MAX_PENDING_SECURITY_UPDATES. | Windows Update Agent API (Microsoft.Update.Session search) - needs internet | apt-get -s upgrade (security) / dnf updateinfo --security - uses local package lists | softwareupdate -l - needs internet |
|
| 52 |
| Outdated third-party applications | windows, linux, macos | ISO A.8.8; ISO A.8.19; GDPR Art. 32(1)(b) | Installed third-party applications with a newer version available <= MAX_OUTDATED_APPS (Windows: winget; macOS: app versions; Linux: snap/flatpak and packages). | winget upgrade | apt upgradable, snap refresh --list, flatpak updates | brew outdated (Homebrew; App Store apps not covered) |
|
| 53 |
-
| Known vulnerabilities in installed software | windows, linux, macos | ISO A.8.8; GDPR Art. 32(1)(b) | Installed software versions matched against an offline copy of the OSV/NVD vulnerability data: critical or high vulnerabilities <= MAX_CRITICAL_HIGH_VULNERABILITIES. | installed programs (uninstall registry
|
| 54 |
|
| 55 |
## GDPR TECHNICAL CONTROLS (12)
|
| 56 |
|
|
|
|
| 2 |
|
| 3 |
Catalog version 0.2.0 · 68 checks. Generated by `tools/build_controls_doc.py` — do not edit by hand.
|
| 4 |
|
| 5 |
+
All sources are read-only. Internet is only used by *Pending security updates* on Windows and macOS, and by the app to refresh the vulnerability bundle.
|
| 6 |
|
| 7 |
## COMPLIANCE RESULTS (43)
|
| 8 |
|
|
|
|
| 50 |
| Signed-in user account type | windows, linux, macos | ISO A.8.2; ISO A.5.15; GDPR Art. 32(1)(b) | The everyday signed-in user is a Standard account (not an administrator), unless listed in APPROVED_ADMINS. | signed-in user (Win32_ComputerSystem) vs Administrators group | session users (loginctl) vs sudo/admin/wheel | console user (stat /dev/console) + dsmemberutil checkmembership |
|
| 51 |
| Pending security updates | windows, linux, macos | ISO A.8.8; GDPR Art. 32(1)(b); GDPR Art. 32(1)(d) | Security updates offered by the OS vendor but not yet installed <= MAX_PENDING_SECURITY_UPDATES. | Windows Update Agent API (Microsoft.Update.Session search) - needs internet | apt-get -s upgrade (security) / dnf updateinfo --security - uses local package lists | softwareupdate -l - needs internet |
|
| 52 |
| Outdated third-party applications | windows, linux, macos | ISO A.8.8; ISO A.8.19; GDPR Art. 32(1)(b) | Installed third-party applications with a newer version available <= MAX_OUTDATED_APPS (Windows: winget; macOS: app versions; Linux: snap/flatpak and packages). | winget upgrade | apt upgradable, snap refresh --list, flatpak updates | brew outdated (Homebrew; App Store apps not covered) |
|
| 53 |
+
| Known vulnerabilities in installed software | windows, linux, macos | ISO A.8.8; GDPR Art. 32(1)(b) | Installed software versions matched against an offline copy of the OSV/NVD vulnerability data: critical or high vulnerabilities <= MAX_CRITICAL_HIGH_VULNERABILITIES. | installed programs (machine and per-user uninstall registry) matched by the app against the signed offline bundle (NVD ranges, CISA KEV, EPSS) | dpkg/rpm package list (with source packages) matched by the app against the signed offline bundle (OSV: Ubuntu, Debian, RHEL, AlmaLinux, Rocky) | app bundle versions (/Applications, ~/Applications) matched by the app against the signed offline bundle (NVD ranges, CISA KEV, EPSS) |
|
| 54 |
|
| 55 |
## GDPR TECHNICAL CONTROLS (12)
|
| 56 |
|
tools/build_controls_doc.py
CHANGED
|
@@ -53,7 +53,7 @@ SOURCES = {
|
|
| 53 |
"encryption.recovery": {"windows": "Get-BitLockerVolume: KeyProtector (RecoveryPassword)", "linux": "cryptsetup luksDump (key slots, tokens)", "macos": "fdesetup haspersonalrecoverykey / hasinstitutionalrecoverykey"},
|
| 54 |
"vuln.pending_updates": {"windows": "Windows Update Agent API (Microsoft.Update.Session search) - needs internet", "linux": "apt-get -s upgrade (security) / dnf updateinfo --security - uses local package lists", "macos": "softwareupdate -l - needs internet"},
|
| 55 |
"vuln.outdated_apps": {"windows": "winget upgrade", "linux": "apt upgradable, snap refresh --list, flatpak updates", "macos": "brew outdated (Homebrew; App Store apps not covered)"},
|
| 56 |
-
"vuln.known_vulnerabilities": {"windows": "installed programs (uninstall registry
|
| 57 |
"gdpr.auto_updates": {"windows": "WindowsUpdate\\AU policy (NoAutoUpdate, AUOptions), wuauserv start type", "linux": "apt-config Unattended-Upgrade / dnf-automatic timer", "macos": "com.apple.SoftwareUpdate AutomaticCheck/Download/Install keys"},
|
| 58 |
"gdpr.updates_recent": {"windows": "Windows Update history (COM) or Get-HotFix", "linux": "/var/log/apt/history.log / rpm -qa --last", "macos": "/Library/Receipts/InstallHistory.plist (softwareupdated)"},
|
| 59 |
"gdpr.os_supported": {"windows": "Win32_OperatingSystem BuildNumber vs WINDOWS_MIN_BUILD", "linux": "/etc/os-release VERSION_ID vs baseline minimum", "macos": "sw_vers -productVersion vs MACOS_MIN_MAJOR"},
|
|
@@ -84,7 +84,7 @@ def main():
|
|
| 84 |
"",
|
| 85 |
f"Catalog version {catalog['catalog_version']} · {len(catalog['checks'])} checks. Generated by `tools/build_controls_doc.py` — do not edit by hand.",
|
| 86 |
"",
|
| 87 |
-
"All sources are read-only. Internet is only used by *Pending security updates* on Windows and macOS.",
|
| 88 |
"",
|
| 89 |
]
|
| 90 |
for section in catalog["sections"]:
|
|
|
|
| 53 |
"encryption.recovery": {"windows": "Get-BitLockerVolume: KeyProtector (RecoveryPassword)", "linux": "cryptsetup luksDump (key slots, tokens)", "macos": "fdesetup haspersonalrecoverykey / hasinstitutionalrecoverykey"},
|
| 54 |
"vuln.pending_updates": {"windows": "Windows Update Agent API (Microsoft.Update.Session search) - needs internet", "linux": "apt-get -s upgrade (security) / dnf updateinfo --security - uses local package lists", "macos": "softwareupdate -l - needs internet"},
|
| 55 |
"vuln.outdated_apps": {"windows": "winget upgrade", "linux": "apt upgradable, snap refresh --list, flatpak updates", "macos": "brew outdated (Homebrew; App Store apps not covered)"},
|
| 56 |
+
"vuln.known_vulnerabilities": {"windows": "installed programs (machine and per-user uninstall registry) matched by the app against the signed offline bundle (NVD ranges, CISA KEV, EPSS)", "linux": "dpkg/rpm package list (with source packages) matched by the app against the signed offline bundle (OSV: Ubuntu, Debian, RHEL, AlmaLinux, Rocky)", "macos": "app bundle versions (/Applications, ~/Applications) matched by the app against the signed offline bundle (NVD ranges, CISA KEV, EPSS)"},
|
| 57 |
"gdpr.auto_updates": {"windows": "WindowsUpdate\\AU policy (NoAutoUpdate, AUOptions), wuauserv start type", "linux": "apt-config Unattended-Upgrade / dnf-automatic timer", "macos": "com.apple.SoftwareUpdate AutomaticCheck/Download/Install keys"},
|
| 58 |
"gdpr.updates_recent": {"windows": "Windows Update history (COM) or Get-HotFix", "linux": "/var/log/apt/history.log / rpm -qa --last", "macos": "/Library/Receipts/InstallHistory.plist (softwareupdated)"},
|
| 59 |
"gdpr.os_supported": {"windows": "Win32_OperatingSystem BuildNumber vs WINDOWS_MIN_BUILD", "linux": "/etc/os-release VERSION_ID vs baseline minimum", "macos": "sw_vers -productVersion vs MACOS_MIN_MAJOR"},
|
|
|
|
| 84 |
"",
|
| 85 |
f"Catalog version {catalog['catalog_version']} · {len(catalog['checks'])} checks. Generated by `tools/build_controls_doc.py` — do not edit by hand.",
|
| 86 |
"",
|
| 87 |
+
"All sources are read-only. Internet is only used by *Pending security updates* on Windows and macOS, and by the app to refresh the vulnerability bundle.",
|
| 88 |
"",
|
| 89 |
]
|
| 90 |
for section in catalog["sections"]:
|
tools/match_vulns.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
// Match a collector run's software inventory against the offline vulnerability bundle, as the app does.
|
| 3 |
+
// Usage: node tools/match_vulns.cjs EVIDENCE.json [--bundle DIR] [--write]
|
| 4 |
+
// EVIDENCE-inventory.json must sit next to the evidence file. --write updates the evidence file in place.
|
| 5 |
+
'use strict';
|
| 6 |
+
const fs = require('node:fs');
|
| 7 |
+
const path = require('node:path');
|
| 8 |
+
const vulndb = require('../app/vulndb.cjs');
|
| 9 |
+
|
| 10 |
+
const args = process.argv.slice(2);
|
| 11 |
+
const evidencePath = args.find(a => !a.startsWith('--') && args[args.indexOf(a) - 1] !== '--bundle');
|
| 12 |
+
if (!evidencePath) { console.error('Usage: node tools/match_vulns.cjs EVIDENCE.json [--bundle DIR] [--write]'); process.exit(2); }
|
| 13 |
+
const bundleDir = args.includes('--bundle') ? args[args.indexOf('--bundle') + 1] : path.join(__dirname, '..', 'vulndb', 'out');
|
| 14 |
+
const read = p => JSON.parse(fs.readFileSync(p, 'utf8').replace(/^/, ''));
|
| 15 |
+
|
| 16 |
+
const evidence = read(evidencePath);
|
| 17 |
+
const inventory = read(evidencePath.replace(/\.json$/, '-inventory.json'));
|
| 18 |
+
const loaded = vulndb.load([bundleDir]);
|
| 19 |
+
if (loaded.error) { console.error(loaded.error); process.exit(1); }
|
| 20 |
+
const max = parseInt((evidence.baseline || {}).MAX_CRITICAL_HIGH_VULNERABILITIES || '0', 10) || 0;
|
| 21 |
+
vulndb.apply(evidence, inventory, loaded, max);
|
| 22 |
+
const r = evidence.results.find(x => x.id === 'vuln.known_vulnerabilities');
|
| 23 |
+
console.log(`${r.status} | ${r.actual}\n${r.detail}`);
|
| 24 |
+
if (args.includes('--write')) fs.writeFileSync(evidencePath, JSON.stringify(evidence, null, 2));
|
vulndb/build_bundle.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build the offline vulnerability bundle the Devseis app matches installed software against.
|
| 3 |
+
|
| 4 |
+
Runs on the Devseis side (needs internet); clients only download the finished bundle.
|
| 5 |
+
Sources (all public):
|
| 6 |
+
OSV.dev Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux package advisories (CC-BY 4.0)
|
| 7 |
+
NVD CVEs for the desktop applications in products.json (public domain)
|
| 8 |
+
CISA KEV known exploited vulnerabilities (CC0)
|
| 9 |
+
EPSS exploit prediction scores (FIRST.org, free with attribution)
|
| 10 |
+
|
| 11 |
+
Only actionable data is kept: vulnerabilities with a fixed version, for releases still in use.
|
| 12 |
+
|
| 13 |
+
Usage:
|
| 14 |
+
python3 vulndb/build_bundle.py # download what is missing, build vulndb/out/
|
| 15 |
+
python3 vulndb/build_bundle.py --refresh # download everything again
|
| 16 |
+
python3 vulndb/build_bundle.py --only nvd # just refresh the NVD cache
|
| 17 |
+
Standard library only.
|
| 18 |
+
"""
|
| 19 |
+
import argparse
|
| 20 |
+
import csv
|
| 21 |
+
import datetime
|
| 22 |
+
import gzip
|
| 23 |
+
import hashlib
|
| 24 |
+
import io
|
| 25 |
+
import json
|
| 26 |
+
import math
|
| 27 |
+
import os
|
| 28 |
+
import re
|
| 29 |
+
import sys
|
| 30 |
+
import time
|
| 31 |
+
import urllib.parse
|
| 32 |
+
import urllib.request
|
| 33 |
+
import zipfile
|
| 34 |
+
|
| 35 |
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 36 |
+
CACHE = os.path.join(HERE, "cache")
|
| 37 |
+
OUT = os.path.join(HERE, "out")
|
| 38 |
+
BUNDLE_FORMAT = 1
|
| 39 |
+
USER_AGENT = "Devseis-Endpoint-Auditor-vulndb/0.1"
|
| 40 |
+
|
| 41 |
+
OSV_ECOSYSTEMS = ["Ubuntu", "Debian", "Red Hat", "AlmaLinux", "Rocky Linux"]
|
| 42 |
+
KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"
|
| 43 |
+
EPSS_URL = "https://epss.empiricalsecurity.com/epss_scores-current.csv.gz"
|
| 44 |
+
NVD_URL = "https://services.nvd.nist.gov/rest/json/cves/2.0"
|
| 45 |
+
NVD_PAUSE = 6.5 # public API: 5 requests per 30 seconds without a key
|
| 46 |
+
|
| 47 |
+
# Releases kept in the bundle (older ones are out of support and flagged by gdpr.os_supported).
|
| 48 |
+
KEEP = {
|
| 49 |
+
"ubuntu": lambda v: v >= (22, 4),
|
| 50 |
+
"debian": lambda v: v >= (11,),
|
| 51 |
+
"rhel": lambda v: v >= (8,),
|
| 52 |
+
"almalinux": lambda v: v >= (8,),
|
| 53 |
+
"rocky": lambda v: v >= (8,),
|
| 54 |
+
}
|
| 55 |
+
SEVERITIES = ["critical", "high", "medium", "low", "unknown"]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def log(msg):
|
| 59 |
+
print(msg, flush=True)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def fetch(url, path, refresh=False):
|
| 63 |
+
if os.path.exists(path) and not refresh:
|
| 64 |
+
return path
|
| 65 |
+
tmp = path + ".part"
|
| 66 |
+
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
|
| 67 |
+
with urllib.request.urlopen(req, timeout=600) as resp, open(tmp, "wb") as handle:
|
| 68 |
+
while True:
|
| 69 |
+
chunk = resp.read(1 << 20)
|
| 70 |
+
if not chunk:
|
| 71 |
+
break
|
| 72 |
+
handle.write(chunk)
|
| 73 |
+
os.replace(tmp, path)
|
| 74 |
+
return path
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def vtuple(text):
|
| 78 |
+
return tuple(int(x) for x in re.findall(r"\d+", text))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# --- severity ---------------------------------------------------------------------------
|
| 82 |
+
def cvss3_score(vector):
|
| 83 |
+
"""Base score from a CVSS v3.x vector (FIRST specification)."""
|
| 84 |
+
try:
|
| 85 |
+
m = dict(part.split(":") for part in vector.split("/")[1:])
|
| 86 |
+
av = {"N": 0.85, "A": 0.62, "L": 0.55, "P": 0.2}[m["AV"]]
|
| 87 |
+
ac = {"L": 0.77, "H": 0.44}[m["AC"]]
|
| 88 |
+
changed = m["S"] == "C"
|
| 89 |
+
pr = {"N": 0.85, "L": 0.68 if changed else 0.62, "H": 0.5 if changed else 0.27}[m["PR"]]
|
| 90 |
+
ui = {"N": 0.85, "R": 0.62}[m["UI"]]
|
| 91 |
+
cia = [{"H": 0.56, "L": 0.22, "N": 0.0}[m[k]] for k in ("C", "I", "A")]
|
| 92 |
+
except (KeyError, ValueError):
|
| 93 |
+
return None
|
| 94 |
+
iss = 1 - (1 - cia[0]) * (1 - cia[1]) * (1 - cia[2])
|
| 95 |
+
impact = 7.52 * (iss - 0.029) - 3.25 * (iss - 0.02) ** 15 if changed else 6.42 * iss
|
| 96 |
+
if impact <= 0:
|
| 97 |
+
return 0.0
|
| 98 |
+
exploit = 8.22 * av * ac * pr * ui
|
| 99 |
+
raw = min(1.08 * (impact + exploit), 10) if changed else min(impact + exploit, 10)
|
| 100 |
+
return math.ceil(raw * 10 - 1e-9) / 10
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def severity_from_score(score):
|
| 104 |
+
if score is None:
|
| 105 |
+
return "unknown"
|
| 106 |
+
return "critical" if score >= 9 else "high" if score >= 7 else "medium" if score >= 4 else "low" if score > 0 else "unknown"
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def osv_severity(record):
|
| 110 |
+
"""Distribution rating if present, else computed from a CVSS v3 vector."""
|
| 111 |
+
for sev in record.get("severity", []):
|
| 112 |
+
if sev.get("type") == "Ubuntu":
|
| 113 |
+
return {"negligible": "low"}.get(sev["score"].lower(), sev["score"].lower())
|
| 114 |
+
for source in (record.get("database_specific") or {}, *(a.get("ecosystem_specific") or {} for a in record.get("affected", []))):
|
| 115 |
+
rating = str(source.get("severity", "")).lower()
|
| 116 |
+
if rating in ("critical", "important", "high", "moderate", "medium", "low"):
|
| 117 |
+
return {"important": "high", "moderate": "medium"}.get(rating, rating)
|
| 118 |
+
for sev in record.get("severity", []):
|
| 119 |
+
if sev.get("type", "").startswith("CVSS_V3"):
|
| 120 |
+
return severity_from_score(cvss3_score(sev["score"]))
|
| 121 |
+
return "unknown"
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
# --- OSV (Linux distributions) ------------------------------------------------------------
|
| 125 |
+
def release_key(ecosystem):
|
| 126 |
+
"""'Ubuntu:24.04:LTS' -> 'ubuntu:24.04'; None for releases or streams we do not keep."""
|
| 127 |
+
parts = ecosystem.split(":")
|
| 128 |
+
name = parts[0]
|
| 129 |
+
if name == "Ubuntu":
|
| 130 |
+
if len(parts) < 2 or parts[1] == "Pro" or not re.match(r"^\d+\.\d+$", parts[1]):
|
| 131 |
+
return None
|
| 132 |
+
family, version = "ubuntu", parts[1]
|
| 133 |
+
elif name == "Debian":
|
| 134 |
+
if len(parts) < 2 or not parts[1].isdigit():
|
| 135 |
+
return None
|
| 136 |
+
family, version = "debian", parts[1]
|
| 137 |
+
elif name == "Red Hat":
|
| 138 |
+
# Red Hat:enterprise_linux:9::baseos (EUS, SAP and other streams are skipped)
|
| 139 |
+
if len(parts) < 3 or parts[1] != "enterprise_linux" or not re.match(r"^\d+$", parts[2]):
|
| 140 |
+
return None
|
| 141 |
+
family, version = "rhel", parts[2]
|
| 142 |
+
elif name in ("AlmaLinux", "Rocky Linux"):
|
| 143 |
+
if len(parts) < 2 or not re.match(r"^\d+$", parts[1]):
|
| 144 |
+
return None
|
| 145 |
+
family, version = ("almalinux" if name == "AlmaLinux" else "rocky"), parts[1]
|
| 146 |
+
else:
|
| 147 |
+
return None
|
| 148 |
+
return f"{family}:{version}" if KEEP[family](vtuple(version)) else None
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def cve_ids(record):
|
| 152 |
+
ids = {i for i in [record["id"], *record.get("aliases", []), *record.get("upstream", []), *record.get("related", [])] if i.startswith("CVE-")}
|
| 153 |
+
return sorted(ids)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def build_osv(stats):
|
| 157 |
+
releases = {}
|
| 158 |
+
rating = {} # CVE -> best known rating from any distribution
|
| 159 |
+
for eco in OSV_ECOSYSTEMS:
|
| 160 |
+
path = os.path.join(CACHE, f"osv-{eco.replace(' ', '_')}.zip")
|
| 161 |
+
if not os.path.exists(path):
|
| 162 |
+
log(f" {eco}: not downloaded, skipped")
|
| 163 |
+
continue
|
| 164 |
+
kept = 0
|
| 165 |
+
with zipfile.ZipFile(path) as archive:
|
| 166 |
+
names = archive.namelist()
|
| 167 |
+
for name in names:
|
| 168 |
+
record = json.loads(archive.read(name))
|
| 169 |
+
if record.get("withdrawn"):
|
| 170 |
+
continue
|
| 171 |
+
# Debian publishes DSA/DLA advisories and per-CVE records; the per-CVE ones carry the fixed versions.
|
| 172 |
+
if eco == "Debian" and not record["id"].startswith("DEBIAN-CVE-"):
|
| 173 |
+
continue
|
| 174 |
+
cves = cve_ids(record)
|
| 175 |
+
if not cves:
|
| 176 |
+
continue # bug-fix / enhancement advisories
|
| 177 |
+
advisory = record["id"] if not record["id"].startswith(("UBUNTU-CVE-", "DEBIAN-CVE-")) else ""
|
| 178 |
+
severity = osv_severity(record)
|
| 179 |
+
if severity != "unknown":
|
| 180 |
+
for cve in cves:
|
| 181 |
+
rating.setdefault(cve, severity)
|
| 182 |
+
for affected in record.get("affected", []):
|
| 183 |
+
key = release_key(affected["package"]["ecosystem"])
|
| 184 |
+
if not key or "-sig-" in affected["package"].get("purl", ""): # special-interest builds (e.g. cloud kernels)
|
| 185 |
+
continue
|
| 186 |
+
for rng in affected.get("ranges", []):
|
| 187 |
+
if rng.get("type") != "ECOSYSTEM":
|
| 188 |
+
continue
|
| 189 |
+
for event in rng.get("events", []):
|
| 190 |
+
if "fixed" not in event:
|
| 191 |
+
continue
|
| 192 |
+
entry = ["|".join(cves) or record["id"], advisory, event["fixed"], severity]
|
| 193 |
+
releases.setdefault(key, {}).setdefault(affected["package"]["name"], []).append(entry)
|
| 194 |
+
kept += 1
|
| 195 |
+
log(f" {eco}: {len(names)} records, {kept} fixed-version entries kept")
|
| 196 |
+
# Some records carry no rating (AlmaLinux, some Debian): borrow another distribution's rating for the same CVE.
|
| 197 |
+
borrowed = 0
|
| 198 |
+
for key, packages in releases.items():
|
| 199 |
+
for entries in packages.values():
|
| 200 |
+
unique = {}
|
| 201 |
+
for entry in entries:
|
| 202 |
+
if entry[3] == "unknown":
|
| 203 |
+
for cve in entry[0].split("|"):
|
| 204 |
+
if cve in rating:
|
| 205 |
+
entry[3] = rating[cve]
|
| 206 |
+
borrowed += 1
|
| 207 |
+
break
|
| 208 |
+
unique[(entry[0], entry[1], entry[2])] = entry
|
| 209 |
+
entries[:] = sorted(unique.values())
|
| 210 |
+
stats["osv"] = {key: sum(len(v) for v in pkgs.values()) for key, pkgs in sorted(releases.items())}
|
| 211 |
+
stats["osv_ratings_borrowed"] = borrowed
|
| 212 |
+
return releases
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
# --- NVD (desktop applications) ----------------------------------------------------------------
|
| 216 |
+
def nvd_query(cpe):
|
| 217 |
+
"""All CVEs for vendor:product, cached as raw pages."""
|
| 218 |
+
vendor, product = cpe.split(":", 1)
|
| 219 |
+
path = os.path.join(CACHE, "nvd", re.sub(r"[^A-Za-z0-9_.-]", "_", cpe) + ".json")
|
| 220 |
+
if os.path.exists(path):
|
| 221 |
+
with open(path, encoding="utf-8") as handle:
|
| 222 |
+
return json.load(handle)
|
| 223 |
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
| 224 |
+
items, start = [], 0
|
| 225 |
+
while True:
|
| 226 |
+
params = urllib.parse.urlencode({"virtualMatchString": f"cpe:2.3:a:{vendor}:{product}", "startIndex": start, "noRejected": ""})
|
| 227 |
+
url = f"{NVD_URL}?{params}".replace("noRejected=", "noRejected")
|
| 228 |
+
for attempt in range(5):
|
| 229 |
+
try:
|
| 230 |
+
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
|
| 231 |
+
if os.environ.get("NVD_API_KEY"):
|
| 232 |
+
req.add_header("apiKey", os.environ["NVD_API_KEY"])
|
| 233 |
+
with urllib.request.urlopen(req, timeout=120) as resp:
|
| 234 |
+
page = json.load(resp)
|
| 235 |
+
break
|
| 236 |
+
except Exception as exc: # rate limit or transient error: wait and retry
|
| 237 |
+
log(f" {cpe} page {start}: {exc}; retrying")
|
| 238 |
+
time.sleep(30 * (attempt + 1))
|
| 239 |
+
else:
|
| 240 |
+
raise RuntimeError(f"NVD query failed for {cpe}")
|
| 241 |
+
items.extend(page.get("vulnerabilities", []))
|
| 242 |
+
start += page.get("resultsPerPage", 0)
|
| 243 |
+
time.sleep(NVD_PAUSE)
|
| 244 |
+
if start >= page.get("totalResults", 0) or not page.get("resultsPerPage"):
|
| 245 |
+
break
|
| 246 |
+
with open(path, "w", encoding="utf-8") as handle:
|
| 247 |
+
json.dump(items, handle)
|
| 248 |
+
return items
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def nvd_severity(cve):
|
| 252 |
+
metrics = cve.get("metrics", {})
|
| 253 |
+
for key in ("cvssMetricV31", "cvssMetricV30", "cvssMetricV40", "cvssMetricV2"):
|
| 254 |
+
rows = metrics.get(key) or []
|
| 255 |
+
rows = sorted(rows, key=lambda r: r.get("type") != "Primary")
|
| 256 |
+
for row in rows:
|
| 257 |
+
rating = (row.get("cvssData", {}).get("baseSeverity") or row.get("baseSeverity") or "").lower()
|
| 258 |
+
if rating in SEVERITIES:
|
| 259 |
+
return rating
|
| 260 |
+
if row.get("cvssData", {}).get("baseScore") is not None:
|
| 261 |
+
return severity_from_score(row["cvssData"]["baseScore"])
|
| 262 |
+
return "unknown"
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
def cpe_parts(criteria):
|
| 266 |
+
# cpe:2.3:a:vendor:product:version:... (escaped colons are not used by the products we track)
|
| 267 |
+
parts = re.split(r"(?<!\\):", criteria)
|
| 268 |
+
return parts[3], parts[4], parts[5]
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def build_nvd(products, stats):
|
| 272 |
+
apps = []
|
| 273 |
+
for product in products:
|
| 274 |
+
ranges = {}
|
| 275 |
+
for cpe in product["cpe"]:
|
| 276 |
+
vendor, name = cpe.split(":", 1)
|
| 277 |
+
for item in nvd_query(cpe):
|
| 278 |
+
cve = item["cve"]
|
| 279 |
+
severity = nvd_severity(cve)
|
| 280 |
+
for config in cve.get("configurations", []):
|
| 281 |
+
for node in config.get("nodes", []):
|
| 282 |
+
for match in node.get("cpeMatch", []):
|
| 283 |
+
if not match.get("vulnerable"):
|
| 284 |
+
continue
|
| 285 |
+
m_vendor, m_product, version = cpe_parts(match["criteria"])
|
| 286 |
+
if (m_vendor, m_product.replace("\\", "")) != (vendor, name.replace("\\", "")):
|
| 287 |
+
continue
|
| 288 |
+
exact = "" if version in ("*", "-") else version.replace("\\", "")
|
| 289 |
+
row = (cve["id"], severity, match.get("versionStartIncluding", ""), match.get("versionStartExcluding", ""),
|
| 290 |
+
match.get("versionEndIncluding", ""), match.get("versionEndExcluding", ""), exact)
|
| 291 |
+
if version == "-" or (not exact and not any(row[2:6])):
|
| 292 |
+
continue # "all versions" with no bound: cannot tell fixed from unfixed
|
| 293 |
+
ranges[row] = True
|
| 294 |
+
apps.append({"id": product["id"], "name": product["name"], "windows": product.get("windows", ""), "macos": product.get("macos", ""),
|
| 295 |
+
"cves": sorted(list(r) for r in ranges)})
|
| 296 |
+
stats["nvd"][product["id"]] = len({r[0] for r in ranges})
|
| 297 |
+
if not ranges:
|
| 298 |
+
log(f" warning: no NVD ranges for {product['id']} ({', '.join(product['cpe'])})")
|
| 299 |
+
return apps
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
# --- KEV and EPSS ----------------------------------------------------------------------------
|
| 303 |
+
def load_kev():
|
| 304 |
+
with open(os.path.join(CACHE, "kev.json"), encoding="utf-8") as handle:
|
| 305 |
+
data = json.load(handle)
|
| 306 |
+
return data.get("catalogVersion", ""), {v["cveID"] for v in data["vulnerabilities"]}
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def load_epss():
|
| 310 |
+
with gzip.open(os.path.join(CACHE, "epss.csv.gz"), "rt", encoding="utf-8") as handle:
|
| 311 |
+
first = handle.readline() # "#model_version:...,score_date:..."
|
| 312 |
+
scores = {row["cve"]: float(row["epss"]) for row in csv.DictReader(handle)}
|
| 313 |
+
date = re.search(r"score_date:(\S+)", first)
|
| 314 |
+
return (date.group(1)[:10] if date else ""), scores
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
def main():
|
| 318 |
+
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 319 |
+
parser.add_argument("--refresh", action="store_true", help="download every source again")
|
| 320 |
+
parser.add_argument("--only", choices=["nvd", "osv"], help="only refresh one source cache")
|
| 321 |
+
args = parser.parse_args()
|
| 322 |
+
os.makedirs(CACHE, exist_ok=True)
|
| 323 |
+
with open(os.path.join(HERE, "products.json"), encoding="utf-8") as handle:
|
| 324 |
+
products = json.load(handle)["products"]
|
| 325 |
+
|
| 326 |
+
if args.refresh and args.only != "osv":
|
| 327 |
+
for name in os.listdir(os.path.join(CACHE, "nvd")) if os.path.isdir(os.path.join(CACHE, "nvd")) else []:
|
| 328 |
+
os.remove(os.path.join(CACHE, "nvd", name))
|
| 329 |
+
if args.only != "nvd":
|
| 330 |
+
for eco in OSV_ECOSYSTEMS:
|
| 331 |
+
log(f"download OSV {eco}")
|
| 332 |
+
fetch(f"https://osv-vulnerabilities.storage.googleapis.com/{urllib.parse.quote(eco)}/all.zip",
|
| 333 |
+
os.path.join(CACHE, f"osv-{eco.replace(' ', '_')}.zip"), args.refresh)
|
| 334 |
+
fetch(KEV_URL, os.path.join(CACHE, "kev.json"), args.refresh)
|
| 335 |
+
fetch(EPSS_URL, os.path.join(CACHE, "epss.csv.gz"), args.refresh)
|
| 336 |
+
if args.only != "osv":
|
| 337 |
+
log("NVD desktop applications")
|
| 338 |
+
for product in products:
|
| 339 |
+
for cpe in product["cpe"]:
|
| 340 |
+
log(f" {cpe}: {len(nvd_query(cpe))} CVEs")
|
| 341 |
+
if args.only:
|
| 342 |
+
return
|
| 343 |
+
|
| 344 |
+
stats = {"nvd": {}}
|
| 345 |
+
log("OSV distributions")
|
| 346 |
+
releases = build_osv(stats)
|
| 347 |
+
log("NVD applications")
|
| 348 |
+
apps = build_nvd(products, stats)
|
| 349 |
+
kev_version, kev = load_kev()
|
| 350 |
+
epss_date, epss_all = load_epss()
|
| 351 |
+
|
| 352 |
+
used = set()
|
| 353 |
+
for packages in releases.values():
|
| 354 |
+
for entries in packages.values():
|
| 355 |
+
for entry in entries:
|
| 356 |
+
used.update(entry[0].split("|"))
|
| 357 |
+
for app in apps:
|
| 358 |
+
used.update(row[0] for row in app["cves"])
|
| 359 |
+
today = datetime.date.today().isoformat()
|
| 360 |
+
bundle = {
|
| 361 |
+
"format": BUNDLE_FORMAT,
|
| 362 |
+
"built_at": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
| 363 |
+
"sources": {
|
| 364 |
+
"osv": {"ecosystems": OSV_ECOSYSTEMS, "downloaded": today, "license": "CC-BY 4.0 (osv.dev)"},
|
| 365 |
+
"nvd": {"products": len(apps), "downloaded": today, "license": "Public domain (NIST NVD); not endorsed by NIST"},
|
| 366 |
+
"kev": {"catalog_version": kev_version, "license": "CC0 (CISA)"},
|
| 367 |
+
"epss": {"score_date": epss_date, "license": "FIRST.org EPSS, free with attribution"},
|
| 368 |
+
},
|
| 369 |
+
"notes": "Only vulnerabilities with a fixed version are included. Linux package names are source packages (Ubuntu, Debian) or binary RPM names (Red Hat family).",
|
| 370 |
+
"releases": releases,
|
| 371 |
+
"apps": apps,
|
| 372 |
+
"kev": sorted(used & kev),
|
| 373 |
+
"epss": {cve: round(epss_all[cve], 4) for cve in sorted(used) if cve in epss_all and epss_all[cve] >= 0.01},
|
| 374 |
+
}
|
| 375 |
+
os.makedirs(OUT, exist_ok=True)
|
| 376 |
+
name = f"devseis-vulndb-{today}.json.gz"
|
| 377 |
+
raw = json.dumps(bundle, separators=(",", ":")).encode("utf-8")
|
| 378 |
+
data = gzip.compress(raw, 9, mtime=0)
|
| 379 |
+
with open(os.path.join(OUT, name), "wb") as handle:
|
| 380 |
+
handle.write(data)
|
| 381 |
+
manifest = {
|
| 382 |
+
"format": BUNDLE_FORMAT, "file": name, "built_at": bundle["built_at"], "size": len(data),
|
| 383 |
+
"sha256": hashlib.sha256(data).hexdigest(), "sources": bundle["sources"],
|
| 384 |
+
"counts": {"releases": stats["osv"], "apps": stats["nvd"], "kev": len(bundle["kev"]), "epss": len(bundle["epss"])},
|
| 385 |
+
"signature": None,
|
| 386 |
+
}
|
| 387 |
+
with open(os.path.join(OUT, "manifest.json"), "w", encoding="utf-8") as handle:
|
| 388 |
+
json.dump(manifest, handle, indent=2)
|
| 389 |
+
log(f"\nWrote vulndb/out/{name}: {len(data) / 1048576:.1f} MB compressed ({len(raw) / 1048576:.1f} MB raw)")
|
| 390 |
+
log(json.dumps(manifest["counts"], indent=1))
|
| 391 |
+
log("Next: node vulndb/sign-bundle.mjs (adds the Ed25519 signature to manifest.json)")
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
if __name__ == "__main__":
|
| 395 |
+
sys.exit(main())
|
vulndb/products.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_comment": "Desktop applications matched against NVD. match: case-insensitive regex on the Windows program name (windows) or the macOS app bundle name without .app (macos). cpe: NVD vendor:product. Keep regexes tight: a wrong match produces false findings.",
|
| 3 |
+
"version": "0.1.0",
|
| 4 |
+
"products": [
|
| 5 |
+
{"id": "chrome", "name": "Google Chrome", "cpe": ["google:chrome"], "windows": "^Google Chrome$", "macos": "^Google Chrome$"},
|
| 6 |
+
{"id": "edge", "name": "Microsoft Edge", "cpe": ["microsoft:edge_chromium"], "windows": "^Microsoft Edge$", "macos": "^Microsoft Edge$"},
|
| 7 |
+
{"id": "firefox", "name": "Mozilla Firefox", "cpe": ["mozilla:firefox"], "windows": "^Mozilla Firefox( \\(x64.*\\)| \\(x86.*\\))?( [a-z]{2}(-[A-Z]{2})?)?$|^Mozilla Firefox \\d", "macos": "^Firefox$"},
|
| 8 |
+
{"id": "firefox_esr", "name": "Mozilla Firefox ESR", "cpe": ["mozilla:firefox_esr"], "windows": "^Mozilla Firefox ESR", "macos": "^Firefox ESR$"},
|
| 9 |
+
{"id": "thunderbird", "name": "Mozilla Thunderbird", "cpe": ["mozilla:thunderbird"], "windows": "^Mozilla Thunderbird", "macos": "^Thunderbird$"},
|
| 10 |
+
{"id": "acrobat_reader", "name": "Adobe Acrobat Reader", "cpe": ["adobe:acrobat_reader_dc", "adobe:acrobat_reader"], "windows": "^Adobe Acrobat Reader", "macos": "^Adobe Acrobat Reader"},
|
| 11 |
+
{"id": "acrobat", "name": "Adobe Acrobat", "cpe": ["adobe:acrobat_dc", "adobe:acrobat"], "windows": "^Adobe Acrobat( \\(64-bit\\)| DC| 20\\d\\d)?$", "macos": "^Adobe Acrobat( DC)?$"},
|
| 12 |
+
{"id": "7zip", "name": "7-Zip", "cpe": ["7-zip:7-zip"], "windows": "^7-Zip "},
|
| 13 |
+
{"id": "winrar", "name": "WinRAR", "cpe": ["rarlab:winrar"], "windows": "^WinRAR "},
|
| 14 |
+
{"id": "notepadpp", "name": "Notepad++", "cpe": ["notepad-plus-plus:notepad\\+\\+"], "windows": "^Notepad\\+\\+"},
|
| 15 |
+
{"id": "vlc", "name": "VLC media player", "cpe": ["videolan:vlc_media_player"], "windows": "^VLC media player$", "macos": "^VLC$"},
|
| 16 |
+
{"id": "zoom", "name": "Zoom", "cpe": ["zoom:workplace_desktop", "zoom:meetings", "zoom:zoom"], "windows": "^Zoom( Workplace| \\(64-bit\\))?$", "macos": "^zoom\\.us$"},
|
| 17 |
+
{"id": "teams", "name": "Microsoft Teams", "cpe": ["microsoft:teams"], "windows": "^Microsoft Teams( classic)?$", "macos": "^Microsoft Teams( classic)?$"},
|
| 18 |
+
{"id": "vscode", "name": "Visual Studio Code", "cpe": ["microsoft:visual_studio_code"], "windows": "^Microsoft Visual Studio Code", "macos": "^Visual Studio Code$"},
|
| 19 |
+
{"id": "putty", "name": "PuTTY", "cpe": ["putty:putty", "simon_tatham:putty"], "windows": "^PuTTY release "},
|
| 20 |
+
{"id": "winscp", "name": "WinSCP", "cpe": ["winscp:winscp"], "windows": "^WinSCP "},
|
| 21 |
+
{"id": "filezilla", "name": "FileZilla", "cpe": ["filezilla-project:filezilla_client"], "windows": "^FileZilla", "macos": "^FileZilla$"},
|
| 22 |
+
{"id": "wireshark", "name": "Wireshark", "cpe": ["wireshark:wireshark"], "windows": "^Wireshark ", "macos": "^Wireshark$"},
|
| 23 |
+
{"id": "git", "name": "Git for Windows", "cpe": ["git-scm:git"], "windows": "^Git$|^Git version "},
|
| 24 |
+
{"id": "python", "name": "Python", "cpe": ["python:python"], "windows": "^Python 3\\.\\d+\\.\\d+ \\("},
|
| 25 |
+
{"id": "nodejs", "name": "Node.js", "cpe": ["nodejs:node.js"], "windows": "^Node\\.js$"},
|
| 26 |
+
{"id": "keepass", "name": "KeePass", "cpe": ["keepass:keepass"], "windows": "^KeePass Password Safe 2"},
|
| 27 |
+
{"id": "teamviewer", "name": "TeamViewer", "cpe": ["teamviewer:teamviewer"], "windows": "^TeamViewer( \\d+)?$", "macos": "^TeamViewer$"},
|
| 28 |
+
{"id": "anydesk", "name": "AnyDesk", "cpe": ["anydesk:anydesk"], "windows": "^AnyDesk$", "macos": "^AnyDesk$"},
|
| 29 |
+
{"id": "docker_desktop", "name": "Docker Desktop", "cpe": ["docker:desktop"], "windows": "^Docker Desktop$", "macos": "^Docker$"},
|
| 30 |
+
{"id": "openvpn_connect", "name": "OpenVPN Connect", "cpe": ["openvpn:connect"], "windows": "^OpenVPN Connect$", "macos": "^OpenVPN Connect$"},
|
| 31 |
+
{"id": "libreoffice", "name": "LibreOffice", "cpe": ["libreoffice:libreoffice"], "windows": "^LibreOffice \\d", "macos": "^LibreOffice$"},
|
| 32 |
+
{"id": "gimp", "name": "GIMP", "cpe": ["gimp:gimp"], "windows": "^GIMP \\d", "macos": "^GIMP"},
|
| 33 |
+
{"id": "foxit_reader", "name": "Foxit PDF Reader", "cpe": ["foxit:pdf_reader"], "windows": "^Foxit (PDF )?Reader$", "macos": "^Foxit PDF Reader$"},
|
| 34 |
+
{"id": "tightvnc", "name": "TightVNC", "cpe": ["tightvnc:tightvnc", "glavsoft:tightvnc"], "windows": "^TightVNC$"},
|
| 35 |
+
{"id": "telegram", "name": "Telegram Desktop", "cpe": ["telegram:telegram_desktop"], "windows": "^Telegram Desktop", "macos": "^Telegram$"},
|
| 36 |
+
{"id": "safari", "name": "Safari", "cpe": ["apple:safari"], "macos": "^Safari$"},
|
| 37 |
+
{"id": "iterm2", "name": "iTerm2", "cpe": ["iterm2:iterm2"], "macos": "^iTerm$"}
|
| 38 |
+
]
|
| 39 |
+
}
|
vulndb/sign-bundle.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Sign the vulnerability bundle in vulndb/out/ with the Devseis Ed25519 key.
|
| 2 |
+
// The private key lives outside the repository (~/.devseis/vulndb-ed25519-private.pem) and is created on first use;
|
| 3 |
+
// its public half is written to app/vulndb-public-key.pem, which the app uses to reject tampered bundles.
|
| 4 |
+
// Usage: node vulndb/sign-bundle.mjs
|
| 5 |
+
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign } from 'node:crypto';
|
| 6 |
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
| 7 |
+
import { homedir } from 'node:os';
|
| 8 |
+
import path from 'node:path';
|
| 9 |
+
import { fileURLToPath } from 'node:url';
|
| 10 |
+
|
| 11 |
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
| 12 |
+
const keyDir = path.join(homedir(), '.devseis');
|
| 13 |
+
const keyFile = process.env.DEVSEIS_VULNDB_KEY || path.join(keyDir, 'vulndb-ed25519-private.pem');
|
| 14 |
+
const publicFile = path.join(here, '..', 'app', 'vulndb-public-key.pem');
|
| 15 |
+
const out = path.join(here, 'out');
|
| 16 |
+
|
| 17 |
+
if (!existsSync(keyFile)) {
|
| 18 |
+
mkdirSync(path.dirname(keyFile), { recursive: true, mode: 0o700 });
|
| 19 |
+
const { privateKey } = generateKeyPairSync('ed25519');
|
| 20 |
+
writeFileSync(keyFile, privateKey.export({ type: 'pkcs8', format: 'pem' }), { mode: 0o600 });
|
| 21 |
+
chmodSync(keyFile, 0o600);
|
| 22 |
+
console.log(`Created signing key ${keyFile} (keep it private; back it up securely).`);
|
| 23 |
+
}
|
| 24 |
+
const privateKey = createPrivateKey(readFileSync(keyFile));
|
| 25 |
+
const publicPem = createPublicKey(privateKey).export({ type: 'spki', format: 'pem' });
|
| 26 |
+
if (!existsSync(publicFile) || readFileSync(publicFile, 'utf8') !== publicPem) {
|
| 27 |
+
writeFileSync(publicFile, publicPem);
|
| 28 |
+
console.log(`Wrote public key ${path.relative(process.cwd(), publicFile)}`);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const manifestPath = path.join(out, 'manifest.json');
|
| 32 |
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
| 33 |
+
const sha = createHash('sha256').update(readFileSync(path.join(out, manifest.file))).digest('hex');
|
| 34 |
+
if (sha !== manifest.sha256) throw new Error(`${manifest.file} does not match manifest.json; rebuild the bundle`);
|
| 35 |
+
manifest.signature = sign(null, Buffer.from(sha), privateKey).toString('base64');
|
| 36 |
+
manifest.signed_at = new Date().toISOString().replace(/\.\d+Z$/, 'Z');
|
| 37 |
+
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
| 38 |
+
console.log(`Signed ${manifest.file} (sha256 ${sha.slice(0, 16)}...)`);
|