pqaudit 0.2.0 → 0.5.0
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/README.md +81 -16
- package/dist/cli.js +73 -24
- package/dist/cli.js.map +1 -1
- package/dist/grammars/tree-sitter-javascript.wasm +0 -0
- package/dist/grammars/tree-sitter-tsx.wasm +0 -0
- package/dist/grammars/tree-sitter-typescript.wasm +0 -0
- package/dist/policy/evaluator.d.ts +4 -0
- package/dist/policy/evaluator.d.ts.map +1 -0
- package/dist/policy/evaluator.js +60 -0
- package/dist/policy/evaluator.js.map +1 -0
- package/dist/policy/loader.d.ts +4 -0
- package/dist/policy/loader.d.ts.map +1 -0
- package/dist/policy/loader.js +19 -0
- package/dist/policy/loader.js.map +1 -0
- package/dist/reporter/html.d.ts +7 -0
- package/dist/reporter/html.d.ts.map +1 -0
- package/dist/reporter/html.js +415 -0
- package/dist/reporter/html.js.map +1 -0
- package/dist/reporter/text.d.ts.map +1 -1
- package/dist/reporter/text.js +16 -0
- package/dist/reporter/text.js.map +1 -1
- package/dist/sbom/enricher.d.ts +4 -0
- package/dist/sbom/enricher.d.ts.map +1 -0
- package/dist/sbom/enricher.js +144 -0
- package/dist/sbom/enricher.js.map +1 -0
- package/dist/sbom/parser.d.ts +4 -0
- package/dist/sbom/parser.d.ts.map +1 -0
- package/dist/sbom/parser.js +49 -0
- package/dist/sbom/parser.js.map +1 -0
- package/dist/scanner/ast-patterns.d.ts +38 -0
- package/dist/scanner/ast-patterns.d.ts.map +1 -0
- package/dist/scanner/ast-patterns.js +46 -0
- package/dist/scanner/ast-patterns.js.map +1 -0
- package/dist/scanner/ast-scanner.d.ts +8 -0
- package/dist/scanner/ast-scanner.d.ts.map +1 -0
- package/dist/scanner/ast-scanner.js +300 -0
- package/dist/scanner/ast-scanner.js.map +1 -0
- package/dist/scanner/dependency-scanner.d.ts +4 -0
- package/dist/scanner/dependency-scanner.d.ts.map +1 -1
- package/dist/scanner/dependency-scanner.js +477 -1
- package/dist/scanner/dependency-scanner.js.map +1 -1
- package/dist/scanner/engine.d.ts.map +1 -1
- package/dist/scanner/engine.js +68 -8
- package/dist/scanner/engine.js.map +1 -1
- package/dist/scanner/file-scanner.d.ts +1 -1
- package/dist/scanner/file-scanner.d.ts.map +1 -1
- package/dist/scanner/file-scanner.js +24 -6
- package/dist/scanner/file-scanner.js.map +1 -1
- package/dist/scanner/network-scanner.d.ts +4 -0
- package/dist/scanner/network-scanner.d.ts.map +1 -0
- package/dist/scanner/network-scanner.js +204 -0
- package/dist/scanner/network-scanner.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -5
- package/rules/crypto-patterns.yaml +143 -2
package/README.md
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
[](https://github.com/PQCWorld/pqaudit/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/pqaudit)
|
|
5
5
|
[](LICENSE)
|
|
6
|
+
[](https://nodejs.org)
|
|
6
7
|
|
|
7
8
|
Scan codebases for quantum-vulnerable cryptography. Get a clear picture of what needs to migrate before [Q-Day](https://en.wikipedia.org/wiki/Q-day).
|
|
8
9
|
|
|
9
|
-
pqaudit
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
pqaudit detects usage of RSA, ECDSA, Ed25519, ECDH, DH, and other algorithms broken by Shor's algorithm. It also identifies already-migrated PQC usage (ML-KEM, ML-DSA, SLH-DSA) so you can track migration progress. Output as human-readable text, JSON, [CycloneDX CBOM](https://cyclonedx.org/capabilities/cbom/), [SARIF](https://sarifweb.azurewebsites.net/) for GitHub Code Scanning, or a self-contained HTML report.
|
|
10
13
|
|
|
11
14
|
## Why now
|
|
12
15
|
|
|
@@ -54,21 +57,29 @@ pqaudit . --no-deps
|
|
|
54
57
|
|
|
55
58
|
# Use custom rules
|
|
56
59
|
pqaudit . --rules ./my-rules.yaml
|
|
60
|
+
|
|
61
|
+
# Scan TLS/SSH endpoints for quantum-vulnerable crypto
|
|
62
|
+
pqaudit . --scan-endpoint api.example.com:443 --scan-endpoint git.example.com:22
|
|
63
|
+
|
|
64
|
+
# Scan endpoints only (no code scanning)
|
|
65
|
+
pqaudit --scan-endpoint example.com:443 --scan-endpoint example.com:22
|
|
57
66
|
```
|
|
58
67
|
|
|
59
68
|
### All options
|
|
60
69
|
|
|
61
70
|
| Flag | Description | Default |
|
|
62
71
|
|------|-------------|---------|
|
|
63
|
-
| `-f, --format <format>` | Output format: `text`, `json`, `cbom`, `sarif` | `text` |
|
|
72
|
+
| `-f, --format <format>` | Output format: `text`, `json`, `cbom`, `sarif`, `html` | `text` |
|
|
64
73
|
| `-o, --output <file>` | Write output to file | stdout |
|
|
65
74
|
| `-s, --severity <level>` | Minimum severity: `critical`, `high`, `medium`, `low`, `safe` | `safe` |
|
|
66
75
|
| `--min-confidence <0-100>` | Filter findings below this confidence threshold | `50` |
|
|
67
76
|
| `--no-dedupe` | Show all occurrences instead of collapsing per file | dedupe on |
|
|
68
|
-
| `--no-deps` | Skip
|
|
77
|
+
| `--no-deps` | Skip dependency scanning | scan deps |
|
|
69
78
|
| `--include <patterns...>` | Glob patterns to include | all source files |
|
|
70
79
|
| `--exclude <patterns...>` | Additional glob patterns to exclude | node_modules, dist, etc. |
|
|
71
80
|
| `--rules <path>` | Path to custom rules YAML file | built-in rules |
|
|
81
|
+
| `--scan-endpoint <endpoints...>` | TLS/SSH endpoints to probe (`host:port`) | none |
|
|
82
|
+
| `--network-timeout <ms>` | Network connection timeout | `5000` |
|
|
72
83
|
| `--ci` | Exit code 1 if critical or high findings exist | off |
|
|
73
84
|
|
|
74
85
|
## Example output
|
|
@@ -88,13 +99,19 @@ pqaudit . --rules ./my-rules.yaml
|
|
|
88
99
|
src/crypto/signing.ts:14
|
|
89
100
|
> import { sign, verify } from "@noble/ed25519";
|
|
90
101
|
Fix: ML-DSA-65 (FIPS 204) or hybrid Ed25519+ML-DSA-65
|
|
91
|
-
Confidence:
|
|
102
|
+
Confidence: 98% | Effort: moderate | Via: ast
|
|
92
103
|
|
|
93
104
|
[!!] RSA — RSA signature — vulnerable to quantum factoring (3 occurrences)
|
|
94
105
|
src/auth/jwt.ts:42
|
|
95
106
|
> jwt.sign(payload, key, { algorithm: "RS256" });
|
|
96
107
|
Fix: ML-DSA-65 (FIPS 204)
|
|
97
|
-
Confidence:
|
|
108
|
+
Confidence: 96% | Effort: complex | Via: ast
|
|
109
|
+
|
|
110
|
+
[!!] ECDSA — Certificate uses ECDSA 256-bit key — vulnerable to Shor's algorithm
|
|
111
|
+
tls://api.example.com:443
|
|
112
|
+
> ECDSA 256-bit key, TLSv1.3
|
|
113
|
+
Fix: Post-quantum certificate algorithms when available
|
|
114
|
+
Confidence: 100% | Effort: complex | Via: network
|
|
98
115
|
...
|
|
99
116
|
```
|
|
100
117
|
|
|
@@ -109,11 +126,13 @@ pqaudit . --rules ./my-rules.yaml
|
|
|
109
126
|
| ECDH / X25519 / DH | Shor's on key exchange | ML-KEM-768 (FIPS 203) |
|
|
110
127
|
| DSA | Shor's algorithm | ML-DSA-65 (FIPS 204) |
|
|
111
128
|
|
|
112
|
-
### High (weakened by quantum)
|
|
129
|
+
### High (weakened by quantum or outdated protocols)
|
|
113
130
|
|
|
114
131
|
| Algorithm | Threat | Replacement |
|
|
115
132
|
|-----------|--------|-------------|
|
|
116
133
|
| AES-128 | Grover reduces to 64-bit | AES-256 |
|
|
134
|
+
| TLS 1.0/1.1, SSLv3 | Deprecated protocols | TLS 1.3 |
|
|
135
|
+
| SSH (detected via network) | DH/ECDH key exchange | PQ hybrid key exchange |
|
|
117
136
|
|
|
118
137
|
### Safe (already quantum-resistant)
|
|
119
138
|
|
|
@@ -137,6 +156,14 @@ Generates SARIF 2.1.0 output compatible with GitHub's code scanning. Upload via
|
|
|
137
156
|
pqaudit . --format sarif --output results.sarif
|
|
138
157
|
```
|
|
139
158
|
|
|
159
|
+
### HTML report
|
|
160
|
+
|
|
161
|
+
Self-contained HTML file with a visual dashboard — severity breakdown, PQC readiness score, and findings table. No external dependencies, works offline.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pqaudit . --format html --output report.html
|
|
165
|
+
```
|
|
166
|
+
|
|
140
167
|
## GitHub Action
|
|
141
168
|
|
|
142
169
|
```yaml
|
|
@@ -160,13 +187,17 @@ jobs:
|
|
|
160
187
|
|
|
161
188
|
## Dependency scanning
|
|
162
189
|
|
|
163
|
-
pqaudit checks
|
|
190
|
+
pqaudit checks manifest files for known cryptographic libraries across five ecosystems:
|
|
164
191
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- `jsonwebtoken`, `
|
|
168
|
-
|
|
169
|
-
|
|
192
|
+
| Ecosystem | Manifest files | Example packages |
|
|
193
|
+
|-----------|---------------|-----------------|
|
|
194
|
+
| **npm** | `package.json` | `@noble/ed25519`, `node-rsa`, `jsonwebtoken`, `ethers` |
|
|
195
|
+
| **Rust** | `Cargo.toml` | `ed25519-dalek`, `rsa`, `ring`, `p256`, `pqcrypto` |
|
|
196
|
+
| **Go** | `go.mod` | `golang.org/x/crypto`, `cloudflare/circl` |
|
|
197
|
+
| **Python** | `requirements.txt`, `pyproject.toml` | `cryptography`, `pycryptodome`, `paramiko` |
|
|
198
|
+
| **Java** | `build.gradle`, `pom.xml` | BouncyCastle, Google Tink |
|
|
199
|
+
|
|
200
|
+
PQC-safe libraries (`@noble/post-quantum`, `pqcrypto`, `cloudflare/circl`) are flagged as **safe** for inventory tracking.
|
|
170
201
|
|
|
171
202
|
## Custom rules
|
|
172
203
|
|
|
@@ -188,14 +219,48 @@ Rules are defined in YAML:
|
|
|
188
219
|
|
|
189
220
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full rule schema and how to submit new rules.
|
|
190
221
|
|
|
222
|
+
## Protocol and config detection
|
|
223
|
+
|
|
224
|
+
pqaudit scans configuration files for quantum-vulnerable crypto settings:
|
|
225
|
+
|
|
226
|
+
- **SSH**: RSA/ECDSA key types, DH/ECDH key exchange in `sshd_config`/`ssh_config`
|
|
227
|
+
- **TLS**: deprecated protocols (1.0/1.1/SSLv3) and vulnerable cipher suites in nginx/apache/haproxy configs
|
|
228
|
+
- **Kubernetes**: TLS secrets and cert-manager RSA private keys
|
|
229
|
+
- **Docker**: crypto library installs in Dockerfiles
|
|
230
|
+
|
|
231
|
+
Extensionless config files (`Dockerfile`, `sshd_config`, `ssh_config`) are automatically detected and scanned.
|
|
232
|
+
|
|
233
|
+
## Network scanning
|
|
234
|
+
|
|
235
|
+
Probe live TLS and SSH endpoints for quantum-vulnerable crypto configurations:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
pqaudit --scan-endpoint api.example.com:443 --scan-endpoint git.example.com:22
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**TLS endpoints** (any port, or specify `tls://host:port`):
|
|
242
|
+
- Negotiated protocol version (TLS 1.2 vs 1.3)
|
|
243
|
+
- Cipher suite key exchange (RSA static, ECDHE — both quantum-vulnerable)
|
|
244
|
+
- Certificate public key algorithm and size (RSA, ECDSA)
|
|
245
|
+
|
|
246
|
+
**SSH endpoints** (port 22 auto-detected, or specify `ssh://host:port`):
|
|
247
|
+
- Server banner detection (OpenSSH, etc.)
|
|
248
|
+
- Flags quantum-vulnerable DH/ECDH key exchange
|
|
249
|
+
|
|
250
|
+
Network findings have 100% confidence (observed facts, not pattern matches) and appear alongside code findings in all output formats.
|
|
251
|
+
|
|
191
252
|
## Detection methods
|
|
192
253
|
|
|
193
|
-
|
|
254
|
+
pqaudit uses four detection methods:
|
|
255
|
+
|
|
256
|
+
- **L0 (regex)**: Pattern matching across all supported languages and config files
|
|
257
|
+
- **L1 (AST)**: Tree-sitter parsing for JS/TS — detects actual imports, function calls, API usage (0.95-0.98 confidence)
|
|
258
|
+
- **Dependency**: Manifest file scanning across npm, Cargo, Go, pip, and Gradle/Maven
|
|
259
|
+
- **Network**: Live TLS/SSH endpoint probing for cipher suites and certificate algorithms (100% confidence)
|
|
260
|
+
|
|
261
|
+
Planned:
|
|
194
262
|
|
|
195
|
-
- **L1**: AST-based analysis via tree-sitter for semantic understanding and fewer false positives
|
|
196
263
|
- **L2**: Data flow / taint analysis for tracing cryptographic data through call chains
|
|
197
|
-
- **Network scanning**: TLS/SSH endpoint analysis
|
|
198
|
-
- **More languages**: Cargo.toml, build.gradle, requirements.txt dependency scanning
|
|
199
264
|
|
|
200
265
|
## Contributing
|
|
201
266
|
|
package/dist/cli.js
CHANGED
|
@@ -6,13 +6,14 @@ import { formatText } from "./reporter/text.js";
|
|
|
6
6
|
import { formatJson } from "./reporter/json.js";
|
|
7
7
|
import { formatCbom } from "./reporter/cbom.js";
|
|
8
8
|
import { formatSarif } from "./reporter/sarif.js";
|
|
9
|
+
import { formatHtml } from "./reporter/html.js";
|
|
9
10
|
const program = new Command();
|
|
10
11
|
program
|
|
11
12
|
.name("pqaudit")
|
|
12
13
|
.description("Scan codebases for quantum-vulnerable cryptography and generate a Cryptographic Bill of Materials (CBOM)")
|
|
13
14
|
.version("0.1.0")
|
|
14
15
|
.argument("[target]", "Directory to scan", ".")
|
|
15
|
-
.option("-f, --format <format>", "Output format: text, json, cbom, sarif", "text")
|
|
16
|
+
.option("-f, --format <format>", "Output format: text, json, cbom, sarif, html", "text")
|
|
16
17
|
.option("-o, --output <file>", "Write output to file instead of stdout")
|
|
17
18
|
.option("-s, --severity <level>", "Minimum severity to report: critical, high, medium, low, safe", "safe")
|
|
18
19
|
.option("--no-deps", "Skip dependency scanning")
|
|
@@ -22,8 +23,31 @@ program
|
|
|
22
23
|
.option("--min-confidence <number>", "Minimum confidence 0-100 (default 50)", "50")
|
|
23
24
|
.option("--dedupe", "Collapse duplicate findings per file (default: true)")
|
|
24
25
|
.option("--no-dedupe", "Show all occurrences instead of collapsing duplicates")
|
|
26
|
+
.option("--sbom <file>", "Path to existing SBOM (CycloneDX or SPDX JSON) to enrich")
|
|
27
|
+
.option("--sbom-format <format>", "SBOM format: cyclonedx, spdx (auto-detected if omitted)")
|
|
28
|
+
.option("--policy <file>", "Path to policy YAML file for compliance checking")
|
|
29
|
+
.option("--scan-endpoint <endpoints...>", "TLS/SSH endpoints to probe (host:port)")
|
|
30
|
+
.option("--network-timeout <ms>", "Network connection timeout in ms", "5000")
|
|
25
31
|
.option("--ci", "Exit with code 1 if critical/high findings exist")
|
|
26
32
|
.action(async (target, opts) => {
|
|
33
|
+
const endpoints = opts.scanEndpoint?.map((ep) => {
|
|
34
|
+
// Support tls:// and ssh:// prefixes
|
|
35
|
+
let protocol = "tls";
|
|
36
|
+
let addr = ep;
|
|
37
|
+
if (ep.startsWith("ssh://")) {
|
|
38
|
+
protocol = "ssh";
|
|
39
|
+
addr = ep.slice(6);
|
|
40
|
+
}
|
|
41
|
+
else if (ep.startsWith("tls://")) {
|
|
42
|
+
addr = ep.slice(6);
|
|
43
|
+
}
|
|
44
|
+
const [host, portStr] = addr.split(":");
|
|
45
|
+
const port = portStr ? parseInt(portStr, 10) : protocol === "ssh" ? 22 : 443;
|
|
46
|
+
// Auto-detect SSH from port 22
|
|
47
|
+
if (port === 22 && !ep.startsWith("tls://"))
|
|
48
|
+
protocol = "ssh";
|
|
49
|
+
return { host, port, protocol };
|
|
50
|
+
});
|
|
27
51
|
const config = {
|
|
28
52
|
target,
|
|
29
53
|
format: opts.format,
|
|
@@ -35,35 +59,60 @@ program
|
|
|
35
59
|
rulesDir: opts.rules,
|
|
36
60
|
minConfidence: Number(opts.minConfidence),
|
|
37
61
|
dedupe: opts.dedupe !== false,
|
|
62
|
+
endpoints,
|
|
63
|
+
networkTimeout: Number(opts.networkTimeout),
|
|
64
|
+
sbomInput: opts.sbom,
|
|
65
|
+
sbomFormat: opts.sbomFormat,
|
|
66
|
+
policyFile: opts.policy,
|
|
38
67
|
};
|
|
39
68
|
const result = await scan(config);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
output = formatSarif(result);
|
|
50
|
-
break;
|
|
51
|
-
case "text":
|
|
52
|
-
default:
|
|
53
|
-
output = formatText(result);
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
if (config.output) {
|
|
57
|
-
writeFileSync(config.output, output, "utf-8");
|
|
58
|
-
if (config.format === "text") {
|
|
59
|
-
console.log(`Results written to ${config.output}`);
|
|
69
|
+
// If SBOM enrichment was done, output the enriched SBOM instead of normal format
|
|
70
|
+
if (result.enrichedSbom) {
|
|
71
|
+
const sbomOutput = JSON.stringify(result.enrichedSbom, null, 2);
|
|
72
|
+
if (config.output) {
|
|
73
|
+
writeFileSync(config.output, sbomOutput, "utf-8");
|
|
74
|
+
console.log(`Enriched SBOM written to ${config.output}`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(sbomOutput);
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
80
|
else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
81
|
+
let output;
|
|
82
|
+
switch (config.format) {
|
|
83
|
+
case "json":
|
|
84
|
+
output = formatJson(result);
|
|
85
|
+
break;
|
|
86
|
+
case "cbom":
|
|
87
|
+
output = formatCbom(result);
|
|
88
|
+
break;
|
|
89
|
+
case "sarif":
|
|
90
|
+
output = formatSarif(result);
|
|
91
|
+
break;
|
|
92
|
+
case "html":
|
|
93
|
+
output = formatHtml(result);
|
|
94
|
+
break;
|
|
95
|
+
case "text":
|
|
96
|
+
default:
|
|
97
|
+
output = formatText(result);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (config.output) {
|
|
101
|
+
writeFileSync(config.output, output, "utf-8");
|
|
102
|
+
if (config.format === "text") {
|
|
103
|
+
console.log(`Results written to ${config.output}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.log(output);
|
|
108
|
+
}
|
|
109
|
+
} // end else (no SBOM enrichment)
|
|
110
|
+
// CI mode: exit 1 if critical/high findings, exit 2 if blocking policy violations
|
|
66
111
|
if (opts.ci) {
|
|
112
|
+
const blockingViolations = result.policyViolations?.filter((v) => v.action === "block");
|
|
113
|
+
if (blockingViolations && blockingViolations.length > 0) {
|
|
114
|
+
process.exit(2);
|
|
115
|
+
}
|
|
67
116
|
const { critical, high } = result.summary.bySeverity;
|
|
68
117
|
if (critical > 0 || high > 0) {
|
|
69
118
|
process.exit(1);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,OAAO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CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,sBAAsB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;IAED,CAAC,CAAC,gCAAgC;IAElC,kFAAkF;IAClF,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,MAAM,CACxD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAC5B,CAAC;QACF,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;QACrD,IAAI,QAAQ,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Finding, Policy, PolicyViolation } from "../types.js";
|
|
2
|
+
/** Check all findings against all policies, returning violations */
|
|
3
|
+
export declare function evaluatePolicies(policies: Policy[], findings: Finding[]): PolicyViolation[];
|
|
4
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/policy/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEpE,oEAAoE;AACpE,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,EAAE,OAAO,EAAE,GAClB,eAAe,EAAE,CAuBnB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Check all findings against all policies, returning violations */
|
|
2
|
+
export function evaluatePolicies(policies, findings) {
|
|
3
|
+
const violations = [];
|
|
4
|
+
const now = new Date();
|
|
5
|
+
for (const finding of findings) {
|
|
6
|
+
// Skip safe findings — policies target vulnerabilities
|
|
7
|
+
if (finding.severity === "safe")
|
|
8
|
+
continue;
|
|
9
|
+
for (const policy of policies) {
|
|
10
|
+
if (matches(policy, finding, now)) {
|
|
11
|
+
violations.push({
|
|
12
|
+
policyId: policy.id,
|
|
13
|
+
description: policy.description ?? policy.id,
|
|
14
|
+
action: policy.action,
|
|
15
|
+
finding,
|
|
16
|
+
message: policy.message ?? `Violates policy "${policy.id}"`,
|
|
17
|
+
deadline: policy.deadline,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return violations;
|
|
23
|
+
}
|
|
24
|
+
function matches(policy, finding, now) {
|
|
25
|
+
// Deadline check — if deadline is in the future, skip (not yet enforced)
|
|
26
|
+
if (policy.deadline) {
|
|
27
|
+
const deadline = new Date(policy.deadline);
|
|
28
|
+
if (now < deadline)
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// Confidence threshold — skip findings below the policy minimum
|
|
32
|
+
if (policy.min_confidence !== undefined && finding.confidence < policy.min_confidence) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
// Algorithm filter
|
|
36
|
+
if (policy.algorithm) {
|
|
37
|
+
const algos = Array.isArray(policy.algorithm) ? policy.algorithm : [policy.algorithm];
|
|
38
|
+
if (!algos.some((a) => finding.algorithm.toLowerCase().includes(a.toLowerCase()))) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Category filter
|
|
43
|
+
if (policy.category) {
|
|
44
|
+
const cats = Array.isArray(policy.category) ? policy.category : [policy.category];
|
|
45
|
+
if (!cats.includes(finding.category))
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Severity filter
|
|
49
|
+
if (policy.severity) {
|
|
50
|
+
const sevs = Array.isArray(policy.severity) ? policy.severity : [policy.severity];
|
|
51
|
+
if (!sevs.includes(finding.severity))
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// If no algorithm/category/severity filter was specified, match all non-safe findings
|
|
55
|
+
if (!policy.algorithm && !policy.category && !policy.severity) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/policy/evaluator.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAC9B,QAAkB,EAClB,QAAmB;IAEnB,MAAM,UAAU,GAAsB,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,uDAAuD;QACvD,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM;YAAE,SAAS;QAE1C,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC9B,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;gBAClC,UAAU,CAAC,IAAI,CAAC;oBACd,QAAQ,EAAE,MAAM,CAAC,EAAE;oBACnB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,EAAE;oBAC5C,MAAM,EAAE,MAAM,CAAC,MAAM;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AC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,KAAK,CAAC;IACrD,CAAC;IAED,kBAAkB;IAClB,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,KAAK,CAAC;IACrD,CAAC;IAED,sFAAsF;IACtF,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/policy/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBvD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { parse as parseYaml } from "yaml";
|
|
3
|
+
/** Load and validate policy definitions from a YAML file */
|
|
4
|
+
export function loadPolicies(filePath) {
|
|
5
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
6
|
+
const parsed = parseYaml(raw);
|
|
7
|
+
if (!parsed?.policies || !Array.isArray(parsed.policies)) {
|
|
8
|
+
throw new Error(`Invalid policy file: expected "policies" array in ${filePath}`);
|
|
9
|
+
}
|
|
10
|
+
for (const policy of parsed.policies) {
|
|
11
|
+
if (!policy.id)
|
|
12
|
+
throw new Error(`Policy missing "id" in ${filePath}`);
|
|
13
|
+
if (!policy.action || !["warn", "block"].includes(policy.action)) {
|
|
14
|
+
throw new Error(`Policy "${policy.id}" has invalid action (must be "warn" or "block")`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return parsed.policies;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/policy/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAO1C,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAe,CAAC;IAE5C,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,qDAAqD,QAAQ,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACjE,MAAM,IAAI,KAAK,CAAC,WAAW,MAAM,CAAC,EAAE,kDAAkD,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScanResult } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generate a self-contained HTML report for pqaudit scan results.
|
|
4
|
+
* No external dependencies -- all CSS is inlined.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatHtml(result: ScanResult): string;
|
|
7
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/reporter/html.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,UAAU,EAA4B,MAAM,aAAa,CAAC;AA8BjF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAiDrD"}
|