@quantakrypto/core 0.4.3 → 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.
Files changed (314) hide show
  1. package/README.md +76 -27
  2. package/dist/cbom-merge.d.ts +9 -0
  3. package/dist/cbom-merge.d.ts.map +1 -0
  4. package/dist/cbom-merge.js +121 -0
  5. package/dist/cbom-merge.js.map +1 -0
  6. package/dist/cbom.d.ts +5 -0
  7. package/dist/cbom.d.ts.map +1 -1
  8. package/dist/cbom.js +132 -37
  9. package/dist/cbom.js.map +1 -1
  10. package/dist/comments.d.ts +6 -26
  11. package/dist/comments.d.ts.map +1 -1
  12. package/dist/comments.js +77 -38
  13. package/dist/comments.js.map +1 -1
  14. package/dist/dependencies.d.ts.map +1 -1
  15. package/dist/dependencies.js +1 -1
  16. package/dist/dependencies.js.map +1 -1
  17. package/dist/detect-utils.d.ts +59 -21
  18. package/dist/detect-utils.d.ts.map +1 -1
  19. package/dist/detect-utils.js +143 -8
  20. package/dist/detect-utils.js.map +1 -1
  21. package/dist/detectors/age.d.ts +16 -0
  22. package/dist/detectors/age.d.ts.map +1 -0
  23. package/dist/detectors/age.js +40 -0
  24. package/dist/detectors/age.js.map +1 -0
  25. package/dist/detectors/ansible.d.ts +13 -0
  26. package/dist/detectors/ansible.d.ts.map +1 -0
  27. package/dist/detectors/ansible.js +108 -0
  28. package/dist/detectors/ansible.js.map +1 -0
  29. package/dist/detectors/bicep.d.ts +20 -0
  30. package/dist/detectors/bicep.d.ts.map +1 -0
  31. package/dist/detectors/bicep.js +74 -0
  32. package/dist/detectors/bicep.js.map +1 -0
  33. package/dist/detectors/c.d.ts +4 -2
  34. package/dist/detectors/c.d.ts.map +1 -1
  35. package/dist/detectors/c.js +222 -4
  36. package/dist/detectors/c.js.map +1 -1
  37. package/dist/detectors/cicd.d.ts +27 -0
  38. package/dist/detectors/cicd.d.ts.map +1 -0
  39. package/dist/detectors/cicd.js +129 -0
  40. package/dist/detectors/cicd.js.map +1 -0
  41. package/dist/detectors/cloud-kms.d.ts +24 -0
  42. package/dist/detectors/cloud-kms.d.ts.map +1 -0
  43. package/dist/detectors/cloud-kms.js +99 -0
  44. package/dist/detectors/cloud-kms.js.map +1 -0
  45. package/dist/detectors/cloudformation.d.ts +38 -0
  46. package/dist/detectors/cloudformation.d.ts.map +1 -0
  47. package/dist/detectors/cloudformation.js +201 -0
  48. package/dist/detectors/cloudformation.js.map +1 -0
  49. package/dist/detectors/codesign.d.ts +50 -0
  50. package/dist/detectors/codesign.d.ts.map +1 -0
  51. package/dist/detectors/codesign.js +143 -0
  52. package/dist/detectors/codesign.js.map +1 -0
  53. package/dist/detectors/csharp.d.ts.map +1 -1
  54. package/dist/detectors/csharp.js +13 -3
  55. package/dist/detectors/csharp.js.map +1 -1
  56. package/dist/detectors/dart.d.ts +35 -0
  57. package/dist/detectors/dart.d.ts.map +1 -0
  58. package/dist/detectors/dart.js +177 -0
  59. package/dist/detectors/dart.js.map +1 -0
  60. package/dist/detectors/database.d.ts +19 -0
  61. package/dist/detectors/database.d.ts.map +1 -0
  62. package/dist/detectors/database.js +97 -0
  63. package/dist/detectors/database.js.map +1 -0
  64. package/dist/detectors/dkim.d.ts +54 -0
  65. package/dist/detectors/dkim.d.ts.map +1 -0
  66. package/dist/detectors/dkim.js +92 -0
  67. package/dist/detectors/dkim.js.map +1 -0
  68. package/dist/detectors/dnssec.d.ts +55 -0
  69. package/dist/detectors/dnssec.d.ts.map +1 -0
  70. package/dist/detectors/dnssec.js +116 -0
  71. package/dist/detectors/dnssec.js.map +1 -0
  72. package/dist/detectors/elixir.d.ts +20 -0
  73. package/dist/detectors/elixir.d.ts.map +1 -0
  74. package/dist/detectors/elixir.js +227 -0
  75. package/dist/detectors/elixir.js.map +1 -0
  76. package/dist/detectors/java.d.ts.map +1 -1
  77. package/dist/detectors/java.js +34 -4
  78. package/dist/detectors/java.js.map +1 -1
  79. package/dist/detectors/jose.d.ts +20 -0
  80. package/dist/detectors/jose.d.ts.map +1 -0
  81. package/dist/detectors/jose.js +72 -0
  82. package/dist/detectors/jose.js.map +1 -0
  83. package/dist/detectors/jwk.d.ts +25 -0
  84. package/dist/detectors/jwk.d.ts.map +1 -0
  85. package/dist/detectors/jwk.js +131 -0
  86. package/dist/detectors/jwk.js.map +1 -0
  87. package/dist/detectors/k8s.d.ts +17 -0
  88. package/dist/detectors/k8s.d.ts.map +1 -0
  89. package/dist/detectors/k8s.js +88 -0
  90. package/dist/detectors/k8s.js.map +1 -0
  91. package/dist/detectors/keystore.d.ts +19 -0
  92. package/dist/detectors/keystore.d.ts.map +1 -0
  93. package/dist/detectors/keystore.js +76 -0
  94. package/dist/detectors/keystore.js.map +1 -0
  95. package/dist/detectors/mesh.d.ts +34 -0
  96. package/dist/detectors/mesh.d.ts.map +1 -0
  97. package/dist/detectors/mesh.js +91 -0
  98. package/dist/detectors/mesh.js.map +1 -0
  99. package/dist/detectors/messaging.d.ts +16 -0
  100. package/dist/detectors/messaging.d.ts.map +1 -0
  101. package/dist/detectors/messaging.js +79 -0
  102. package/dist/detectors/messaging.js.map +1 -0
  103. package/dist/detectors/objc.d.ts +41 -0
  104. package/dist/detectors/objc.d.ts.map +1 -0
  105. package/dist/detectors/objc.js +146 -0
  106. package/dist/detectors/objc.js.map +1 -0
  107. package/dist/detectors/openpgp.d.ts +20 -0
  108. package/dist/detectors/openpgp.d.ts.map +1 -0
  109. package/dist/detectors/openpgp.js +151 -0
  110. package/dist/detectors/openpgp.js.map +1 -0
  111. package/dist/detectors/pem.d.ts.map +1 -1
  112. package/dist/detectors/pem.js +33 -1
  113. package/dist/detectors/pem.js.map +1 -1
  114. package/dist/detectors/php.d.ts +25 -0
  115. package/dist/detectors/php.d.ts.map +1 -0
  116. package/dist/detectors/php.js +171 -0
  117. package/dist/detectors/php.js.map +1 -0
  118. package/dist/detectors/pkcs11.d.ts +17 -0
  119. package/dist/detectors/pkcs11.d.ts.map +1 -0
  120. package/dist/detectors/pkcs11.js +87 -0
  121. package/dist/detectors/pkcs11.js.map +1 -0
  122. package/dist/detectors/proxy.d.ts +52 -0
  123. package/dist/detectors/proxy.d.ts.map +1 -0
  124. package/dist/detectors/proxy.js +157 -0
  125. package/dist/detectors/proxy.js.map +1 -0
  126. package/dist/detectors/pulumi.d.ts +19 -0
  127. package/dist/detectors/pulumi.d.ts.map +1 -0
  128. package/dist/detectors/pulumi.js +80 -0
  129. package/dist/detectors/pulumi.js.map +1 -0
  130. package/dist/detectors/python.d.ts.map +1 -1
  131. package/dist/detectors/python.js +70 -0
  132. package/dist/detectors/python.js.map +1 -1
  133. package/dist/detectors/rust.d.ts.map +1 -1
  134. package/dist/detectors/rust.js +73 -0
  135. package/dist/detectors/rust.js.map +1 -1
  136. package/dist/detectors/secrets.d.ts +24 -0
  137. package/dist/detectors/secrets.d.ts.map +1 -0
  138. package/dist/detectors/secrets.js +63 -0
  139. package/dist/detectors/secrets.js.map +1 -0
  140. package/dist/detectors/solidity.d.ts +50 -0
  141. package/dist/detectors/solidity.d.ts.map +1 -0
  142. package/dist/detectors/solidity.js +108 -0
  143. package/dist/detectors/solidity.js.map +1 -0
  144. package/dist/detectors/source.d.ts.map +1 -1
  145. package/dist/detectors/source.js +243 -53
  146. package/dist/detectors/source.js.map +1 -1
  147. package/dist/detectors/spire.d.ts +49 -0
  148. package/dist/detectors/spire.d.ts.map +1 -0
  149. package/dist/detectors/spire.js +77 -0
  150. package/dist/detectors/spire.js.map +1 -0
  151. package/dist/detectors/ssh-ca.d.ts +72 -0
  152. package/dist/detectors/ssh-ca.d.ts.map +1 -0
  153. package/dist/detectors/ssh-ca.js +119 -0
  154. package/dist/detectors/ssh-ca.js.map +1 -0
  155. package/dist/detectors/stateful-hbs.d.ts.map +1 -1
  156. package/dist/detectors/stateful-hbs.js +9 -6
  157. package/dist/detectors/stateful-hbs.js.map +1 -1
  158. package/dist/detectors/supply-chain.d.ts +17 -0
  159. package/dist/detectors/supply-chain.d.ts.map +1 -0
  160. package/dist/detectors/supply-chain.js +89 -0
  161. package/dist/detectors/supply-chain.js.map +1 -0
  162. package/dist/detectors/swift.d.ts +22 -0
  163. package/dist/detectors/swift.d.ts.map +1 -0
  164. package/dist/detectors/swift.js +120 -0
  165. package/dist/detectors/swift.js.map +1 -0
  166. package/dist/detectors/terraform.d.ts +21 -0
  167. package/dist/detectors/terraform.d.ts.map +1 -0
  168. package/dist/detectors/terraform.js +150 -0
  169. package/dist/detectors/terraform.js.map +1 -0
  170. package/dist/detectors/vault.d.ts +15 -0
  171. package/dist/detectors/vault.d.ts.map +1 -0
  172. package/dist/detectors/vault.js +97 -0
  173. package/dist/detectors/vault.js.map +1 -0
  174. package/dist/detectors/vpn.d.ts +22 -0
  175. package/dist/detectors/vpn.d.ts.map +1 -0
  176. package/dist/detectors/vpn.js +73 -0
  177. package/dist/detectors/vpn.js.map +1 -0
  178. package/dist/detectors/weak-hash.d.ts +71 -0
  179. package/dist/detectors/weak-hash.d.ts.map +1 -0
  180. package/dist/detectors/weak-hash.js +116 -0
  181. package/dist/detectors/weak-hash.js.map +1 -0
  182. package/dist/detectors/webauthn.d.ts +61 -0
  183. package/dist/detectors/webauthn.d.ts.map +1 -0
  184. package/dist/detectors/webauthn.js +109 -0
  185. package/dist/detectors/webauthn.js.map +1 -0
  186. package/dist/detectors/xmldsig.d.ts +23 -0
  187. package/dist/detectors/xmldsig.d.ts.map +1 -0
  188. package/dist/detectors/xmldsig.js +84 -0
  189. package/dist/detectors/xmldsig.js.map +1 -0
  190. package/dist/evidence.d.ts +79 -4
  191. package/dist/evidence.d.ts.map +1 -1
  192. package/dist/evidence.js +76 -0
  193. package/dist/evidence.js.map +1 -1
  194. package/dist/index.d.ts +17 -9
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +21 -9
  197. package/dist/index.js.map +1 -1
  198. package/dist/inventory.d.ts +0 -2
  199. package/dist/inventory.d.ts.map +1 -1
  200. package/dist/inventory.js +15 -6
  201. package/dist/inventory.js.map +1 -1
  202. package/dist/policy.d.ts +67 -0
  203. package/dist/policy.d.ts.map +1 -0
  204. package/dist/policy.js +115 -0
  205. package/dist/policy.js.map +1 -0
  206. package/dist/registry.d.ts +9 -4
  207. package/dist/registry.d.ts.map +1 -1
  208. package/dist/registry.js +81 -4
  209. package/dist/registry.js.map +1 -1
  210. package/dist/remediate-pipeline.d.ts +0 -3
  211. package/dist/remediate-pipeline.d.ts.map +1 -1
  212. package/dist/remediate-pipeline.js +23 -2
  213. package/dist/remediate-pipeline.js.map +1 -1
  214. package/dist/remediation.d.ts +10 -0
  215. package/dist/remediation.d.ts.map +1 -1
  216. package/dist/remediation.js +32 -0
  217. package/dist/remediation.js.map +1 -1
  218. package/dist/report.d.ts +9 -0
  219. package/dist/report.d.ts.map +1 -1
  220. package/dist/report.js +38 -1
  221. package/dist/report.js.map +1 -1
  222. package/dist/scan-worker.js +5 -3
  223. package/dist/scan-worker.js.map +1 -1
  224. package/dist/scan.d.ts.map +1 -1
  225. package/dist/scan.js +35 -6
  226. package/dist/scan.js.map +1 -1
  227. package/dist/standards-profiles.d.ts +58 -0
  228. package/dist/standards-profiles.d.ts.map +1 -0
  229. package/dist/standards-profiles.js +100 -0
  230. package/dist/standards-profiles.js.map +1 -0
  231. package/dist/standards.d.ts +96 -0
  232. package/dist/standards.d.ts.map +1 -0
  233. package/dist/standards.js +107 -0
  234. package/dist/standards.js.map +1 -0
  235. package/dist/types.d.ts +6 -5
  236. package/dist/types.d.ts.map +1 -1
  237. package/dist/types.js.map +1 -1
  238. package/dist/version.d.ts +1 -1
  239. package/dist/version.js +1 -1
  240. package/dist/version.js.map +1 -1
  241. package/dist/vex.d.ts +39 -0
  242. package/dist/vex.d.ts.map +1 -0
  243. package/dist/vex.js +87 -0
  244. package/dist/vex.js.map +1 -0
  245. package/dist/walk.d.ts +8 -3
  246. package/dist/walk.d.ts.map +1 -1
  247. package/dist/walk.js +32 -1
  248. package/dist/walk.js.map +1 -1
  249. package/package.json +1 -1
  250. package/src/cbom-merge.ts +146 -0
  251. package/src/cbom.ts +153 -39
  252. package/src/comments.ts +84 -39
  253. package/src/dependencies.ts +2 -1
  254. package/src/detect-utils.ts +146 -12
  255. package/src/detectors/age.ts +60 -0
  256. package/src/detectors/ansible.ts +140 -0
  257. package/src/detectors/bicep.ts +107 -0
  258. package/src/detectors/c.ts +240 -6
  259. package/src/detectors/cicd.ts +171 -0
  260. package/src/detectors/cloud-kms.ts +141 -0
  261. package/src/detectors/cloudformation.ts +250 -0
  262. package/src/detectors/codesign.ts +214 -0
  263. package/src/detectors/csharp.ts +13 -3
  264. package/src/detectors/dart.ts +237 -0
  265. package/src/detectors/database.ts +141 -0
  266. package/src/detectors/dkim.ts +172 -0
  267. package/src/detectors/dnssec.ts +195 -0
  268. package/src/detectors/elixir.ts +268 -0
  269. package/src/detectors/java.ts +39 -4
  270. package/src/detectors/jose.ts +110 -0
  271. package/src/detectors/jwk.ts +170 -0
  272. package/src/detectors/k8s.ts +115 -0
  273. package/src/detectors/keystore.ts +109 -0
  274. package/src/detectors/mesh.ts +130 -0
  275. package/src/detectors/messaging.ts +106 -0
  276. package/src/detectors/objc.ts +209 -0
  277. package/src/detectors/openpgp.ts +194 -0
  278. package/src/detectors/pem.ts +31 -1
  279. package/src/detectors/php.ts +230 -0
  280. package/src/detectors/pkcs11.ts +113 -0
  281. package/src/detectors/proxy.ts +236 -0
  282. package/src/detectors/pulumi.ts +106 -0
  283. package/src/detectors/python.ts +71 -0
  284. package/src/detectors/rust.ts +76 -0
  285. package/src/detectors/secrets.ts +103 -0
  286. package/src/detectors/solidity.ts +176 -0
  287. package/src/detectors/source.ts +283 -73
  288. package/src/detectors/spire.ts +143 -0
  289. package/src/detectors/ssh-ca.ts +215 -0
  290. package/src/detectors/stateful-hbs.ts +9 -6
  291. package/src/detectors/supply-chain.ts +117 -0
  292. package/src/detectors/swift.ts +149 -0
  293. package/src/detectors/terraform.ts +188 -0
  294. package/src/detectors/vault.ts +120 -0
  295. package/src/detectors/vpn.ts +103 -0
  296. package/src/detectors/weak-hash.ts +217 -0
  297. package/src/detectors/webauthn.ts +205 -0
  298. package/src/detectors/xmldsig.ts +115 -0
  299. package/src/evidence.ts +138 -4
  300. package/src/index.ts +50 -12
  301. package/src/inventory.ts +15 -7
  302. package/src/policy.ts +180 -0
  303. package/src/registry.ts +81 -4
  304. package/src/remediate-pipeline.ts +26 -3
  305. package/src/remediation.ts +39 -0
  306. package/src/report.ts +43 -1
  307. package/src/scan-worker.ts +5 -3
  308. package/src/scan.ts +41 -6
  309. package/src/standards-profiles.ts +136 -0
  310. package/src/standards.ts +186 -0
  311. package/src/types.ts +11 -4
  312. package/src/version.ts +1 -1
  313. package/src/vex.ts +122 -0
  314. package/src/walk.ts +33 -2
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Config detector: classical asymmetric signature algorithms pinned by
3
+ * WebAuthn / FIDO2 / passkey attestation & assertion, expressed as COSE
4
+ * algorithm identifiers in relying-party code and config
5
+ * (@simplewebauthn/server, py_webauthn, go-webauthn, webauthn4j).
6
+ *
7
+ * WHY WebAuthn is PQC-relevant: a WebAuthn credential is an asymmetric key
8
+ * pair whose PUBLIC key the authenticator returns (COSE-encoded) at
9
+ * registration; every subsequent assertion is a classical signature over the
10
+ * authentication challenge, and attestation statements are classical
11
+ * signatures over the credential. These are AUTHENTICATION signatures, not
12
+ * confidentiality — there is nothing to "harvest now" — but the moment a
13
+ * cryptographically-relevant quantum computer (CRQC) exists, an attacker who
14
+ * has a user's registered public key (or an attestation CA's key) can FORGE
15
+ * assertions/attestations and impersonate the user or a genuine authenticator.
16
+ * So every finding here is `category: "signature"`, `hndl: false`.
17
+ *
18
+ * The relying party pins which algorithms it will accept: `pubKeyCredParams`
19
+ * (registration) and `supportedAlgorithmIDs` (verification) enumerate COSE
20
+ * `alg` values, and the classical ones — ES256 (COSE -7, ECDSA P-256),
21
+ * RS256 (-257, RSA), EdDSA (-8) and their P-384/P-521/RSA-2048+ siblings — are
22
+ * exactly the ones a PQC migration must inventory and replace once FIDO/COSE
23
+ * standardise post-quantum algorithm identifiers.
24
+ *
25
+ * WHY numeric COSE ids need their own detector: the existing JWT/JOSE rule
26
+ * only matches QUOTED alg strings (`"ES256"`, `"RS256"`). WebAuthn libraries
27
+ * almost never write those strings — they use the NUMERIC COSE ids
28
+ * (`alg: -7`, `supportedAlgorithmIDs: [-7, -257]`) and language-level enum
29
+ * identifiers (`COSEAlgorithmIdentifier.ES256`, `webauthncose.AlgES256`,
30
+ * `COSEAlgorithmIdentifier.EDDSA`). None of those carry the quote characters
31
+ * the JWT rule keys off, so the entire WebAuthn surface is invisible today.
32
+ *
33
+ * Two independent match shapes per family, both gated by a file-level WebAuthn
34
+ * marker (see `hasWebauthnMarker`) so the generic numeric `alg: -7` form can't
35
+ * fire on unrelated code that happens to assign a small negative number:
36
+ *
37
+ * 1. NUMERIC form — the COSE `alg` value as an integer, either as an object
38
+ * member (`alg: -7`, `alg = -257`) or inside a `supportedAlgorithmIDs`
39
+ * array (`supportedAlgorithmIDs: [-7, -257]`). Restricted to the classical
40
+ * COSE numbers only; symmetric / KDF / "direct" ids (e.g. -6, HS*) are
41
+ * never in the alternation, so they cannot match.
42
+ * 2. ENUM form — the COSE algorithm's identifier as written in each library:
43
+ * `COSEAlgorithmIdentifier.ES256|RS256|EdDSA|ECDSA_SHA_256` (webauthn4j,
44
+ * py_webauthn) and Go's `webauthncose.AlgES256` / `AlgRS256` / `AlgEdDSA`
45
+ * constants.
46
+ *
47
+ * COSE algorithm numbers → {@link AlgorithmFamily} (per the COSE registry, using
48
+ * the mapping this detector is specified against):
49
+ * - ES256 (-7), ES384 (-35), ES512 (-36) → ECDSA
50
+ * - RS256 (-257), RS384 (-258), RS512 (-259) → RSA
51
+ * - EdDSA (-8) → EdDSA
52
+ *
53
+ * Fast reject: `detect()` bails unless the file carries a distinctive WebAuthn
54
+ * API token (`pubKeyCredParams`, `PublicKeyCredential`, `webauthn`,
55
+ * `COSEAlgorithm`, `supportedAlgorithmIDs`, `navigator.credentials`). Those
56
+ * tokens are the marker gate ONLY — they never produce a standalone finding.
57
+ */
58
+ import type { Detector, Finding, RuleMeta } from "../types.js";
59
+ import {
60
+ DOC_EXTENSIONS,
61
+ eachMatch,
62
+ findingFromRule,
63
+ hasExtension,
64
+ maskBlockComments,
65
+ maskCommentLines,
66
+ } from "../detect-utils.js";
67
+ import { CWE_BROKEN_CRYPTO } from "../cwe.js";
68
+
69
+ // Classical COSE algorithm numbers, grouped by family (see module docstring).
70
+ const NUM_ECDSA = "7|35|36"; // ES256, ES384, ES512
71
+ const NUM_RSA = "257|258|259"; // RS256, RS384, RS512
72
+ const NUM_EDDSA = "8"; // EdDSA
73
+
74
+ // --- NUMERIC form: a COSE `alg` value written as an integer. ---
75
+ // (a) object member: `alg: -7`, `alg = -257` (JS/JSON, Python `alg=-7`).
76
+ // `["']?alg["']?` tolerates the JSON/serialized form `"alg": -7` (the WebAuthn
77
+ // options object is JSON-serializable and often stored/transmitted/tested as JSON
78
+ // with a quoted key), as well as the unquoted `alg: -7` / `alg = -7` (audit M2).
79
+ const RE_NUM_ECDSA = new RegExp(`["']?\\balg\\b["']?\\s*[:=]\\s*-(?:${NUM_ECDSA})\\b`, "g");
80
+ const RE_NUM_RSA = new RegExp(`["']?\\balg\\b["']?\\s*[:=]\\s*-(?:${NUM_RSA})\\b`, "g");
81
+ const RE_NUM_EDDSA = new RegExp(`["']?\\balg\\b["']?\\s*[:=]\\s*-(?:${NUM_EDDSA})\\b`, "g");
82
+ // (b) `supportedAlgorithmIDs: [-7, -257]` array (@simplewebauthn verify option).
83
+ // `[^\]]*` stays inside a single array literal; one match per family even when
84
+ // the array lists several ids of that family.
85
+ const RE_IDS_ECDSA = new RegExp(
86
+ `supportedAlgorithmIDs\\s*[:=]\\s*\\[[^\\]]*-(?:${NUM_ECDSA})\\b`,
87
+ "g",
88
+ );
89
+ const RE_IDS_RSA = new RegExp(`supportedAlgorithmIDs\\s*[:=]\\s*\\[[^\\]]*-(?:${NUM_RSA})\\b`, "g");
90
+ const RE_IDS_EDDSA = new RegExp(
91
+ `supportedAlgorithmIDs\\s*[:=]\\s*\\[[^\\]]*-(?:${NUM_EDDSA})\\b`,
92
+ "g",
93
+ );
94
+
95
+ // --- ENUM form: the COSE algorithm's language-level identifier. ---
96
+ // webauthn4j / py_webauthn: `COSEAlgorithmIdentifier.<name>`; go-webauthn:
97
+ // `webauthncose.Alg<name>` (matched bare as `Alg<name>`).
98
+ const RE_ENUM_ECDSA =
99
+ /\bCOSEAlgorithmIdentifier\.(?:ES(?:256|384|512)|ECDSA_SHA_(?:256|384|512))\b|\bAlgES(?:256|384|512)\b/g;
100
+ const RE_ENUM_RSA =
101
+ /\bCOSEAlgorithmIdentifier\.(?:RS(?:256|384|512)|RSASSA_[A-Za-z0-9_]+)\b|\bAlgRS(?:256|384|512)\b/g;
102
+ const RE_ENUM_EDDSA = /\bCOSEAlgorithmIdentifier\.(?:EdDSA|EDDSA)\b|\bAlgEdDSA\b/g;
103
+
104
+ const REMEDIATION =
105
+ "WebAuthn/FIDO2 is standardizing PQC COSE algorithms; inventory the classical attestation/assertion algs now and plan migration.";
106
+
107
+ const RULE_WEBAUTHN_ECDSA: RuleMeta = {
108
+ id: "webauthn-ecdsa",
109
+ title: "WebAuthn ECDSA COSE algorithm",
110
+ description:
111
+ "WebAuthn/FIDO2 credential pins a classical ECDSA COSE algorithm (ES256/ES384/ES512)",
112
+ category: "signature",
113
+ severity: "medium",
114
+ confidence: "high",
115
+ algorithm: "ECDSA",
116
+ hndl: false,
117
+ cwe: CWE_BROKEN_CRYPTO,
118
+ message:
119
+ "WebAuthn/FIDO2 relying party accepts a classical ECDSA COSE algorithm (ES256/ES384/ES512); attestation/assertion signatures become forgeable once a CRQC exists.",
120
+ remediation: REMEDIATION,
121
+ };
122
+ const RULE_WEBAUTHN_RSA: RuleMeta = {
123
+ id: "webauthn-rsa",
124
+ title: "WebAuthn RSA COSE algorithm",
125
+ description: "WebAuthn/FIDO2 credential pins a classical RSA COSE algorithm (RS256/RS384/RS512)",
126
+ category: "signature",
127
+ severity: "medium",
128
+ confidence: "high",
129
+ algorithm: "RSA",
130
+ hndl: false,
131
+ cwe: CWE_BROKEN_CRYPTO,
132
+ message:
133
+ "WebAuthn/FIDO2 relying party accepts a classical RSA COSE algorithm (RS256/RS384/RS512); attestation/assertion signatures become forgeable once a CRQC exists.",
134
+ remediation: REMEDIATION,
135
+ };
136
+ const RULE_WEBAUTHN_EDDSA: RuleMeta = {
137
+ id: "webauthn-eddsa",
138
+ title: "WebAuthn EdDSA COSE algorithm",
139
+ description: "WebAuthn/FIDO2 credential pins the classical EdDSA COSE algorithm (COSE -8)",
140
+ category: "signature",
141
+ severity: "medium",
142
+ confidence: "high",
143
+ algorithm: "EdDSA",
144
+ hndl: false,
145
+ cwe: CWE_BROKEN_CRYPTO,
146
+ message:
147
+ "WebAuthn/FIDO2 relying party accepts the classical EdDSA COSE algorithm (Ed25519); modern but still classical — attestation/assertion signatures become forgeable once a CRQC exists.",
148
+ remediation: REMEDIATION,
149
+ };
150
+
151
+ interface WebauthnRule {
152
+ meta: RuleMeta;
153
+ res: readonly RegExp[];
154
+ }
155
+
156
+ const WEBAUTHN_RULES: readonly WebauthnRule[] = [
157
+ { meta: RULE_WEBAUTHN_ECDSA, res: [RE_NUM_ECDSA, RE_IDS_ECDSA, RE_ENUM_ECDSA] },
158
+ { meta: RULE_WEBAUTHN_RSA, res: [RE_NUM_RSA, RE_IDS_RSA, RE_ENUM_RSA] },
159
+ { meta: RULE_WEBAUTHN_EDDSA, res: [RE_NUM_EDDSA, RE_IDS_EDDSA, RE_ENUM_EDDSA] },
160
+ ];
161
+
162
+ /**
163
+ * True when `content` carries a distinctive WebAuthn API token. Used ONLY as
164
+ * the fast-reject marker gate — none of these tokens produce a finding — so the
165
+ * generic numeric `alg: -7` form can't fire on unrelated code.
166
+ */
167
+ function hasWebauthnMarker(content: string): boolean {
168
+ return (
169
+ content.includes("pubKeyCredParams") ||
170
+ content.includes("PublicKeyCredential") ||
171
+ content.includes("COSEAlgorithm") ||
172
+ content.includes("supportedAlgorithmIDs") ||
173
+ content.includes("navigator.credentials") ||
174
+ /webauthn/i.test(content)
175
+ );
176
+ }
177
+
178
+ /** Detects classical COSE signature algorithms pinned by WebAuthn/FIDO2 relying parties. */
179
+ export const webauthnDetector: Detector = {
180
+ id: "webauthn-crypto",
181
+ description: "Classical COSE signature algorithms in WebAuthn/FIDO2/passkey relying-party code",
182
+ scope: "config",
183
+ language: "any",
184
+ rules: WEBAUTHN_RULES.map((r) => r.meta),
185
+ appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),
186
+ detect({ file, content }): Finding[] {
187
+ if (!hasWebauthnMarker(content)) return [];
188
+
189
+ // Mask C-style (`//`, `/* */`) and hash (`#`) comments so a commented-out
190
+ // options object can't fire. Offsets are preserved so finding locations stay
191
+ // exact.
192
+ const scan = maskCommentLines(maskBlockComments(content), ["//", "#"]);
193
+ const findings: Finding[] = [];
194
+ for (const { meta, res } of WEBAUTHN_RULES) {
195
+ for (const re of res) {
196
+ eachMatch(re, scan, (m) =>
197
+ findings.push(
198
+ findingFromRule(meta, { file, content, index: m.index, matchLength: m[0].length }),
199
+ ),
200
+ );
201
+ }
202
+ }
203
+ return findings;
204
+ },
205
+ };
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Config detector: classical crypto in XML Digital Signature / XML Encryption
3
+ * (W3C XML-DSig / XML-Enc), the algorithm layer under SAML SSO, WS-Security /
4
+ * SOAP, and signed XML documents. Enterprise identity is ubiquitous and its IdP
5
+ * signing keys are long-lived, so a forged SAML assertion is a prime quantum
6
+ * forgery surface; an encrypted SAML assertion (RSA key transport) is
7
+ * harvest-now-decrypt-later exposed.
8
+ *
9
+ * Detection keys off the W3C algorithm URIs, which are globally-unique constant
10
+ * strings (RFC-precise, so a lexical match is exact):
11
+ * - `…xmldsig#rsa-sha1` / `…xmldsig-more#rsa-sha256` … → RSA signature (forgeable)
12
+ * - `…xmldsig11#dsa-sha256` / `…xmldsig#dsa-sha1` → DSA signature
13
+ * - `…xmldsig-more#ecdsa-sha256` … → ECDSA signature
14
+ * - `…xmlenc#rsa-oaep(-mgf1p)` / `…xmlenc#rsa-1_5` → RSA key transport (HNDL)
15
+ *
16
+ * These URIs appear both in XML config (`.xml`) and as string constants in SAML
17
+ * library code (python3-saml, xml-crypto, OpenSAML), so the detector runs on any
18
+ * non-doc file.
19
+ */
20
+ import type { Detector, Finding, RuleMeta } from "../types.js";
21
+ import { DOC_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
22
+ import { CWE_BROKEN_CRYPTO } from "../cwe.js";
23
+
24
+ // The `#fragment` of the W3C XML-DSig / XML-Enc algorithm URIs. Anchored on the
25
+ // namespace fragment (`xmldsig…#` / `xmlenc#`) so a bare `rsa-sha256` elsewhere
26
+ // doesn't misfire.
27
+ const RE_XMLDSIG_RSA = /\bxmldsig(?:-more|11)?#rsa-sha(?:1|224|256|384|512)\b/g;
28
+ const RE_XMLDSIG_DSA = /\bxmldsig(?:11)?#dsa-sha(?:1|256)\b/g;
29
+ const RE_XMLDSIG_ECDSA = /\bxmldsig-more#ecdsa-sha(?:1|224|256|384|512)\b/g;
30
+ const RE_XMLENC_RSA = /\bxmlenc#rsa-(?:oaep(?:-mgf1p)?|1_5)\b/g;
31
+
32
+ const RULE_XMLDSIG_RSA: RuleMeta = {
33
+ id: "xmldsig-rsa-sign",
34
+ title: "XML-DSig RSA signature",
35
+ description: "XML Digital Signature with an RSA-SHA* algorithm (SAML/WS-Security)",
36
+ category: "signature",
37
+ severity: "medium",
38
+ confidence: "high",
39
+ algorithm: "RSA",
40
+ hndl: false,
41
+ cwe: CWE_BROKEN_CRYPTO,
42
+ message:
43
+ "XML signatures (SAML / WS-Security) use classical RSA (rsa-sha*); a quantum attacker could forge assertions signed with this key.",
44
+ remediation:
45
+ "Track PQC XML-DSig / SAML profiles (ML-DSA); rotate to a PQC signing key as tooling and IdPs add support.",
46
+ };
47
+ const RULE_XMLDSIG_DSA: RuleMeta = {
48
+ id: "xmldsig-dsa-sign",
49
+ title: "XML-DSig DSA signature",
50
+ description: "XML Digital Signature with a DSA-SHA* algorithm",
51
+ category: "signature",
52
+ severity: "medium",
53
+ confidence: "high",
54
+ algorithm: "DSA",
55
+ hndl: false,
56
+ cwe: CWE_BROKEN_CRYPTO,
57
+ message: "XML signatures use classical DSA (dsa-sha*) — deprecated and quantum-forgeable.",
58
+ remediation: "Migrate off DSA now; track PQC XML-DSig profiles (ML-DSA).",
59
+ };
60
+ const RULE_XMLDSIG_ECDSA: RuleMeta = {
61
+ id: "xmldsig-ecdsa-sign",
62
+ title: "XML-DSig ECDSA signature",
63
+ description: "XML Digital Signature with an ECDSA-SHA* algorithm",
64
+ category: "signature",
65
+ severity: "medium",
66
+ confidence: "high",
67
+ algorithm: "ECDSA",
68
+ hndl: false,
69
+ cwe: CWE_BROKEN_CRYPTO,
70
+ message: "XML signatures use classical ECDSA (ecdsa-sha*); forgeable by a quantum attacker.",
71
+ remediation:
72
+ "Track PQC XML-DSig / SAML profiles (ML-DSA); rotate the signing key when supported.",
73
+ };
74
+ const RULE_XMLENC_RSA: RuleMeta = {
75
+ id: "xmlenc-rsa-keytransport",
76
+ title: "XML-Enc RSA key transport",
77
+ description: "XML Encryption with RSA-OAEP / RSA-1_5 key transport (encrypted SAML assertions)",
78
+ category: "kem",
79
+ severity: "high",
80
+ confidence: "high",
81
+ algorithm: "RSA",
82
+ hndl: true,
83
+ cwe: CWE_BROKEN_CRYPTO,
84
+ message:
85
+ "XML Encryption wraps the content key with classical RSA (rsa-oaep / rsa-1_5); encrypted XML (e.g. SAML assertions) is harvest-now-decrypt-later exposed.",
86
+ remediation:
87
+ "Plan migration to a post-quantum KEM (ML-KEM-768) for key transport as XML-Enc / SAML PQC profiles mature.",
88
+ };
89
+
90
+ /** Detects classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML). */
91
+ export const xmldsigDetector: Detector = {
92
+ id: "xmldsig-crypto",
93
+ description: "Classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML)",
94
+ scope: "config",
95
+ language: "any",
96
+ // Skip prose/docs: a page explaining the SAML algorithm URIs is not live config.
97
+ appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),
98
+ rules: [RULE_XMLDSIG_RSA, RULE_XMLDSIG_DSA, RULE_XMLDSIG_ECDSA, RULE_XMLENC_RSA],
99
+ detect({ file, content }): Finding[] {
100
+ // Fast reject: only proceed if an XML-DSig / XML-Enc namespace fragment is present.
101
+ if (!content.includes("xmldsig") && !content.includes("xmlenc")) return [];
102
+ const findings: Finding[] = [];
103
+ const add = (re: RegExp, rule: RuleMeta): void =>
104
+ eachMatch(re, content, (m) =>
105
+ findings.push(
106
+ findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length }),
107
+ ),
108
+ );
109
+ add(RE_XMLDSIG_RSA, RULE_XMLDSIG_RSA);
110
+ add(RE_XMLDSIG_DSA, RULE_XMLDSIG_DSA);
111
+ add(RE_XMLDSIG_ECDSA, RULE_XMLDSIG_ECDSA);
112
+ add(RE_XMLENC_RSA, RULE_XMLENC_RSA);
113
+ return findings;
114
+ },
115
+ };
package/src/evidence.ts CHANGED
@@ -21,6 +21,8 @@ import { createHash } from "node:crypto";
21
21
  import type { ScanResult } from "./types.js";
