pqaudit 0.2.0 → 0.6.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 +176 -22
- package/dist/cli.js +89 -25
- 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 +11 -0
- package/dist/policy/evaluator.d.ts.map +1 -0
- package/dist/policy/evaluator.js +75 -0
- package/dist/policy/evaluator.js.map +1 -0
- package/dist/policy/loader.d.ts +10 -0
- package/dist/policy/loader.d.ts.map +1 -0
- package/dist/policy/loader.js +55 -0
- package/dist/policy/loader.js.map +1 -0
- package/dist/reporter/cbom.d.ts.map +1 -1
- package/dist/reporter/cbom.js +2 -1
- package/dist/reporter/cbom.js.map +1 -1
- 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/sarif.d.ts.map +1 -1
- package/dist/reporter/sarif.js +2 -1
- package/dist/reporter/sarif.js.map +1 -1
- 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 +40 -0
- package/dist/scanner/ast-patterns.d.ts.map +1 -0
- package/dist/scanner/ast-patterns.js +71 -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 +305 -0
- package/dist/scanner/ast-scanner.js.map +1 -0
- package/dist/scanner/certificate-scanner.d.ts +38 -0
- package/dist/scanner/certificate-scanner.d.ts.map +1 -0
- package/dist/scanner/certificate-scanner.js +241 -0
- package/dist/scanner/certificate-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 +84 -11
- package/dist/scanner/engine.js.map +1 -1
- package/dist/scanner/file-scanner.d.ts +16 -1
- package/dist/scanner/file-scanner.d.ts.map +1 -1
- package/dist/scanner/file-scanner.js +155 -42
- package/dist/scanner/file-scanner.js.map +1 -1
- package/dist/scanner/network-scanner.d.ts +26 -0
- package/dist/scanner/network-scanner.d.ts.map +1 -0
- package/dist/scanner/network-scanner.js +500 -0
- package/dist/scanner/network-scanner.js.map +1 -0
- package/dist/scanner/rules.d.ts +4 -0
- package/dist/scanner/rules.d.ts.map +1 -1
- package/dist/scanner/rules.js +26 -2
- package/dist/scanner/rules.js.map +1 -1
- package/dist/scanner/suppress.d.ts +3 -0
- package/dist/scanner/suppress.d.ts.map +1 -0
- package/dist/scanner/suppress.js +38 -0
- package/dist/scanner/suppress.js.map +1 -0
- package/dist/types.d.ts +76 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/package.json +10 -6
- package/policies/cnsa-2.0.yaml +63 -0
- package/policies/eu-pqc-roadmap.yaml +48 -0
- package/policies/nist-ir-8547.yaml +69 -0
- package/rules/crypto-patterns.yaml +517 -143
package/README.md
CHANGED
|
@@ -3,14 +3,55 @@
|
|
|
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
|
+

