ai-secure-audit 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/report.js +2 -2
- package/src/scan.js +3 -2
- package/src/scanners/osv.js +87 -0
- package/tools.lock.json +43 -0
package/package.json
CHANGED
package/src/report.js
CHANGED
|
@@ -94,7 +94,7 @@ export function reportMarkdown(result, date) {
|
|
|
94
94
|
lines.push('- Business rules: prices, coupons, approvals, payments');
|
|
95
95
|
lines.push('- Database rules such as Supabase row-level security or Firebase security rules (planned)');
|
|
96
96
|
lines.push('- Anything about the live server or website');
|
|
97
|
-
lines.push('-
|
|
97
|
+
lines.push('- Docker/config mistakes: not in this version yet (coming in v0.3)');
|
|
98
98
|
lines.push('');
|
|
99
99
|
lines.push('## Tools');
|
|
100
100
|
lines.push('');
|
|
@@ -120,7 +120,7 @@ export function consoleSummary(result, outRel) {
|
|
|
120
120
|
'- Use each finding\'s fix field. A key that is in git or was deployed must be rotated at the provider: deleting it from the code is not enough.',
|
|
121
121
|
'- A finding marked not_committed can be moved out of the code without rotating, unless the key was shared or pasted somewhere else.',
|
|
122
122
|
'- Not checked: whether one user can reach another user\'s data, business rules, and (in this version)',
|
|
123
|
-
'
|
|
123
|
+
' Docker/config files. Say so.',
|
|
124
124
|
...(failed.length ? ['- Some tools did not run (see NOT RUN above). Tell the user the check is incomplete.'] : []),
|
|
125
125
|
].join('\n');
|
|
126
126
|
}
|
package/src/scan.js
CHANGED
|
@@ -4,10 +4,11 @@ import { join, resolve } from 'node:path';
|
|
|
4
4
|
import { cacheDir, ensureTool, lockedTools } from './tools.js';
|
|
5
5
|
import { sortAndNumber } from './findings.js';
|
|
6
6
|
import gitleaks from './scanners/gitleaks.js';
|
|
7
|
+
import osv from './scanners/osv.js';
|
|
7
8
|
|
|
8
9
|
// Scanners are released one at a time, each after passing its own tests (see CLAUDE.md).
|
|
9
10
|
// Scanners still in development are kept outside this repository until they pass.
|
|
10
|
-
export const BASIC_SCANNERS = [gitleaks];
|
|
11
|
+
export const BASIC_SCANNERS = [gitleaks, osv];
|
|
11
12
|
|
|
12
13
|
function git(root, args) {
|
|
13
14
|
const r = spawnSync('git', ['-C', root, ...args], { encoding: 'utf8' });
|
|
@@ -83,7 +84,7 @@ export async function scan(target, { log = () => {}, version }) {
|
|
|
83
84
|
tools: runs,
|
|
84
85
|
notes: [
|
|
85
86
|
'Not checked by this tool: whether one user can reach another user\'s data, business rules, and anything running on a server.',
|
|
86
|
-
`Not checked yet in this version:
|
|
87
|
+
`Not checked yet in this version: Docker/config files (trivy, coming in v0.3).`,
|
|
87
88
|
],
|
|
88
89
|
findings: sortAndNumber(findings),
|
|
89
90
|
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { rel } from '../paths.js';
|
|
3
|
+
|
|
4
|
+
function cvssBand(score) {
|
|
5
|
+
const s = Number.parseFloat(score);
|
|
6
|
+
if (Number.isNaN(s)) return null;
|
|
7
|
+
if (s >= 9) return 'critical';
|
|
8
|
+
if (s >= 7) return 'high';
|
|
9
|
+
if (s >= 4) return 'medium';
|
|
10
|
+
if (s > 0) return 'low';
|
|
11
|
+
return 'info';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function compareVersions(a, b) {
|
|
15
|
+
const pa = a.split(/[.\-+]/).map((x) => (/^\d+$/.test(x) ? Number(x) : x));
|
|
16
|
+
const pb = b.split(/[.\-+]/).map((x) => (/^\d+$/.test(x) ? Number(x) : x));
|
|
17
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
18
|
+
const x = pa[i] ?? 0, y = pb[i] ?? 0;
|
|
19
|
+
if (x === y) continue;
|
|
20
|
+
if (typeof x === 'number' && typeof y === 'number') return x - y;
|
|
21
|
+
return String(x).localeCompare(String(y));
|
|
22
|
+
}
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function fixedVersion(vulns, pkgName) {
|
|
27
|
+
const fixed = [];
|
|
28
|
+
for (const v of vulns) {
|
|
29
|
+
for (const a of v.affected ?? []) {
|
|
30
|
+
if (a.package?.name !== pkgName) continue;
|
|
31
|
+
for (const r of a.ranges ?? []) for (const e of r.events ?? []) if (e.fixed) fixed.push(e.fixed);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return fixed.sort(compareVersions).at(-1) ?? null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
id: 'osv-scanner',
|
|
39
|
+
category: 'dependency',
|
|
40
|
+
|
|
41
|
+
// Offline databases: the dependency list never leaves the machine. Only the public databases are downloaded.
|
|
42
|
+
env(ctx) {
|
|
43
|
+
return { OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY: join(ctx.cache, 'osv-db') };
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
args(ctx, out) {
|
|
47
|
+
return ['scan', 'source', '-r', '--offline-vulnerabilities', '--download-offline-databases', '--allow-no-lockfiles',
|
|
48
|
+
'--format', 'json', '--output-file', out, '--verbosity', 'error', ctx.root];
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
okExit: [0, 1],
|
|
52
|
+
|
|
53
|
+
parse(json, ctx) {
|
|
54
|
+
const findings = [];
|
|
55
|
+
for (const result of json?.results ?? []) {
|
|
56
|
+
const file = rel(ctx.root, result.source?.path);
|
|
57
|
+
for (const pkg of result.packages ?? []) {
|
|
58
|
+
const { name, version, ecosystem } = pkg.package;
|
|
59
|
+
const vulns = pkg.vulnerabilities ?? [];
|
|
60
|
+
for (const group of pkg.groups ?? []) {
|
|
61
|
+
const ids = [...group.ids].sort();
|
|
62
|
+
const main = vulns.find((v) => ids.includes(v.id)) ?? {};
|
|
63
|
+
const groupVulns = vulns.filter((v) => ids.includes(v.id));
|
|
64
|
+
const fixed = fixedVersion(groupVulns, name);
|
|
65
|
+
const band = cvssBand(group.max_severity);
|
|
66
|
+
const aliases = [...new Set([...(group.aliases ?? []), ...ids])].sort();
|
|
67
|
+
findings.push({
|
|
68
|
+
fingerprint: `osv:${ecosystem}:${name}@${version}:${ids[0]}`,
|
|
69
|
+
category: 'dependency',
|
|
70
|
+
title: `${name} ${version}: ${main.summary ?? ids[0]}`,
|
|
71
|
+
severity: {
|
|
72
|
+
tool: group.max_severity ? `CVSS ${group.max_severity}` : 'unrated',
|
|
73
|
+
normalized: band ?? 'medium',
|
|
74
|
+
},
|
|
75
|
+
source: { kind: 'tool', tool: 'osv-scanner', rule_id: ids[0] },
|
|
76
|
+
evidence: [{ location: file, detail: `${ecosystem} package ${name}@${version}. Advisories: ${aliases.join(', ')}` }],
|
|
77
|
+
fix: fixed
|
|
78
|
+
? `Upgrade ${name} to ${fixed} or later, then reinstall so the lockfile updates.`
|
|
79
|
+
: `No fixed version is published yet. Check whether the affected feature is used; consider a replacement.`,
|
|
80
|
+
references: { advisories: aliases },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return findings;
|
|
86
|
+
},
|
|
87
|
+
};
|
package/tools.lock.json
CHANGED
|
@@ -43,6 +43,49 @@
|
|
|
43
43
|
"binary": "gitleaks.exe"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
},
|
|
47
|
+
"osv-scanner": {
|
|
48
|
+
"version": "2.7.0",
|
|
49
|
+
"license": "Apache-2.0",
|
|
50
|
+
"repo": "https://github.com/google/osv-scanner",
|
|
51
|
+
"platforms": {
|
|
52
|
+
"darwin-arm64": {
|
|
53
|
+
"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_darwin_arm64",
|
|
54
|
+
"sha256": "d4926ef8da134332543be276dff157e4c170f99ad91fc48e89448a8816bdf70b",
|
|
55
|
+
"archive": "raw",
|
|
56
|
+
"binary": "osv-scanner_darwin_arm64"
|
|
57
|
+
},
|
|
58
|
+
"darwin-x64": {
|
|
59
|
+
"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_darwin_amd64",
|
|
60
|
+
"sha256": "e82c5df7ab0a42dff29a1cd0660711447b56b4c0483ff66ad8634df10fd81a45",
|
|
61
|
+
"archive": "raw",
|
|
62
|
+
"binary": "osv-scanner_darwin_amd64"
|
|
63
|
+
},
|
|
64
|
+
"linux-arm64": {
|
|
65
|
+
"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_linux_arm64",
|
|
66
|
+
"sha256": "4061ef4c021ed3c47f203b818f337e351336cc5cd67c0274fc36bd1dfc728dd7",
|
|
67
|
+
"archive": "raw",
|
|
68
|
+
"binary": "osv-scanner_linux_arm64"
|
|
69
|
+
},
|
|
70
|
+
"linux-x64": {
|
|
71
|
+
"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_linux_amd64",
|
|
72
|
+
"sha256": "160c6253e2922e9e0a6a9771c5c4c40a4b3c6090b34a3cdd5e80c96cc2e4218b",
|
|
73
|
+
"archive": "raw",
|
|
74
|
+
"binary": "osv-scanner_linux_amd64"
|
|
75
|
+
},
|
|
76
|
+
"win32-arm64": {
|
|
77
|
+
"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_windows_arm64.exe",
|
|
78
|
+
"sha256": "3e630381c1f1fd3c9c4d447e6ff2ef6c737083371722773db8337eead0f97962",
|
|
79
|
+
"archive": "raw",
|
|
80
|
+
"binary": "osv-scanner_windows_arm64.exe"
|
|
81
|
+
},
|
|
82
|
+
"win32-x64": {
|
|
83
|
+
"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_windows_amd64.exe",
|
|
84
|
+
"sha256": "9964ed64ec9a387391eb4cc006ad5c531154821aef29b793e02c448de4686438",
|
|
85
|
+
"archive": "raw",
|
|
86
|
+
"binary": "osv-scanner_windows_amd64.exe"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
46
89
|
}
|
|
47
90
|
}
|
|
48
91
|
}
|