22
22
  import { toCbom } from "./cbom.js";
23
23
  import { VERSION } from "./version.js";
24
+ import { buildPolicyMapping } from "./policy.js";
25
+ import type { CryptoPolicy, PolicyMapping } from "./policy.js";
24
26
 
25
27
  /** Stable per-finding record for the evidence body (deterministic per commit). */
26
28
  export interface EvidenceFinding {
@@ -44,14 +46,27 @@ export interface ReadinessReport {
44
46
  tool: { name: "qScan"; version: string };
45
47
  inventory: ScanResult["inventory"];
46
48
  findings: EvidenceFinding[];
49
+ /** §4 policy verdicts, present only when a crypto policy was supplied. */
50
+ policyMapping?: PolicyMapping;
47
51
  cbom: unknown;
48
52
  attestation: {
49
53
  /** sha256 over the canonicalized deterministic body (excludes scanTimeUtc). */
50
54
  contentHash: string;
51
- /** RFC-3161 / transparency-log token — filled by an external signer. */
52
- timestamp: null;
53
- /** Detached signature over `contentHash` filled by an external signer. */
54
- signature: null;
55
+ /**
56
+ * RFC-3161 / transparency-log token over `contentHash`, produced by an EXTERNAL
57
+ * timestamper (opaque string, e.g. base64). `null` until {@link signReadinessReport}
58
+ * runs one.
59
+ */
60
+ timestamp: string | null;
61
+ /**
62
+ * Detached signature over `contentHash`, produced by an EXTERNAL signer (opaque
63
+ * string, e.g. base64/PEM). `null` until {@link signReadinessReport} runs one.
64
+ */
65
+ signature: string | null;
66
+ /** Non-sensitive provenance label of the signer (e.g. "openssl", "cosign"). */
67
+ signedWith?: string;
68
+ /** Non-sensitive provenance label of the timestamper (e.g. "openssl-ts"). */
69
+ timestampedWith?: string;
55
70
  };
56
71
  }
57
72
 
@@ -73,6 +88,8 @@ export interface ReadinessReportOptions {
73
88
  repository?: string;
74
89
  /** Full commit SHA (e.g. from `GITHUB_SHA`); omitted → null. */
75
90
  commit?: string;
91
+ /** Optional org cryptography policy — adds the §4 `policyMapping` verdicts. */
92
+ policy?: CryptoPolicy;
76
93
  }
77
94
 
78
95
  /**
@@ -97,6 +114,10 @@ export function buildReadinessReport(
97
114
  // its CycloneDX envelope carries a volatile timestamp/serial — so it is
98
115
  // EXCLUDED from the hashed body (its integrity follows from its hashed inputs)
99
116
  // to keep the content hash reproducible across scan runs on the same commit.
117
+ // §4: if the org supplied a crypto policy, attest the per-finding verdicts too.
118
+ // Deterministic (same findings + policy → same mapping), so it is hashed.
119
+ const policyMapping = opts.policy ? buildPolicyMapping(result.findings, opts.policy) : undefined;
120
+
100
121
  const hashableBody = {
101
122
  reportType: "quantakrypto-readiness",
102
123
  specVersion: 1,
@@ -108,6 +129,7 @@ export function buildReadinessReport(
108
129
  tool: { name: "qScan", version: VERSION },
109
130
  inventory: result.inventory,
110
131
  findings,
132
+ ...(policyMapping ? { policyMapping } : {}),
111
133
  };
112
134
  const contentHash =
113
135
  "sha256:" +
@@ -122,3 +144,115 @@ export function buildReadinessReport(
122
144
  attestation: { contentHash, timestamp: null, signature: null },
123
145
  } as ReadinessReport;
124
146
  }
147
+
148
+ /** The result of {@link verifyReadinessReport}. */
149
+ export interface VerifyReadinessResult {
150
+ /** True iff the recomputed body hash equals the hash claimed in the attestation. */
151
+ valid: boolean;
152
+ /** The hash recomputed over the report's CURRENT body. */
153
+ computedHash: string;
154
+ /** The hash claimed in the report's attestation (`attestation.contentHash`). */
155
+ claimedHash: string;
156
+ /** A short human reason; present only when `valid` is false. */
157
+ reason?: string;
158
+ }
159
+
160
+ /**
161
+ * Recompute the deterministic content hash over a readiness report's body and
162
+ * compare it to the hash the attestation claims. Detects tampering with ANY
163
+ * hashed field — a finding, the inventory, a policy verdict, or subject/tool
164
+ * metadata: editing it after the fact changes the recomputed hash, so `valid`
165
+ * becomes false.
166
+ *
167
+ * By construction the scan timestamp, the CBOM envelope, and the attestation
168
+ * block itself are EXCLUDED from the hash (see {@link buildReadinessReport}), so
169
+ * touching those does not fail verification — their integrity follows from their
170
+ * hashed inputs. The body is reconstructed from the report's OWN stored fields
171
+ * (including `tool.version`), so a report built by an older qScan still verifies.
172
+ *
173
+ * This checks the INTEGRITY hash only. It does NOT validate the detached
174
+ * signature or RFC-3161 timestamp: those are opaque tokens from an external
175
+ * signer (ADR-0004) and are verified with that signer's own tooling.
176
+ */
177
+ export function verifyReadinessReport(report: ReadinessReport): VerifyReadinessResult {
178
+ const hashableBody = {
179
+ reportType: report.reportType,
180
+ specVersion: report.specVersion,
181
+ subject: {
182
+ repository: report.subject.repository,
183
+ commit: report.subject.commit,
184
+ scannedRoot: report.subject.scannedRoot,
185
+ },
186
+ tool: { name: report.tool.name, version: report.tool.version },
187
+ inventory: report.inventory,
188
+ findings: report.findings,
189
+ ...(report.policyMapping ? { policyMapping: report.policyMapping } : {}),
190
+ };
191
+ const computedHash =
192
+ "sha256:" +
193
+ createHash("sha256")
194
+ .update(JSON.stringify(canonicalize(hashableBody)))
195
+ .digest("hex");
196
+ const claimedHash = report.attestation.contentHash;
197
+ if (computedHash === claimedHash) {
198
+ return { valid: true, computedHash, claimedHash };
199
+ }
200
+ return {
201
+ valid: false,
202
+ computedHash,
203
+ claimedHash,
204
+ reason: "content-hash mismatch: the report body was modified after it was built",
205
+ };
206
+ }
207
+
208
+ /**
209
+ * An EXTERNAL signer/timestamper the tool orchestrates. Per ADR-0004 the tool
210
+ * implements no cryptography: it hands the payload to an operator-provided signer
211
+ * (an `openssl`/`cosign` invocation, an RFC-3161 TSA client, …) and records what
212
+ * comes back. `label` is a short, non-sensitive provenance string (e.g. the signer
213
+ * program name) — NOT the full command, which may contain a key path.
214
+ */
215
+ export interface EvidenceSigner {
216
+ label: string;
217
+ /**
218
+ * Produce a detached signature / timestamp token (opaque string) over `payload`.
219
+ * May be async so a future signer can shell out OR call a KMS / RFC-3161 TSA over
220
+ * the network without foreclosing that once this contract freezes at 1.0.
221
+ */
222
+ sign(payload: string): string | Promise<string>;
223
+ }
224
+
225
+ /** Options for {@link signReadinessReport}: a detached-signature and/or a timestamp signer. */
226
+ export interface SignEvidenceOptions {
227
+ signer?: EvidenceSigner;
228
+ timestamper?: EvidenceSigner;
229
+ }
230
+
231
+ /**
232
+ * Fill a readiness report's attestation with a detached signature and/or RFC-3161
233
+ * timestamp, produced by EXTERNAL signers over the report's `contentHash`. Pure
234
+ * orchestration: it invokes the injected signers and records their opaque output
235
+ * plus a provenance label — it performs no cryptography itself (ADR-0004). Returns a
236
+ * NEW report; the hashed body is untouched (attestation is excluded from the hash),
237
+ * so signing never changes `contentHash`.
238
+ */
239
+ export async function signReadinessReport(
240
+ report: ReadinessReport,
241
+ opts: SignEvidenceOptions,
242
+ ): Promise<ReadinessReport> {
243
+ const payload = report.attestation.contentHash;
244
+ const signature = opts.signer ? await opts.signer.sign(payload) : report.attestation.signature;
245
+ const timestamp = opts.timestamper
246
+ ? await opts.timestamper.sign(payload)
247
+ : report.attestation.timestamp;
248
+ return {
249
+ ...report,
250
+ attestation: {
251
+ ...report.attestation,
252
+ signature,
253
+ timestamp,
254
+ ...(opts.signer ? { signedWith: opts.signer.label } : {}),
255
+ ...(opts.timestamper ? { timestampedWith: opts.timestamper.label } : {}),
256
+ },
257
+ };
258
+ }
package/src/index.ts CHANGED
@@ -56,13 +56,14 @@ export type {
56
56
  // Scan cancellation / work-budget errors.
57
57
  export { AbortError, BudgetExceededError } from "./errors.js";
58
58
 
59
- // Parallel scanning (worker_threads pool) + pure merge/chunk helpers.
60
- export { scanParallel, mergeChunkResults, chunkByBytes } from "./parallel.js";
61
- export type { ScanChunk, ChunkResult, SizedFile } from "./parallel.js";
59
+ // Parallel scanning (worker_threads pool). The chunk/merge helpers and their
60
+ // SizedFile/ChunkResult types are internal plumbing (not part of the public API).
61
+ export { scanParallel } from "./parallel.js";
62
+ export type { ScanChunk } from "./parallel.js";
62
63
 
63
- // Detector registry (plugin point) + helpers + the rule catalog.
64
- export { DetectorRegistry, defaultRegistry, detectorScope } from "./registry.js";
65
- export type { RuleCatalogEntry } from "./registry.js";
64
+ // Detector registry (plugin point). `detectorScope` and the rule-catalog type are
65
+ // internal.
66
+ export { DetectorRegistry, defaultRegistry } from "./registry.js";
66
67
 
67
68
  // Canonical baseline (shared by qScan + the Action).
68
69
  export {
@@ -83,7 +84,7 @@ export { loadConfig, ConfigError, CONFIG_FILENAME } from "./config.js";
83
84
  export type { QuantakryptoFileConfig, LoadConfigResult } from "./config.js";
84
85
 
85
86
  // Filesystem walker (relative POSIX paths, default ignores, size/binary filters).
86
- export { walkFiles, isBinaryPath, isGeneratedPath, looksMinified } from "./walk.js";
87
+ export { walkFiles, isBinaryPath, looksMinified } from "./walk.js";
87
88
 
88
89
  // Analyzable-language coverage (which source languages the scanner inspects).
89
90
  export {
@@ -104,20 +105,43 @@ export { vulnerableDependencies, DEP_VULNERABLE_RULE, isManifestFile } from "./d
104
105
  export { SEVERITY_ORDER, severityRank, meetsThreshold, sarifLevel } from "./severity.js";
105
106
 
106
107
  // Reporters.
107
- export { toSarif, toJson, formatSummary, formatTierGuidance } from "./report.js";
108
+ export {
109
+ toSarif,
110
+ toJson,
111
+ formatSummary,
112
+ formatTierGuidance,
113
+ formatProfileGuidance,
114
+ } from "./report.js";
108
115
  export type { ReportOptions } from "./report.js";
109
116
 
110
117
  // CycloneDX 1.6 cryptographic bill of materials (CBOM) export.
111
118
  export { toCbom } from "./cbom.js";
112
119
  export type { CycloneDxBom, CbomComponent } from "./cbom.js";
120
+ // Merge multiple CBOMs (code + infra + live endpoints) into one combined BOM.
121
+ export { mergeCboms } from "./cbom-merge.js";
122
+ // OpenVEX 0.2.0 export — quantum-readiness posture as VEX statements.
123
+ export { toOpenVex } from "./vex.js";
124
+ export type { OpenVexDocument, OpenVexStatement, OpenVexOptions } from "./vex.js";
113
125
  // ISO/IEC 27001 A.8.24 evidence-chain readiness report.
114
- export { buildReadinessReport } from "./evidence.js";
115
- export type { ReadinessReport, EvidenceFinding, ReadinessReportOptions } from "./evidence.js";
116
-
117
- // Remediation lookup (family + tier-aware) and stateful-HBS guidance.
126
+ export { buildReadinessReport, signReadinessReport, verifyReadinessReport } from "./evidence.js";
127
+ export type {
128
+ ReadinessReport,
129
+ EvidenceFinding,
130
+ ReadinessReportOptions,
131
+ EvidenceSigner,
132
+ SignEvidenceOptions,
133
+ VerifyReadinessResult,
134
+ } from "./evidence.js";
135
+
136
+ // Cryptography policy → per-finding verdicts (A.8.24 evidence §4).
137
+ export { buildPolicyMapping, parseCryptoPolicy } from "./policy.js";
138
+ export type { CryptoPolicy, PolicyVerdict, PolicyMapping, PolicyFindingVerdict } from "./policy.js";
139
+
140
+ // Remediation lookup (family + tier-aware + profile-aware) and stateful-HBS guidance.
118
141
  export {
119
142
  remediationFor,
120
143
  remediationForTier,
144
+ remediationForProfile,
121
145
  TIER_PARAMS,
122
146
  STATEFUL_HBS_NOTE,
123
147
  PQC_TRANSITION_NOTE,
@@ -125,6 +149,20 @@ export {
125
149
  } from "./remediation.js";
126
150
  export type { SecurityTier } from "./remediation.js";
127
151
 
152
+ // Post-quantum standards source of truth + review cadence.
153
+ export { PQC_STANDARDS } from "./standards.js";
154
+ export type { PqcStandards, StandardsCitation, StandardsReviewStatus } from "./standards.js";
155
+
156
+ // Selectable standards regime profiles (NIST / CNSA / BSI / ANSSI / NCSC).
157
+ export {
158
+ STANDARDS_PROFILES,
159
+ DEFAULT_PROFILE_ID,
160
+ standardsProfileIds,
161
+ getStandardsProfile,
162
+ defaultStandardsProfile,
163
+ } from "./standards-profiles.js";
164
+ export type { StandardsProfile, HybridStance } from "./standards-profiles.js";
165
+
128
166
  // CWE identifier constants.
129
167
  export {
130
168
  CWE_BROKEN_CRYPTO,
package/src/inventory.ts CHANGED
@@ -48,7 +48,7 @@ const SCORE_SCALE = 100;
48
48
  const TEST_PATH_WEIGHT = 0.15;
49
49
 
50
50
  /** True when a finding's file path is test / fixture / example / documentation. */
51
- export function isTestOrFixturePath(file: string): boolean {
51
+ function isTestOrFixturePath(file: string): boolean {
52
52
  const f = file.toLowerCase().replace(/\\/g, "/");
53
53
  if (
54
54
  /(?:^|\/)(?:tests?|__tests__|testdata|test-data|fixtures?|examples?|demos?|samples?|specs?|mocks?|docs?|benchmarks?|e2e)\//.test(
@@ -75,20 +75,28 @@ export function isTestOrFixturePath(file: string): boolean {
75
75
  export function readinessScore(findings: Finding[]): number {
76
76
  if (findings.length === 0) return 100;
77
77
 
78
- const seen: Record<Severity, number> = {
78
+ // Diminishing-returns occurrence counters, kept SEPARATE for full-weight vs
79
+ // test-path findings. Sharing one counter per severity let whichever finding came
80
+ // first in the (path-sorted) list claim the `1/√1` slot, so a directory rename — or
81
+ // a test finding sorting ahead of a real one — changed the score. Bucketing makes
82
+ // the penalty independent of file order and of test/real interleaving.
83
+ const zero = (): Record<Severity, number> => ({
79
84
  critical: 0,
80
85
  high: 0,
81
86
  medium: 0,
82
87
  low: 0,
83
88
  info: 0,
84
- };
89
+ });
90
+ const seenReal = zero();
91
+ const seenTest = zero();
85
92
 
86
93
  let penalty = 0;
87
94
  for (const f of findings) {
88
- seen[f.severity] += 1;
89
- const weight =
90
- SEVERITY_WEIGHT[f.severity] * (isTestOrFixturePath(f.location.file) ? TEST_PATH_WEIGHT : 1);
91
- penalty += penaltyFor(weight, seen[f.severity]);
95
+ const isTest = isTestOrFixturePath(f.location.file);
96
+ const bucket = isTest ? seenTest : seenReal;
97
+ bucket[f.severity] += 1;
98
+ const weight = SEVERITY_WEIGHT[f.severity] * (isTest ? TEST_PATH_WEIGHT : 1);
99
+ penalty += penaltyFor(weight, bucket[f.severity]);
92
100
  }
93
101
 
94
102
  return Math.max(0, Math.min(100, Math.round(100 * Math.exp(-penalty / SCORE_SCALE))));