|
|
10
11
|
|
|
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.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
## Chronology: why migrate now
|
|
15
|
+
|
|
16
|
+
*Last updated: December 4, 2026.*
|
|
17
|
+
|
|
18
|
+
### The last few weeks
|
|
19
|
+
|
|
20
|
+
- **Dec 3, 2026: Cloudflare moves its "fully post-quantum" target from 2029 to 2027.** It cites the U.S. government statement from the day before and "AI-accelerated research". 73% of human connections to its network already use post-quantum encryption, and in 2027 it will require critical vendors to use post-quantum cryptography to protect its data. [Cloudflare](https://blog.cloudflare.com/project-quantum-leap)
|
|
21
|
+
- **Dec 2, 2026: NSA, CISA and ONCD issue a joint warning.** They say recent AI-driven advances in cryptanalysis "do not present an immediate and widespread threat" to current cryptography. NSA nonetheless urges agencies and contractors running National Security Systems to "immediately accelerate" their move to post-quantum cryptography. [The Record](https://therecord.media/cisa-oncd-nsa-cryptography-warnings-quantum-resistance-guidance), [Breaking Defense](https://breakingdefense.com/2026/12/nsa-urges-immediate-shift-to-post-quantum-encryption-for-national-security-systems/), [CISA](https://www.cisa.gov/news-events/news/joint-statement-recent-advances-cryptographic-and-cybersecurity-capabilities)
|
|
22
|
+
- **Dec 2, 2026: Amazon, Anthropic, Apple, Cloudflare, Google, Microsoft, OpenAI and Oracle back that call.** Their joint statement urges organizations to adopt NIST's post-quantum standards and "accelerate the migration as soon as possible". [Joint statement](https://www.anthropic.com/news/joint-statement-post-quantum-cryptography)
|
|
23
|
+
- **Nov 30, 2026: Anthropic publishes a theoretical quantum attack on structured lattices.** Structured lattices are the math under ML-KEM and ML-DSA. The algorithm is faster than earlier methods only at very large key sizes, and Anthropic says it has no "practical, real-world consequences for today's security systems". Anthropic still calls ML-KEM and ML-DSA "two of the strongest public key algorithms available", but says the results "lower our long-term confidence in structured lattices". [MIT Technology Review](https://www.technologyreview.com/2026/12/01/1150237/anthropics-bombshell-cryptography-breakthrough-is-kind-of-fine-actually/), [The Block](https://www.theblock.co/news/ecosystems/2026-12-01-a-complete-nothingburger-anthropic-releases-lattice-cryptography-research-says-findings-pose-no-practical-threat-today-448218)
|
|
24
|
+
- **Nov 30, 2026: An independent review finds no practical threat, with caveats.** The Cryptography Incident Review Group (CIRG) says Anthropic's attack "falls far short of compromising the current NIST standards" and costs far more than even 2^1000 quantum operations against the smallest parameter sets. It recommends continuing the transition and choosing "the highest security level each application can support". It also encourages hybrids that combine different mathematical foundations, and systems built so that "individual schemes can be replaced quickly". [CIRG](https://cirg.org/statements/1/)
|
|
25
|
+
- **Nov 25, 2026: The European Commission proposes the Quantum Act.** For public administrations covered by NIS2, digital procurement would have to be post-quantum six months after the Act enters into force. Where no suitable PQC solution exists, the buyer needs a documented migration plan. [European Commission](https://digital-strategy.ec.europa.eu/en/policies/quantum-act)
|
|
26
|
+
- **Oct 27, 2026: NIST finalizes IR 8547.** Every quantum-vulnerable public-key algorithm (RSA, ECDSA, EdDSA, ECDH, DH) is deprecated after 2030 and disallowed after 2035, at any key size. The 2024 draft's exemption for RSA-3072, P-256 and Ed25519 was dropped. [NIST](https://csrc.nist.gov/pubs/ir/8547)
|
|
27
|
+
- **Sep 29, 2026: BSI advises against new Classic McEliece deployments.** The advice follows significant cryptanalytic progress in 2026. There is still no practical attack on the recommended parameters, and existing use should be hybrid-only. BSI recommends ML-KEM or FrodoKEM instead, plus HQC once it is standardized. This shows that even the conservative non-lattice options get re-rated. [BSI](https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Crypto/Notes_Classic_McEliece.html)
|
|
28
|
+
|
|
29
|
+
### How we got here
|
|
30
|
+
|
|
31
|
+
- **Aug 2024:** NIST publishes FIPS 203 (ML-KEM), FIPS 204 (ML-DSA) and FIPS 205 (SLH-DSA).
|
|
32
|
+
- **Mar 2025:** NIST selects HQC, a code-based KEM that doesn't use lattices, as a backup to ML-KEM.
|
|
33
|
+
- **Apr 2025:** OpenSSL 3.5 and OpenSSH 10.0 ship hybrid ML-KEM key exchange on by default. Chrome and Firefox already negotiate X25519MLKEM768, and Safari follows with iOS/macOS 26 in Sep 2025.
|
|
34
|
+
- **Jun 2025:** The EU roadmap: every Member State starts migrating by end-2026, with high-risk systems done by end-2030.
|
|
35
|
+
- **Mar 31, 2026:** Google estimates that breaking ECDSA-256 takes [20x fewer qubits than previously thought](https://research.google/blog/safeguarding-cryptocurrency-by-disclosing-quantum-vulnerabilities-responsibly/): about 1,200 logical qubits.
|
|
36
|
+
- **Jun 22, 2026:** U.S. Executive Order 14412 requires federal high-value and high-impact systems to use post-quantum key establishment by Dec 31, 2030 and post-quantum signatures by Dec 31, 2031. Contractors follow through a FAR rule. [Cloudflare analysis](https://blog.cloudflare.com/post-quantum-eo-2026)
|
|
37
|
+
|
|
38
|
+
### What's next
|
|
39
|
+
|
|
40
|
+
| Date | Milestone |
|
|
41
|
+
|------|-----------|
|
|
42
|
+
| **Jan 1, 2027** | CNSA 2.0: new National Security System acquisitions must be compliant |
|
|
43
|
+
| **2027** | Cloudflare fully post-quantum; EU Quantum Act PQC procurement rule (6 months after entry into force) |
|
|
44
|
+
| **Dec 31, 2030** | EO 14412 key-establishment deadline; EU high-risk systems migrated; NIST deprecation of RSA/ECC |
|
|
45
|
+
| **Dec 31, 2031** | EO 14412 signature deadline |
|
|
46
|
+
| **2035** | NIST disallows RSA/ECC; CNSA 2.0 complete |
|
|
47
|
+
|
|
48
|
+
### Why this means converting now
|
|
49
|
+
|
|
50
|
+
- **Data recorded today can be decrypted later.** Traffic protected by RSA or ECDH key exchange can be stored now and decrypted once a large quantum computer exists ("harvest now, decrypt later"). The key-exchange migration protects data you are sending today, so it can't wait for that computer to appear.
|
|
51
|
+
- **The deadlines now carry legal and contractual weight.** In four weeks CNSA 2.0 starts gating National Security System procurement. The federal 2030/2031 deadlines and the EU procurement rule follow, and Cloudflare-style vendor mandates pass the requirement down supply chains to companies that never dealt with government guidance. `pqaudit --policy cnsa-2.0` (or `nist-ir-8547`, `eu-pqc-roadmap`) checks your code against these dates.
|
|
52
|
+
- **Attack estimates keep falling, and AI is speeding up the research.** Qubit estimates for breaking RSA and ECC have dropped repeatedly. Both governments and vendors now cite AI-assisted cryptanalysis as a reason to move faster.
|
|
53
|
+
- **The new algorithms won't be the last change, so you need an inventory.** The Anthropic result doesn't break ML-KEM, and BSI's McEliece note didn't break McEliece either. Both show that confidence in specific math can shift within months. Hybrid schemes (X25519MLKEM768) and backups that don't rely on lattices (HQC, SLH-DSA, LMS/XMSS) hedge against that. The lasting defense is knowing where every algorithm lives so you can swap it again. That inventory is the CBOM (`pqaudit --format cbom`).
|
|
54
|
+
- **The tools are ready.** Hybrid key exchange is already the default in OpenSSL 3.5, OpenSSH 10, Go 1.24 and every major browser. Most of the time, migrating means upgrading and changing configuration, not new cryptographic engineering. `pqaudit` shows which code, configs, certificates and endpoints still lag behind.
|
|
14
55
|
|
|
15
56
|
## Install
|
|
16
57
|
|
|
@@ -54,22 +95,53 @@ pqaudit . --no-deps
|
|
|
54
95
|
|
|
55
96
|
# Use custom rules
|
|
56
97
|
pqaudit . --rules ./my-rules.yaml
|
|
98
|
+
|
|
99
|
+
# Scan TLS/SSH endpoints for quantum-vulnerable crypto
|
|
100
|
+
pqaudit . --scan-endpoint api.example.com:443 --scan-endpoint git.example.com:22
|
|
101
|
+
|
|
102
|
+
# Scan endpoints only (no code scanning)
|
|
103
|
+
pqaudit --scan-endpoint example.com:443 --scan-endpoint example.com:22
|
|
57
104
|
```
|
|
58
105
|
|
|
59
106
|
### All options
|
|
60
107
|
|
|
61
108
|
| Flag | Description | Default |
|
|
62
109
|
|------|-------------|---------|
|
|
63
|
-
| `-f, --format <format>` | Output format: `text`, `json`, `cbom`, `sarif` | `text` |
|
|
110
|
+
| `-f, --format <format>` | Output format: `text`, `json`, `cbom`, `sarif`, `html` | `text` |
|
|
64
111
|
| `-o, --output <file>` | Write output to file | stdout |
|
|
65
112
|
| `-s, --severity <level>` | Minimum severity: `critical`, `high`, `medium`, `low`, `safe` | `safe` |
|
|
66
113
|
| `--min-confidence <0-100>` | Filter findings below this confidence threshold | `50` |
|
|
67
114
|
| `--no-dedupe` | Show all occurrences instead of collapsing per file | dedupe on |
|
|
68
|
-
| `--no-deps` | Skip
|
|
115
|
+
| `--no-deps` | Skip dependency scanning | scan deps |
|
|
69
116
|
| `--include <patterns...>` | Glob patterns to include | all source files |
|
|
70
117
|
| `--exclude <patterns...>` | Additional glob patterns to exclude | node_modules, dist, etc. |
|
|
71
118
|
| `--rules <path>` | Path to custom rules YAML file | built-in rules |
|
|
72
|
-
| `--
|
|
119
|
+
| `--scan-endpoint <endpoints...>` | TLS/SSH endpoints to probe (`host:port`) | none |
|
|
120
|
+
| `--network-timeout <ms>` | Network connection timeout | `5000` |
|
|
121
|
+
| `--policy <file\|preset>` | Policy YAML, or a built-in preset: `cnsa-2.0`, `nist-ir-8547`, `eu-pqc-roadmap` | none |
|
|
122
|
+
| `--list-policies` | List built-in policy presets | |
|
|
123
|
+
| `--sbom <file>` | Enrich an existing CycloneDX/SPDX SBOM with findings | none |
|
|
124
|
+
| `--ci` | Exit code 1 if critical or high findings exist, 2 if a policy blocks | off |
|
|
125
|
+
|
|
126
|
+
### Compliance presets
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pqaudit . --policy cnsa-2.0 --ci # NSA CNSA 2.0 (blocks from 2027-01-01)
|
|
130
|
+
pqaudit . --policy nist-ir-8547 --ci # NIST IR 8547 (deprecated 2030, disallowed 2035)
|
|
131
|
+
pqaudit . --policy eu-pqc-roadmap --ci # EU PQC roadmap (high-risk by end-2030)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Presets live in [`policies/`](policies/). Each one warns today and escalates to `block` on its deadline (`block_after`). Copy one and edit it to match your organization's dates. Set `include_safe: true` on a policy to check quantum-resistant findings too. CNSA 2.0 uses this to reject SHA-256 and to ask for review of ML-KEM-768 vs. ML-KEM-1024.
|
|
135
|
+
|
|
136
|
+
### Suppressing findings
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
const etag = createHash("md5"); // pqaudit-ignore MD5_USAGE -- cache key only
|
|
140
|
+
// pqaudit-ignore-next-line DES_3DES -- legacy HSM interop, tracked in SEC-142
|
|
141
|
+
const c = createCipheriv("des-ede3-cbc", key, iv);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Leave out the rule IDs to suppress every rule on that line. Text after `--` is a free-form reason.
|
|
73
145
|
|
|
74
146
|
## Example output
|
|
75
147
|
|
|
@@ -88,13 +160,19 @@ pqaudit . --rules ./my-rules.yaml
|
|
|
88
160
|
src/crypto/signing.ts:14
|
|
89
161
|
> import { sign, verify } from "@noble/ed25519";
|
|
90
162
|
Fix: ML-DSA-65 (FIPS 204) or hybrid Ed25519+ML-DSA-65
|
|
91
|
-
Confidence:
|
|
163
|
+
Confidence: 98% | Effort: moderate | Via: ast
|
|
92
164
|
|
|
93
165
|
[!!] RSA — RSA signature — vulnerable to quantum factoring (3 occurrences)
|
|
94
166
|
src/auth/jwt.ts:42
|
|
95
167
|
> jwt.sign(payload, key, { algorithm: "RS256" });
|
|
96
168
|
Fix: ML-DSA-65 (FIPS 204)
|
|
97
|
-
Confidence:
|
|
169
|
+
Confidence: 96% | Effort: complex | Via: ast
|
|
170
|
+
|
|
171
|
+
[!!] ECDSA — Certificate uses ECDSA 256-bit key — vulnerable to Shor's algorithm
|
|
172
|
+
tls://api.example.com:443
|
|
173
|
+
> ECDSA 256-bit key, TLSv1.3
|
|
174
|
+
Fix: Post-quantum certificate algorithms when available
|
|
175
|
+
Confidence: 100% | Effort: complex | Via: network
|
|
98
176
|
...
|
|
99
177
|
```
|
|
100
178
|
|
|
@@ -106,18 +184,33 @@ pqaudit . --rules ./my-rules.yaml
|
|
|
106
184
|
|-----------|--------|-------------|
|
|
107
185
|
| RSA (any key size) | Shor's algorithm | ML-KEM-768 / ML-DSA-65 |
|
|
108
186
|
| ECDSA / Ed25519 | Shor's on elliptic curves | ML-DSA-65 (FIPS 204) |
|
|
109
|
-
| ECDH / X25519 / DH | Shor's on key exchange | ML-KEM-768 (FIPS 203) |
|
|
187
|
+
| ECDH / X25519 / DH | Shor's on key exchange | ML-KEM-768 (FIPS 203) / X25519MLKEM768 |
|
|
110
188
|
| DSA | Shor's algorithm | ML-DSA-65 (FIPS 204) |
|
|
189
|
+
| X.509 certificates & PEM keys (RSA/EC/Ed25519) | Decoded key type, size and expiry; flags certs valid past NIST's 2030/2035 deadlines | ML-DSA / composite certificates |
|
|
190
|
+
| Cloud KMS / Terraform key specs (`RSA_2048`, `ECC_NIST_P256`, `tls_private_key`) | Shor's algorithm | ML-DSA / ML-KEM key specs |
|
|
111
191
|
|
|
112
|
-
### High (weakened by quantum)
|
|
192
|
+
### High (weakened by quantum or outdated protocols)
|
|
113
193
|
|
|
114
194
|
| Algorithm | Threat | Replacement |
|
|
115
195
|
|-----------|--------|-------------|
|
|
116
196
|
| AES-128 | Grover reduces to 64-bit | AES-256 |
|
|
197
|
+
| TLS 1.0/1.1, SSLv3 | Deprecated protocols | TLS 1.3 |
|
|
198
|
+
| SSH server (network) that offers no PQ key exchange, or whose offer couldn't be read | DH/ECDH key exchange | mlkem768x25519-sha256 |
|
|
199
|
+
|
|
200
|
+
### Low (review)
|
|
201
|
+
|
|
202
|
+
| Finding | Why |
|
|
203
|
+
|---------|-----|
|
|
204
|
+
| Pre-standard Kyber / Dilithium / SPHINCS+, `X25519Kyber768Draft00` | Round-3 variants are not interoperable with FIPS 203/204/205. Browsers and servers dropped the draft Kyber codepoint |
|
|
205
|
+
| ML-KEM-512, ML-DSA-44 | Smallest parameter sets. They aren't broken, but after the Nov 2026 structured-lattice results the CIRG review recommends the highest security level each application supports. CNSA 2.0 requires ML-KEM-1024 and ML-DSA-87 |
|
|
206
|
+
| Classic McEliece | BSI advises against new deployments (Sep 2026) after cryptanalytic progress. Keep existing use hybrid-only |
|
|
207
|
+
| Classical group listed *after* a hybrid PQ group (`X25519MLKEM768:X25519`) | Interoperability fallback, which is the recommended migration posture. Remove it once all peers support PQ |
|
|
117
208
|
|
|
118
209
|
### Safe (already quantum-resistant)
|
|
119
210
|
|
|
120
|
-
ML-KEM (
|
|
211
|
+
ML-KEM (FIPS 203), ML-DSA (FIPS 204), SLH-DSA (FIPS 205), hybrid key exchange (X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024, mlkem768x25519-sha256, sntrup761x25519-sha512), composite ML-DSA, FN-DSA (draft FIPS 206), HQC, LMS/XMSS, FrodoKEM, sntrup761, AES-256, ChaCha20-Poly1305, SHA-256, SHA-384/512, SHA-3
|
|
212
|
+
|
|
213
|
+
When matches overlap on a line, the most specific one wins. `RSA-SHA256` is an RSA signature, not a "safe SHA-256", and `X25519MLKEM768` is a hybrid PQ group, not vulnerable X25519.
|
|
121
214
|
|
|
122
215
|
## Output formats
|
|
123
216
|
|
|
@@ -137,6 +230,14 @@ Generates SARIF 2.1.0 output compatible with GitHub's code scanning. Upload via
|
|
|
137
230
|
pqaudit . --format sarif --output results.sarif
|
|
138
231
|
```
|
|
139
232
|
|
|
233
|
+
### HTML report
|
|
234
|
+
|
|
235
|
+
Self-contained HTML file with a visual dashboard — severity breakdown, PQC readiness score, and findings table. No external dependencies, works offline.
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
pqaudit . --format html --output report.html
|
|
239
|
+
```
|
|
240
|
+
|
|
140
241
|
## GitHub Action
|
|
141
242
|
|
|
142
243
|
```yaml
|
|
@@ -149,7 +250,7 @@ jobs:
|
|
|
149
250
|
- uses: actions/checkout@v4
|
|
150
251
|
- uses: actions/setup-node@v4
|
|
151
252
|
with:
|
|
152
|
-
node-version: "
|
|
253
|
+
node-version: "24"
|
|
153
254
|
- run: npx pqaudit . --format sarif --output pqaudit.sarif --ci
|
|
154
255
|
- uses: github/codeql-action/upload-sarif@v3
|
|
155
256
|
if: always()
|
|
@@ -160,13 +261,17 @@ jobs:
|
|
|
160
261
|
|
|
161
262
|
## Dependency scanning
|
|
162
263
|
|
|
163
|
-
pqaudit checks
|
|
264
|
+
pqaudit checks manifest files for known cryptographic libraries across five ecosystems:
|
|
164
265
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- `jsonwebtoken`, `
|
|
168
|
-
|
|
169
|
-
|
|
266
|
+
| Ecosystem | Manifest files | Example packages |
|
|
267
|
+
|-----------|---------------|-----------------|
|
|
268
|
+
| **npm** | `package.json` | `@noble/ed25519`, `node-rsa`, `jsonwebtoken`, `ethers` |
|
|
269
|
+
| **Rust** | `Cargo.toml` | `ed25519-dalek`, `rsa`, `ring`, `p256`, `pqcrypto` |
|
|
270
|
+
| **Go** | `go.mod` | `golang.org/x/crypto`, `cloudflare/circl` |
|
|
271
|
+
| **Python** | `requirements.txt`, `pyproject.toml` | `cryptography`, `pycryptodome`, `paramiko` |
|
|
272
|
+
| **Java** | `build.gradle`, `pom.xml` | BouncyCastle, Google Tink |
|
|
273
|
+
|
|
274
|
+
PQC-safe libraries (`@noble/post-quantum`, `pqcrypto`, `cloudflare/circl`) are flagged as **safe** for inventory tracking.
|
|
170
275
|
|
|
171
276
|
## Custom rules
|
|
172
277
|
|
|
@@ -188,14 +293,54 @@ Rules are defined in YAML:
|
|
|
188
293
|
|
|
189
294
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full rule schema and how to submit new rules.
|
|
190
295
|
|
|
296
|
+
## Protocol and config detection
|
|
297
|
+
|
|
298
|
+
pqaudit scans configuration files for quantum-vulnerable crypto settings:
|
|
299
|
+
|
|
300
|
+
- **SSH**: RSA/ECDSA key types, DH/ECDH key exchange in `sshd_config`/`ssh_config`
|
|
301
|
+
- **TLS**: deprecated protocols (1.0/1.1/SSLv3) and vulnerable cipher suites in nginx/apache/haproxy configs
|
|
302
|
+
- **Kubernetes**: TLS secrets and cert-manager RSA private keys
|
|
303
|
+
- **Docker**: crypto library installs in Dockerfiles
|
|
304
|
+
|
|
305
|
+
Extensionless config files (`Dockerfile`, `sshd_config`, `ssh_config`) are automatically detected and scanned.
|
|
306
|
+
|
|
307
|
+
## Network scanning
|
|
308
|
+
|
|
309
|
+
Probe live TLS and SSH endpoints for quantum-vulnerable crypto configurations:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
pqaudit --scan-endpoint api.example.com:443 --scan-endpoint git.example.com:22
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**TLS endpoints** (any port, or specify `tls://host:port`):
|
|
316
|
+
- Negotiated protocol version (TLS 1.2 vs 1.3)
|
|
317
|
+
- Cipher suite key exchange (RSA static, ECDHE — both quantum-vulnerable)
|
|
318
|
+
- Negotiated TLS 1.3 key-exchange group: hybrid `X25519MLKEM768` vs. classical X25519/P-256
|
|
319
|
+
- Certificate public key algorithm, size and expiry (RSA, ECDSA, Ed25519, ML-DSA)
|
|
320
|
+
|
|
321
|
+
**SSH endpoints** (port 22 auto-detected, or specify `ssh://host:port`):
|
|
322
|
+
- Reads the server's algorithm offer (`SSH_MSG_KEXINIT`). The server sends it in the clear right after the version exchange, so no login or key exchange takes place
|
|
323
|
+
- Post-quantum key exchange (`mlkem768x25519-sha256`, `sntrup761x25519-sha512`) is reported as safe. Classical methods offered alongside it for older clients are listed as low-severity fallbacks, and a server offering only classical methods is critical
|
|
324
|
+
- Host key algorithms (Ed25519, ECDSA, RSA): quantum-vulnerable, critical
|
|
325
|
+
- Classically weak legacy algorithms still offered (`diffie-hellman-group1-sha1`, `ssh-dss`, `ssh-rsa`, 3DES, `hmac-md5`, …) are reported as medium
|
|
326
|
+
|
|
327
|
+
In SSH the client's preference order decides which key exchange is used, so the server only has to *offer* a post-quantum method. Clients need OpenSSH ≥ 9.9 to pick ML-KEM. Some systems' bundled ssh configs (for example macOS's `/etc/ssh/crypto.conf`) push classical `ecdh-sha2-nistp256` ahead of it, so check your clients too: `ssh -G host | grep kexalgorithms`.
|
|
328
|
+
|
|
329
|
+
Network findings have 100% confidence (observed facts, not pattern matches) and appear alongside code findings in all output formats.
|
|
330
|
+
|
|
191
331
|
## Detection methods
|
|
192
332
|
|
|
193
|
-
|
|
333
|
+
pqaudit uses four detection methods:
|
|
334
|
+
|
|
335
|
+
- **L0 (regex)**: Pattern matching across all supported languages and config files
|
|
336
|
+
- **L1 (AST)**: Tree-sitter parsing for JS/TS — detects actual imports, function calls, API usage (0.95-0.98 confidence)
|
|
337
|
+
- **Dependency**: Manifest file scanning across npm, Cargo, Go, pip, and Gradle/Maven
|
|
338
|
+
- **Certificate**: Decodes X.509 certificates (PEM and DER) and SPKI/PKCS#8 keys for key type, size and expiry. ML-DSA/ML-KEM/SLH-DSA keys are recognized by OID even where the local OpenSSL predates 3.5
|
|
339
|
+
- **Network**: Live TLS/SSH endpoint probing for cipher suites, the negotiated TLS 1.3 key-exchange group, and certificate algorithms (100% confidence). The probe offers X25519MLKEM768 when Node is linked against OpenSSL ≥ 3.5 (Node 24+). TLS 1.3 with plain X25519 is reported as quantum-vulnerable (harvest now, decrypt later). Use Node 24+ for network scans: Node 22 can negotiate the hybrid group, but it can't report the group's name, so the result is shown as unconfirmed
|
|
340
|
+
|
|
341
|
+
Planned:
|
|
194
342
|
|
|
195
|
-
- **L1**: AST-based analysis via tree-sitter for semantic understanding and fewer false positives
|
|
196
343
|
- **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
344
|
|
|
200
345
|
## Contributing
|
|
201
346
|
|
|
@@ -206,6 +351,15 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on submitting rules, bug f
|
|
|
206
351
|
- [NIST FIPS 203 — ML-KEM](https://csrc.nist.gov/pubs/fips/203/final)
|
|
207
352
|
- [NIST FIPS 204 — ML-DSA](https://csrc.nist.gov/pubs/fips/204/final)
|
|
208
353
|
- [NIST FIPS 205 — SLH-DSA](https://csrc.nist.gov/pubs/fips/205/final)
|
|
354
|
+
- [NIST IR 8547 — Transition to PQC Standards](https://csrc.nist.gov/pubs/ir/8547)
|
|
355
|
+
- [Joint statement on post-quantum cryptography (Dec 2026)](https://www.anthropic.com/news/joint-statement-post-quantum-cryptography)
|
|
356
|
+
- [CISA/NSA/ONCD joint statement (Dec 2026)](https://www.cisa.gov/news-events/news/joint-statement-recent-advances-cryptographic-and-cybersecurity-capabilities)
|
|
357
|
+
- [Cloudflare — Project Quantum Leap (Dec 2026)](https://blog.cloudflare.com/project-quantum-leap)
|
|
358
|
+
- [EU Quantum Act](https://digital-strategy.ec.europa.eu/en/policies/quantum-act)
|
|
359
|
+
- [CIRG — Initial assessment of Anthropic's lattice findings (Nov 2026)](https://cirg.org/statements/1/)
|
|
360
|
+
- [BSI — Notes on recent developments concerning Classic McEliece (Sep 2026)](https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Crypto/Notes_Classic_McEliece.html)
|
|
361
|
+
- [EU Coordinated Implementation Roadmap for PQC](https://digital-strategy.ec.europa.eu/en/library/coordinated-implementation-roadmap-transition-post-quantum-cryptography)
|
|
362
|
+
- [OpenSSH post-quantum cryptography](https://www.openssh.com/pq.html)
|
|
209
363
|
- [NSA CNSA 2.0 Timeline](https://media.defense.gov/2022/Sep/07/2003071836/-1/-1/0/CSI_CNSA_2.0_FAQ_.PDF)
|
|
210
364
|
- [CycloneDX CBOM Specification](https://cyclonedx.org/capabilities/cbom/)
|
|
211
365
|
- [Google PQC Migration Timeline (March 2026)](https://blog.google/innovation-and-ai/technology/safety-security/cryptography-migration-timeline/)
|
package/dist/cli.js
CHANGED
|
@@ -6,13 +6,16 @@ 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";
|
|
10
|
+
import { listPresets } from "./policy/loader.js";
|
|
11
|
+
import { VERSION } from "./version.js";
|
|
9
12
|
const program = new Command();
|
|
10
13
|
program
|
|
11
14
|
.name("pqaudit")
|
|
12
15
|
.description("Scan codebases for quantum-vulnerable cryptography and generate a Cryptographic Bill of Materials (CBOM)")
|
|
13
|
-
.version(
|
|
16
|
+
.version(VERSION)
|
|
14
17
|
.argument("[target]", "Directory to scan", ".")
|
|
15
|
-
.option("-f, --format <format>", "Output format: text, json, cbom, sarif", "text")
|
|
18
|
+
.option("-f, --format <format>", "Output format: text, json, cbom, sarif, html", "text")
|
|
16
19
|
.option("-o, --output <file>", "Write output to file instead of stdout")
|
|
17
20
|
.option("-s, --severity <level>", "Minimum severity to report: critical, high, medium, low, safe", "safe")
|
|
18
21
|
.option("--no-deps", "Skip dependency scanning")
|
|
@@ -22,8 +25,37 @@ program
|
|
|
22
25
|
.option("--min-confidence <number>", "Minimum confidence 0-100 (default 50)", "50")
|
|
23
26
|
.option("--dedupe", "Collapse duplicate findings per file (default: true)")
|
|
24
27
|
.option("--no-dedupe", "Show all occurrences instead of collapsing duplicates")
|
|
28
|
+
.option("--sbom <file>", "Path to existing SBOM (CycloneDX or SPDX JSON) to enrich")
|
|
29
|
+
.option("--sbom-format <format>", "SBOM format: cyclonedx, spdx (auto-detected if omitted)")
|
|
30
|
+
.option("--policy <file|preset>", `Policy YAML file, or a built-in preset: ${listPresets().join(", ")}`)
|
|
31
|
+
.option("--list-policies", "List built-in compliance policy presets and exit")
|
|
32
|
+
.option("--scan-endpoint <endpoints...>", "TLS/SSH endpoints to probe (host:port)")
|
|
33
|
+
.option("--network-timeout <ms>", "Network connection timeout in ms", "5000")
|
|
25
34
|
.option("--ci", "Exit with code 1 if critical/high findings exist")
|
|
26
35
|
.action(async (target, opts) => {
|
|
36
|
+
if (opts.listPolicies) {
|
|
37
|
+
for (const p of listPresets())
|
|
38
|
+
console.log(p);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const endpoints = opts.scanEndpoint?.map((ep) => {
|
|
42
|
+
// Support tls:// and ssh:// prefixes
|
|
43
|
+
let protocol = "tls";
|
|
44
|
+
let addr = ep;
|
|
45
|
+
if (ep.startsWith("ssh://")) {
|
|
46
|
+
protocol = "ssh";
|
|
47
|
+
addr = ep.slice(6);
|
|
48
|
+
}
|
|
49
|
+
else if (ep.startsWith("tls://")) {
|
|
50
|
+
addr = ep.slice(6);
|
|
51
|
+
}
|
|
52
|
+
const [host, portStr] = addr.split(":");
|
|
53
|
+
const port = portStr ? parseInt(portStr, 10) : protocol === "ssh" ? 22 : 443;
|
|
54
|
+
// Auto-detect SSH from port 22
|
|
55
|
+
if (port === 22 && !ep.startsWith("tls://"))
|
|
56
|
+
protocol = "ssh";
|
|
57
|
+
return { host, port, protocol };
|
|
58
|
+
});
|
|
27
59
|
const config = {
|
|
28
60
|
target,
|
|
29
61
|
format: opts.format,
|
|
@@ -35,35 +67,67 @@ program
|
|
|
35
67
|
rulesDir: opts.rules,
|
|
36
68
|
minConfidence: Number(opts.minConfidence),
|
|
37
69
|
dedupe: opts.dedupe !== false,
|
|
70
|
+
endpoints,
|
|
71
|
+
networkTimeout: Number(opts.networkTimeout),
|
|
72
|
+
sbomInput: opts.sbom,
|
|
73
|
+
sbomFormat: opts.sbomFormat,
|
|
74
|
+
policyFile: opts.policy,
|
|
38
75
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
case "json":
|
|
43
|
-
output = formatJson(result);
|
|
44
|
-
break;
|
|
45
|
-
case "cbom":
|
|
46
|
-
output = formatCbom(result);
|
|
47
|
-
break;
|
|
48
|
-
case "sarif":
|
|
49
|
-
output = formatSarif(result);
|
|
50
|
-
break;
|
|
51
|
-
case "text":
|
|
52
|
-
default:
|
|
53
|
-
output = formatText(result);
|
|
54
|
-
break;
|
|
76
|
+
let result;
|
|
77
|
+
try {
|
|
78
|
+
result = await scan(config);
|
|
55
79
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
catch (err) {
|
|
81
|
+
console.error(`pqaudit: ${err.message}`);
|
|
82
|
+
process.exit(3);
|
|
83
|
+
}
|
|
84
|
+
// If SBOM enrichment was done, output the enriched SBOM instead of normal format
|
|
85
|
+
if (result.enrichedSbom) {
|
|
86
|
+
const sbomOutput = JSON.stringify(result.enrichedSbom, null, 2);
|
|
87
|
+
if (config.output) {
|
|
88
|
+
writeFileSync(config.output, sbomOutput, "utf-8");
|
|
89
|
+
console.log(`Enriched SBOM written to ${config.output}`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log(sbomOutput);
|
|
60
93
|
}
|
|
61
94
|
}
|
|
62
95
|
else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
let output;
|
|
97
|
+
switch (config.format) {
|
|
98
|
+
case "json":
|
|
99
|
+
output = formatJson(result);
|
|
100
|
+
break;
|
|
101
|
+
case "cbom":
|
|
102
|
+
output = formatCbom(result);
|
|
103
|
+
break;
|
|
104
|
+
case "sarif":
|
|
105
|
+
output = formatSarif(result);
|
|
106
|
+
break;
|
|
107
|
+
case "html":
|
|
108
|
+
output = formatHtml(result);
|
|
109
|
+
break;
|
|
110
|
+
case "text":
|
|
111
|
+
default:
|
|
112
|
+
output = formatText(result);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (config.output) {
|
|
116
|
+
writeFileSync(config.output, output, "utf-8");
|
|
117
|
+
if (config.format === "text") {
|
|
118
|
+
console.log(`Results written to ${config.output}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log(output);
|
|
123
|
+
}
|
|
124
|
+
} // end else (no SBOM enrichment)
|
|
125
|
+
// CI mode: exit 1 if critical/high findings, exit 2 if blocking policy violations
|
|
66
126
|
if (opts.ci) {
|
|
127
|
+
const blockingViolations = result.policyViolations?.filter((v) => v.action === "block");
|
|
128
|
+
if (blockingViolations && blockingViolations.length > 0) {
|
|
129
|
+
process.exit(2);
|
|
130
|
+
}
|
|
67
131
|
const { critical, high } = result.summary.bySeverity;
|
|
68
132
|
if (critical > 0 || high > 0) {
|
|
69
133
|
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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;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,11 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Case-insensitive token match: "RSA" matches "RSA/ECDSA/DSA" and
|
|
6
|
+
* "secp256k1 (ECDSA)" matches "ECDSA", but "SHA-3" does not match "SHA-384".
|
|
7
|
+
*/
|
|
8
|
+
export declare function algorithmMatches(findingAlgorithm: string, policyAlgorithm: string): boolean;
|
|
9
|
+
/** A "warn" policy with block_after escalates to "block" from that date */
|
|
10
|
+
export declare function effectiveAction(policy: Policy, now: Date): "warn" | "block";
|
|
11
|
+
//# 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,CAwBnB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAK3F;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAG3E"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
for (const policy of policies) {
|
|
7
|
+
// Safe findings only count for policies that opt in (e.g. CNSA 2.0
|
|
8
|
+
// rejects SHA-256 even though it is quantum-resistant)
|
|
9
|
+
if (finding.severity === "safe" && !policy.include_safe)
|
|
10
|
+
continue;
|
|
11
|
+
if (matches(policy, finding, now)) {
|
|
12
|
+
violations.push({
|
|
13
|
+
policyId: policy.id,
|
|
14
|
+
description: policy.description ?? policy.id,
|
|
15
|
+
action: effectiveAction(policy, now),
|
|
16
|
+
finding,
|
|
17
|
+
message: policy.message ?? `Violates policy "${policy.id}"`,
|
|
18
|
+
deadline: policy.deadline,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return violations;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Case-insensitive token match: "RSA" matches "RSA/ECDSA/DSA" and
|
|
27
|
+
* "secp256k1 (ECDSA)" matches "ECDSA", but "SHA-3" does not match "SHA-384".
|
|
28
|
+
*/
|
|
29
|
+
export function algorithmMatches(findingAlgorithm, policyAlgorithm) {
|
|
30
|
+
const escaped = policyAlgorithm.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
|
+
return new RegExp(`(?:^|[^a-z0-9])${escaped}(?:$|[^a-z0-9])`).test(findingAlgorithm.toLowerCase());
|
|
32
|
+
}
|
|
33
|
+
/** A "warn" policy with block_after escalates to "block" from that date */
|
|
34
|
+
export function effectiveAction(policy, now) {
|
|
35
|
+
if (policy.block_after && now >= new Date(policy.block_after))
|
|
36
|
+
return "block";
|
|
37
|
+
return policy.action;
|
|
38
|
+
}
|
|
39
|
+
function matches(policy, finding, now) {
|
|
40
|
+
// Deadline check — if deadline is in the future, skip (not yet enforced)
|
|
41
|
+
if (policy.deadline) {
|
|
42
|
+
const deadline = new Date(policy.deadline);
|
|
43
|
+
if (now < deadline)
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// Confidence threshold — skip findings below the policy minimum
|
|
47
|
+
if (policy.min_confidence !== undefined && finding.confidence < policy.min_confidence) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
// Algorithm filter
|
|
51
|
+
if (policy.algorithm) {
|
|
52
|
+
const algos = Array.isArray(policy.algorithm) ? policy.algorithm : [policy.algorithm];
|
|
53
|
+
if (!algos.some((a) => algorithmMatches(finding.algorithm, a))) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Category filter
|
|
58
|
+
if (policy.category) {
|
|
59
|
+
const cats = Array.isArray(policy.category) ? policy.category : [policy.category];
|
|
60
|
+
if (!cats.includes(finding.category))
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Severity filter
|
|
64
|
+
if (policy.severity) {
|
|
65
|
+
const sevs = Array.isArray(policy.severity) ? policy.severity : [policy.severity];
|
|
66
|
+
if (!sevs.includes(finding.severity))
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
// If no algorithm/category/severity filter was specified, match all non-safe findings
|
|
70
|
+
if (!policy.algorithm && !policy.category && !policy.severity) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0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,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,10 @@
|
|
|
1
|
+
import type { Policy } from "../types.js";
|
|
2
|
+
/** Built-in compliance presets shipped in <package>/policies/*.yaml */
|
|
3
|
+
export declare const PRESETS_DIR: string;
|
|
4
|
+
/** Names of the built-in policy presets (e.g. "cnsa-2.0", "nist-ir-8547") */
|
|
5
|
+
export declare function listPresets(): string[];
|
|
6
|
+
/** Resolve a --policy argument: an existing file path, or a preset name */
|
|
7
|
+
export declare function resolvePolicyPath(nameOrPath: string): string;
|
|
8
|
+
/** Load and validate policy definitions from a YAML file or preset name */
|
|
9
|
+
export declare function loadPolicies(nameOrPath: string): Policy[];
|
|
10
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/policy/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C,uEAAuE;AACvE,eAAO,MAAM,WAAW,QAAiD,CAAC;AAE1E,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAMtC;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAS5D;AAQD,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBzD"}
|