@quantakrypto/core 0.4.4 → 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 (284) hide show
  1. package/README.md +76 -27
  2. package/dist/cbom-merge.d.ts.map +1 -1
  3. package/dist/cbom-merge.js +30 -8
  4. package/dist/cbom-merge.js.map +1 -1
  5. package/dist/cbom.d.ts +5 -0
  6. package/dist/cbom.d.ts.map +1 -1
  7. package/dist/cbom.js +132 -37
  8. package/dist/cbom.js.map +1 -1
  9. package/dist/comments.d.ts +2 -23
  10. package/dist/comments.d.ts.map +1 -1
  11. package/dist/comments.js +24 -5
  12. package/dist/comments.js.map +1 -1
  13. package/dist/detect-utils.d.ts +55 -21
  14. package/dist/detect-utils.d.ts.map +1 -1
  15. package/dist/detect-utils.js +133 -7
  16. package/dist/detect-utils.js.map +1 -1
  17. package/dist/detectors/age.d.ts +16 -0
  18. package/dist/detectors/age.d.ts.map +1 -0
  19. package/dist/detectors/age.js +40 -0
  20. package/dist/detectors/age.js.map +1 -0
  21. package/dist/detectors/ansible.d.ts +13 -0
  22. package/dist/detectors/ansible.d.ts.map +1 -0
  23. package/dist/detectors/ansible.js +108 -0
  24. package/dist/detectors/ansible.js.map +1 -0
  25. package/dist/detectors/bicep.d.ts +20 -0
  26. package/dist/detectors/bicep.d.ts.map +1 -0
  27. package/dist/detectors/bicep.js +74 -0
  28. package/dist/detectors/bicep.js.map +1 -0
  29. package/dist/detectors/c.d.ts.map +1 -1
  30. package/dist/detectors/c.js +30 -3
  31. package/dist/detectors/c.js.map +1 -1
  32. package/dist/detectors/cicd.d.ts.map +1 -1
  33. package/dist/detectors/cicd.js +18 -5
  34. package/dist/detectors/cicd.js.map +1 -1
  35. package/dist/detectors/cloud-kms.d.ts +8 -5
  36. package/dist/detectors/cloud-kms.d.ts.map +1 -1
  37. package/dist/detectors/cloud-kms.js +62 -20
  38. package/dist/detectors/cloud-kms.js.map +1 -1
  39. package/dist/detectors/cloudformation.d.ts +8 -0
  40. package/dist/detectors/cloudformation.d.ts.map +1 -1
  41. package/dist/detectors/cloudformation.js +41 -10
  42. package/dist/detectors/cloudformation.js.map +1 -1
  43. package/dist/detectors/codesign.d.ts +50 -0
  44. package/dist/detectors/codesign.d.ts.map +1 -0
  45. package/dist/detectors/codesign.js +143 -0
  46. package/dist/detectors/codesign.js.map +1 -0
  47. package/dist/detectors/csharp.d.ts.map +1 -1
  48. package/dist/detectors/csharp.js +13 -3
  49. package/dist/detectors/csharp.js.map +1 -1
  50. package/dist/detectors/dart.d.ts +35 -0
  51. package/dist/detectors/dart.d.ts.map +1 -0
  52. package/dist/detectors/dart.js +177 -0
  53. package/dist/detectors/dart.js.map +1 -0
  54. package/dist/detectors/database.d.ts +5 -3
  55. package/dist/detectors/database.d.ts.map +1 -1
  56. package/dist/detectors/database.js +45 -8
  57. package/dist/detectors/database.js.map +1 -1
  58. package/dist/detectors/dkim.d.ts +54 -0
  59. package/dist/detectors/dkim.d.ts.map +1 -0
  60. package/dist/detectors/dkim.js +92 -0
  61. package/dist/detectors/dkim.js.map +1 -0
  62. package/dist/detectors/dnssec.d.ts.map +1 -1
  63. package/dist/detectors/dnssec.js +19 -10
  64. package/dist/detectors/dnssec.js.map +1 -1
  65. package/dist/detectors/elixir.d.ts.map +1 -1
  66. package/dist/detectors/elixir.js +34 -2
  67. package/dist/detectors/elixir.js.map +1 -1
  68. package/dist/detectors/java.d.ts.map +1 -1
  69. package/dist/detectors/java.js +33 -3
  70. package/dist/detectors/java.js.map +1 -1
  71. package/dist/detectors/jose.d.ts.map +1 -1
  72. package/dist/detectors/jose.js +13 -3
  73. package/dist/detectors/jose.js.map +1 -1
  74. package/dist/detectors/jwk.d.ts +7 -7
  75. package/dist/detectors/jwk.d.ts.map +1 -1
  76. package/dist/detectors/jwk.js +44 -8
  77. package/dist/detectors/jwk.js.map +1 -1
  78. package/dist/detectors/k8s.d.ts.map +1 -1
  79. package/dist/detectors/k8s.js +5 -2
  80. package/dist/detectors/k8s.js.map +1 -1
  81. package/dist/detectors/keystore.d.ts +19 -0
  82. package/dist/detectors/keystore.d.ts.map +1 -0
  83. package/dist/detectors/keystore.js +76 -0
  84. package/dist/detectors/keystore.js.map +1 -0
  85. package/dist/detectors/mesh.d.ts +7 -8
  86. package/dist/detectors/mesh.d.ts.map +1 -1
  87. package/dist/detectors/mesh.js +17 -35
  88. package/dist/detectors/mesh.js.map +1 -1
  89. package/dist/detectors/messaging.d.ts +2 -2
  90. package/dist/detectors/messaging.d.ts.map +1 -1
  91. package/dist/detectors/messaging.js +19 -12
  92. package/dist/detectors/messaging.js.map +1 -1
  93. package/dist/detectors/objc.d.ts +41 -0
  94. package/dist/detectors/objc.d.ts.map +1 -0
  95. package/dist/detectors/objc.js +146 -0
  96. package/dist/detectors/objc.js.map +1 -0
  97. package/dist/detectors/openpgp.d.ts +20 -0
  98. package/dist/detectors/openpgp.d.ts.map +1 -0
  99. package/dist/detectors/openpgp.js +151 -0
  100. package/dist/detectors/openpgp.js.map +1 -0
  101. package/dist/detectors/pem.d.ts.map +1 -1
  102. package/dist/detectors/pem.js +32 -0
  103. package/dist/detectors/pem.js.map +1 -1
  104. package/dist/detectors/php.d.ts +2 -1
  105. package/dist/detectors/php.d.ts.map +1 -1
  106. package/dist/detectors/php.js +7 -3
  107. package/dist/detectors/php.js.map +1 -1
  108. package/dist/detectors/pkcs11.d.ts +17 -0
  109. package/dist/detectors/pkcs11.d.ts.map +1 -0
  110. package/dist/detectors/pkcs11.js +87 -0
  111. package/dist/detectors/pkcs11.js.map +1 -0
  112. package/dist/detectors/proxy.d.ts +52 -0
  113. package/dist/detectors/proxy.d.ts.map +1 -0
  114. package/dist/detectors/proxy.js +157 -0
  115. package/dist/detectors/proxy.js.map +1 -0
  116. package/dist/detectors/pulumi.d.ts +19 -0
  117. package/dist/detectors/pulumi.d.ts.map +1 -0
  118. package/dist/detectors/pulumi.js +80 -0
  119. package/dist/detectors/pulumi.js.map +1 -0
  120. package/dist/detectors/rust.d.ts.map +1 -1
  121. package/dist/detectors/rust.js +5 -0
  122. package/dist/detectors/rust.js.map +1 -1
  123. package/dist/detectors/secrets.d.ts +4 -1
  124. package/dist/detectors/secrets.d.ts.map +1 -1
  125. package/dist/detectors/secrets.js +5 -21
  126. package/dist/detectors/secrets.js.map +1 -1
  127. package/dist/detectors/solidity.d.ts +50 -0
  128. package/dist/detectors/solidity.d.ts.map +1 -0
  129. package/dist/detectors/solidity.js +108 -0
  130. package/dist/detectors/solidity.js.map +1 -0
  131. package/dist/detectors/source.d.ts.map +1 -1
  132. package/dist/detectors/source.js +53 -6
  133. package/dist/detectors/source.js.map +1 -1
  134. package/dist/detectors/spire.d.ts +49 -0
  135. package/dist/detectors/spire.d.ts.map +1 -0
  136. package/dist/detectors/spire.js +77 -0
  137. package/dist/detectors/spire.js.map +1 -0
  138. package/dist/detectors/ssh-ca.d.ts +72 -0
  139. package/dist/detectors/ssh-ca.d.ts.map +1 -0
  140. package/dist/detectors/ssh-ca.js +119 -0
  141. package/dist/detectors/ssh-ca.js.map +1 -0
  142. package/dist/detectors/supply-chain.d.ts +17 -0
  143. package/dist/detectors/supply-chain.d.ts.map +1 -0
  144. package/dist/detectors/supply-chain.js +89 -0
  145. package/dist/detectors/supply-chain.js.map +1 -0
  146. package/dist/detectors/swift.d.ts +22 -0
  147. package/dist/detectors/swift.d.ts.map +1 -0
  148. package/dist/detectors/swift.js +120 -0
  149. package/dist/detectors/swift.js.map +1 -0
  150. package/dist/detectors/terraform.d.ts.map +1 -1
  151. package/dist/detectors/terraform.js +35 -8
  152. package/dist/detectors/terraform.js.map +1 -1
  153. package/dist/detectors/vault.d.ts +15 -0
  154. package/dist/detectors/vault.d.ts.map +1 -0
  155. package/dist/detectors/vault.js +97 -0
  156. package/dist/detectors/vault.js.map +1 -0
  157. package/dist/detectors/vpn.d.ts +8 -8
  158. package/dist/detectors/vpn.d.ts.map +1 -1
  159. package/dist/detectors/vpn.js +12 -38
  160. package/dist/detectors/vpn.js.map +1 -1
  161. package/dist/detectors/weak-hash.d.ts +71 -0
  162. package/dist/detectors/weak-hash.d.ts.map +1 -0
  163. package/dist/detectors/weak-hash.js +116 -0
  164. package/dist/detectors/weak-hash.js.map +1 -0
  165. package/dist/detectors/webauthn.d.ts +61 -0
  166. package/dist/detectors/webauthn.d.ts.map +1 -0
  167. package/dist/detectors/webauthn.js +109 -0
  168. package/dist/detectors/webauthn.js.map +1 -0
  169. package/dist/detectors/xmldsig.d.ts +23 -0
  170. package/dist/detectors/xmldsig.d.ts.map +1 -0
  171. package/dist/detectors/xmldsig.js +84 -0
  172. package/dist/detectors/xmldsig.js.map +1 -0
  173. package/dist/evidence.d.ts +74 -4
  174. package/dist/evidence.d.ts.map +1 -1
  175. package/dist/evidence.js +71 -0
  176. package/dist/evidence.js.map +1 -1
  177. package/dist/index.d.ts +14 -11
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +17 -11
  180. package/dist/index.js.map +1 -1
  181. package/dist/inventory.d.ts +0 -2
  182. package/dist/inventory.d.ts.map +1 -1
  183. package/dist/inventory.js +15 -6
  184. package/dist/inventory.js.map +1 -1
  185. package/dist/registry.d.ts +9 -4
  186. package/dist/registry.d.ts.map +1 -1
  187. package/dist/registry.js +51 -4
  188. package/dist/registry.js.map +1 -1
  189. package/dist/remediate-pipeline.d.ts +0 -3
  190. package/dist/remediate-pipeline.d.ts.map +1 -1
  191. package/dist/remediate-pipeline.js +1 -1
  192. package/dist/remediate-pipeline.js.map +1 -1
  193. package/dist/remediation.d.ts +10 -0
  194. package/dist/remediation.d.ts.map +1 -1
  195. package/dist/remediation.js +32 -0
  196. package/dist/remediation.js.map +1 -1
  197. package/dist/report.d.ts +9 -0
  198. package/dist/report.d.ts.map +1 -1
  199. package/dist/report.js +31 -1
  200. package/dist/report.js.map +1 -1
  201. package/dist/scan-worker.js +5 -3
  202. package/dist/scan-worker.js.map +1 -1
  203. package/dist/scan.d.ts.map +1 -1
  204. package/dist/scan.js +35 -6
  205. package/dist/scan.js.map +1 -1
  206. package/dist/standards-profiles.d.ts +58 -0
  207. package/dist/standards-profiles.d.ts.map +1 -0
  208. package/dist/standards-profiles.js +100 -0
  209. package/dist/standards-profiles.js.map +1 -0
  210. package/dist/types.d.ts +6 -5
  211. package/dist/types.d.ts.map +1 -1
  212. package/dist/types.js.map +1 -1
  213. package/dist/version.d.ts +1 -1
  214. package/dist/version.js +1 -1
  215. package/dist/version.js.map +1 -1
  216. package/dist/vex.d.ts +39 -0
  217. package/dist/vex.d.ts.map +1 -0
  218. package/dist/vex.js +87 -0
  219. package/dist/vex.js.map +1 -0
  220. package/dist/walk.d.ts +8 -3
  221. package/dist/walk.d.ts.map +1 -1
  222. package/dist/walk.js +32 -1
  223. package/dist/walk.js.map +1 -1
  224. package/package.json +1 -1
  225. package/src/cbom-merge.ts +38 -8
  226. package/src/cbom.ts +153 -39
  227. package/src/comments.ts +25 -6
  228. package/src/detect-utils.ts +133 -11
  229. package/src/detectors/age.ts +60 -0
  230. package/src/detectors/ansible.ts +140 -0
  231. package/src/detectors/bicep.ts +107 -0
  232. package/src/detectors/c.ts +31 -3
  233. package/src/detectors/cicd.ts +18 -5
  234. package/src/detectors/cloud-kms.ts +79 -25
  235. package/src/detectors/cloudformation.ts +45 -10
  236. package/src/detectors/codesign.ts +214 -0
  237. package/src/detectors/csharp.ts +13 -3
  238. package/src/detectors/dart.ts +237 -0
  239. package/src/detectors/database.ts +64 -11
  240. package/src/detectors/dkim.ts +172 -0
  241. package/src/detectors/dnssec.ts +19 -10
  242. package/src/detectors/elixir.ts +33 -2
  243. package/src/detectors/java.ts +37 -3
  244. package/src/detectors/jose.ts +19 -3
  245. package/src/detectors/jwk.ts +59 -17
  246. package/src/detectors/k8s.ts +5 -2
  247. package/src/detectors/keystore.ts +109 -0
  248. package/src/detectors/mesh.ts +21 -45
  249. package/src/detectors/messaging.ts +22 -14
  250. package/src/detectors/objc.ts +209 -0
  251. package/src/detectors/openpgp.ts +194 -0
  252. package/src/detectors/pem.ts +30 -0
  253. package/src/detectors/php.ts +9 -4
  254. package/src/detectors/pkcs11.ts +113 -0
  255. package/src/detectors/proxy.ts +236 -0
  256. package/src/detectors/pulumi.ts +106 -0
  257. package/src/detectors/rust.ts +5 -0
  258. package/src/detectors/secrets.ts +15 -26
  259. package/src/detectors/solidity.ts +176 -0
  260. package/src/detectors/source.ts +48 -5
  261. package/src/detectors/spire.ts +143 -0
  262. package/src/detectors/ssh-ca.ts +215 -0
  263. package/src/detectors/supply-chain.ts +117 -0
  264. package/src/detectors/swift.ts +149 -0
  265. package/src/detectors/terraform.ts +42 -8
  266. package/src/detectors/vault.ts +120 -0
  267. package/src/detectors/vpn.ts +20 -48
  268. package/src/detectors/weak-hash.ts +217 -0
  269. package/src/detectors/webauthn.ts +205 -0
  270. package/src/detectors/xmldsig.ts +115 -0
  271. package/src/evidence.ts +127 -4
  272. package/src/index.ts +41 -13
  273. package/src/inventory.ts +15 -7
  274. package/src/registry.ts +51 -4
  275. package/src/remediate-pipeline.ts +1 -1
  276. package/src/remediation.ts +39 -0
  277. package/src/report.ts +36 -1
  278. package/src/scan-worker.ts +5 -3
  279. package/src/scan.ts +41 -6
  280. package/src/standards-profiles.ts +136 -0
  281. package/src/types.ts +9 -4
  282. package/src/version.ts +1 -1
  283. package/src/vex.ts +122 -0
  284. package/src/walk.ts +33 -2
@@ -1 +1 @@
1
- {"version":3,"file":"remediation.js","sourceRoot":"","sources":["../src/remediation.ts"],"names":[],"mappings":"AASA,8DAA8D;AAC9D,MAAM,YAAY,GAAyC;IACzD,GAAG,EAAE;QACH,SAAS,EAAE,KAAK;QAChB,cAAc,EAAE,yDAAyD;QACzE,MAAM,EACJ,4EAA4E;YAC5E,2EAA2E;YAC3E,gEAAgE;KACnE;IACD,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM;QACjB,cAAc,EAAE,oCAAoC;QACpD,MAAM,EACJ,6EAA6E;YAC7E,gFAAgF;YAChF,2DAA2D;KAC9D;IACD,KAAK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CAAC,CAAC,EAAE,CAAC;QACP,OAAO;YACL,SAAS;YACT,cAAc,EAAE,GAAG,OAAO,4DAA4D;YACtF,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,iDAAiD,MAAM,CAAC,GAAG,cAAc,MAAM,CAAC,SAAS,iBAAiB,UAAU,EAAE;SAC5J,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS;QACT,cAAc,EAAE,GAAG,IAAI,CAAC,cAAc,MAAM,IAAI,KAAK,OAAO,EAAE;QAC9D,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,sBAAsB,MAAM,CAAC,GAAG,cAAc,MAAM,CAAC,SAAS,gBAAgB;KACpH,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,yEAAyE;IACzE,2EAA2E;IAC3E,2EAA2E;IAC3E,6EAA6E;IAC7E,mCAAmC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,+EAA+E;IAC/E,iFAAiF;IACjF,2EAA2E;IAC3E,+EAA+E;IAC/E,+EAA+E;IAC/E,gEAAgE,CAAC;AAEnE,oFAAoF;AACpF,MAAM,UAAU,kBAAkB,CAAC,SAA0B;IAC3D,+DAA+D;IAC/D,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Post-quantum remediation guidance for each classical asymmetric algorithm\n * family. The recommendations follow NIST's finalized PQC algorithms — ML-KEM\n * (FIPS 203), ML-DSA (FIPS 204), SLH-DSA (FIPS 205) — and the IETF hybrid\n * key-exchange groups (X25519MLKEM768, SecP384r1MLKEM1024). Forward-looking\n * standards to track are captured in {@link PQC_TRANSITION_NOTE}.\n */\nimport type { AlgorithmFamily, Remediation } from \"./types.js\";\n\n/** Canonical remediation table, keyed by algorithm family. */\nconst REMEDIATIONS: Record<AlgorithmFamily, Remediation> = {\n RSA: {\n algorithm: \"RSA\",\n recommendation: \"ML-KEM-768 for encryption/KEM; ML-DSA-65 for signatures\",\n detail:\n \"RSA is broken by Shor's algorithm. For key transport / encryption move to \" +\n \"ML-KEM-768 (FIPS 203), ideally as the hybrid X25519MLKEM768. For digital \" +\n \"signatures move to ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).\",\n },\n ECDH: {\n algorithm: \"ECDH\",\n recommendation: \"hybrid X25519MLKEM768 (ML-KEM-768)\",\n detail:\n \"Elliptic-curve Diffie-Hellman is broken by Shor's algorithm and is exposed \" +\n \"to harvest-now-decrypt-later. Adopt the hybrid X25519MLKEM768 key exchange so \" +\n \"confidentiality survives even if one component is broken.\",\n },\n ECDSA: {\n algorithm: \"ECDSA\",\n recommendation: \"ML-DSA-65 (FIPS 204)\",\n detail:\n \"ECDSA signatures can be forged by a quantum attacker via Shor's algorithm. \" +\n \"Migrate to ML-DSA (Dilithium, FIPS 204) or SLH-DSA (SPHINCS+, FIPS 205) for \" +\n \"long-lived signatures.\",\n },\n EdDSA: {\n algorithm: \"EdDSA\",\n recommendation: \"ML-DSA-65 (FIPS 204)\",\n detail:\n \"Ed25519 / Ed448 (EdDSA) are classical signatures broken by Shor's algorithm. \" +\n \"Replace with ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205) for forgery resistance.\",\n },\n DH: {\n algorithm: \"DH\",\n recommendation: \"hybrid X25519MLKEM768 (ML-KEM-768)\",\n detail:\n \"Finite-field Diffie-Hellman is broken by Shor's algorithm and exposed to \" +\n \"harvest-now-decrypt-later. Move to a hybrid PQC KEM such as X25519MLKEM768.\",\n },\n DSA: {\n algorithm: \"DSA\",\n recommendation: \"ML-DSA-65 (FIPS 204)\",\n detail:\n \"DSA is a classical, quantum-broken signature scheme (and already deprecated). \" +\n \"Replace with ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).\",\n },\n X25519: {\n algorithm: \"X25519\",\n recommendation: \"hybrid X25519MLKEM768 (ML-KEM-768)\",\n detail:\n \"X25519 is a modern, well-built classical key-agreement primitive but is still \" +\n \"broken by Shor's algorithm. Wrap it in the hybrid X25519MLKEM768 construction \" +\n \"so it stays useful during the PQC transition.\",\n },\n X448: {\n algorithm: \"X448\",\n recommendation: \"hybrid SecP384r1MLKEM1024 (or X25519MLKEM768)\",\n detail:\n \"X448 (Goldilocks curve) is a modern classical key-agreement primitive at a \" +\n \"higher classical security level, but it is still broken by Shor's algorithm. \" +\n \"To preserve that assurance level, prefer the SecP384r1MLKEM1024 hybrid \" +\n \"(ML-KEM-1024); X25519MLKEM768 is acceptable at the commercial tier.\",\n },\n ECIES: {\n algorithm: \"ECIES\",\n recommendation: \"ML-KEM-768 hybrid encryption (X-Wing for HPKE)\",\n detail:\n \"ECIES relies on classical ECDH for its key encapsulation and is exposed to \" +\n \"harvest-now-decrypt-later. Replace the KEM step with ML-KEM-768 (FIPS 203) in \" +\n \"a hybrid construction — for HPKE-style application-layer encryption, X-Wing \" +\n \"(X25519 + ML-KEM-768) is the emerging hybrid KEM target.\",\n },\n unknown: {\n algorithm: \"unknown\",\n recommendation: \"review for post-quantum migration\",\n detail:\n \"This usage involves classical public-key cryptography. Audit it and plan a \" +\n \"migration to NIST PQC standards (ML-KEM / FIPS 203, ML-DSA / FIPS 204).\",\n },\n};\n\n/** Look up the recommended post-quantum remediation for a classical algorithm. */\nexport function remediationFor(algorithm: AlgorithmFamily): Remediation | undefined {\n return REMEDIATIONS[algorithm];\n}\n\n/** Convenience: just the short recommendation string for a family (always defined). */\nexport function remediationText(algorithm: AlgorithmFamily): string {\n return REMEDIATIONS[algorithm].recommendation;\n}\n\n/**\n * True when a family's PQC replacement is a KEM — i.e. it's used for\n * confidentiality / key-agreement (and is therefore harvest-now-decrypt-later\n * exposed). RSA is in both this set and {@link isSignatureFamily}. Single\n * source of truth for the family→target taxonomy used by tier guidance and the\n * multi-family remediation composer.\n */\nexport function isConfidentialityFamily(algorithm: AlgorithmFamily): boolean {\n return (\n algorithm === \"RSA\" ||\n algorithm === \"ECDH\" ||\n algorithm === \"DH\" ||\n algorithm === \"X25519\" ||\n algorithm === \"X448\" ||\n algorithm === \"ECIES\"\n );\n}\n\n/** True when a family's PQC replacement is a signature scheme (ML-DSA / SLH-DSA). */\nexport function isSignatureFamily(algorithm: AlgorithmFamily): boolean {\n return (\n algorithm === \"RSA\" || algorithm === \"ECDSA\" || algorithm === \"EdDSA\" || algorithm === \"DSA\"\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Security-tier guidance (CNSA 2.0 Category 5) + stateful HBS (SP 800-208) */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Security tier for remediation guidance.\n * - `\"category-3\"` (default): commercial use — ML-KEM-768 / ML-DSA-65.\n * - `\"category-5\"`: CNSA 2.0 national-security-systems / long-lived secrets —\n * ML-KEM-1024 / ML-DSA-87.\n */\nexport type SecurityTier = \"category-3\" | \"category-5\";\n\n/** Per-tier KEM / signature parameter sets. */\nexport const TIER_PARAMS: Record<SecurityTier, { kem: string; signature: string; note: string }> = {\n \"category-3\": {\n kem: \"ML-KEM-768 (FIPS 203)\",\n signature: \"ML-DSA-65 (FIPS 204)\",\n note: \"NIST Category 3 — default for general commercial use.\",\n },\n \"category-5\": {\n kem: \"ML-KEM-1024 (FIPS 203)\",\n signature: \"ML-DSA-87 (FIPS 204)\",\n note: \"NIST Category 5 — CNSA 2.0 for national-security systems and long-lived secrets (2030/2033 milestones).\",\n },\n};\n\n/**\n * Tier-aware remediation. Returns the base family remediation plus the\n * parameter sets for the requested CNSA tier. Category 5 surfaces the\n * ML-KEM-1024 / ML-DSA-87 sets mandated by CNSA 2.0; category 3 is the\n * commercial default.\n */\nexport function remediationForTier(\n algorithm: AlgorithmFamily,\n tier: SecurityTier = \"category-3\",\n): Remediation {\n const base = REMEDIATIONS[algorithm];\n const params = TIER_PARAMS[tier];\n // Confidentiality families lean on the KEM; signature families on the signer.\n const isConf = isConfidentialityFamily(algorithm);\n const primary = isConf ? params.kem : params.signature;\n\n // Category-5 (CNSA 2.0 / NSS) mandates the ML-KEM-1024 / ML-DSA-87 parameter\n // sets and must NOT surface the category-3 X25519MLKEM768 hybrid (its PQC\n // component is ML-KEM-768 — sub-CNSA). Lead with the mandated set; only point\n // at a hybrid TLS group at the 1024 level (audit: quantum #1, crypto S5).\n if (tier === \"category-5\") {\n const hybridNote = isConf\n ? \" If a hybrid TLS group is required, use SecP384r1MLKEM1024 (draft-ietf-tls-ecdhe-mlkem) — not X25519MLKEM768, whose ML-KEM-768 component does not meet CNSA 2.0.\"\n : \"\";\n return {\n algorithm,\n recommendation: `${primary} — CNSA 2.0 mandates this parameter set (hybrids optional)`,\n detail: `${base.detail} ${params.note} For CNSA 2.0 / national-security systems use ${params.kem} (KEM) and ${params.signature} (signatures).${hybridNote}`,\n };\n }\n\n return {\n algorithm,\n recommendation: `${base.recommendation} — ${tier}: ${primary}`,\n detail: `${base.detail} ${params.note} For this tier use ${params.kem} (KEM) and ${params.signature} (signatures).`,\n };\n}\n\n/**\n * Guidance for stateful hash-based signatures (SP 800-208: LMS / XMSS / HSS).\n * These are NIST-approved for firmware / boot signing but are STATEFUL — each\n * private key may sign a bounded number of messages and the state MUST be\n * managed to avoid catastrophic key reuse. Surfaced where a long-lived,\n * low-volume signing root is appropriate.\n */\nexport const STATEFUL_HBS_NOTE =\n \"For firmware / secure-boot signing, the stateful hash-based signatures \" +\n \"LMS, XMSS and HSS (NIST SP 800-208) are approved alternatives to ML-DSA, \" +\n \"but they are STATEFUL: the signer must never reuse a one-time key index. \" +\n \"Use only with rigorous state management; otherwise prefer stateless ML-DSA \" +\n \"(FIPS 204) or SLH-DSA (FIPS 205).\";\n\n/**\n * Forward-looking PQC standards worth tracking beyond the current FIPS 203/204/205\n * targets. Surfaced for operators planning multi-year migrations.\n */\nexport const PQC_TRANSITION_NOTE =\n \"Migration urgency: NIST IR 8547 deprecates classical public-key crypto after \" +\n \"2030 and disallows it after 2035 — long-lived (harvest-now-decrypt-later) data \" +\n \"must move sooner. Standards to track: HQC (NIST's code-based backup KEM, \" +\n \"selected March 2025; draft FIPS expected ~2026) as a diversity hedge against \" +\n \"ML-KEM; FN-DSA / Falcon (draft FIPS 206) for compact lattice signatures; and \" +\n \"X-Wing (X25519 + ML-KEM-768) for HPKE-style hybrid encryption.\";\n\n/** True when stateful HBS (SP 800-208) is a reasonable alternative for a family. */\nexport function statefulHbsApplies(algorithm: AlgorithmFamily): boolean {\n // Signature families only — LMS/XMSS are signatures, not KEMs.\n return isSignatureFamily(algorithm);\n}\n"]}
1
+ {"version":3,"file":"remediation.js","sourceRoot":"","sources":["../src/remediation.ts"],"names":[],"mappings":"AAUA,8DAA8D;AAC9D,MAAM,YAAY,GAAyC;IACzD,GAAG,EAAE;QACH,SAAS,EAAE,KAAK;QAChB,cAAc,EAAE,yDAAyD;QACzE,MAAM,EACJ,4EAA4E;YAC5E,2EAA2E;YAC3E,gEAAgE;KACnE;IACD,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM;QACjB,cAAc,EAAE,oCAAoC;QACpD,MAAM,EACJ,6EAA6E;YAC7E,gFAAgF;YAChF,2DAA2D;KAC9D;IACD,KAAK,EAAE;QACL,SAAS,EAAE,OAAO;QAClB,cAAc,EAAE,sBAAsB;QACtC,MAAM,EACJ,6EAA6E;YAC7E,8EAA8E;YAC9E,wBAAwB;KAC3B;IACD,KAAK,EAAE;QACL,SAAS,EAAE,OAAO;QAClB,cAAc,EAAE,sBAAsB;QACtC,MAAM,EACJ,+EAA+E;YAC/E,iFAAiF;KACpF;IACD,EAAE,EAAE;QACF,SAAS,EAAE,IAAI;QACf,cAAc,EAAE,oCAAoC;QACpD,MAAM,EACJ,2EAA2E;YAC3E,6EAA6E;KAChF;IACD,GAAG,EAAE;QACH,SAAS,EAAE,KAAK;QAChB,cAAc,EAAE,sBAAsB;QACtC,MAAM,EACJ,gFAAgF;YAChF,0DAA0D;KAC7D;IACD,MAAM,EAAE;QACN,SAAS,EAAE,QAAQ;QACnB,cAAc,E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AAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,+EAA+E;IAC/E,iFAAiF;IACjF,2EAA2E;IAC3E,+EAA+E;IAC/E,+EAA+E;IAC/E,gEAAgE,CAAC;AAEnE,oFAAoF;AACpF,MAAM,UAAU,kBAAkB,CAAC,SAA0B;IAC3D,+DAA+D;IAC/D,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Post-quantum remediation guidance for each classical asymmetric algorithm\n * family. The recommendations follow NIST's finalized PQC algorithms — ML-KEM\n * (FIPS 203), ML-DSA (FIPS 204), SLH-DSA (FIPS 205) — and the IETF hybrid\n * key-exchange groups (X25519MLKEM768, SecP384r1MLKEM1024). Forward-looking\n * standards to track are captured in {@link PQC_TRANSITION_NOTE}.\n */\nimport type { AlgorithmFamily, Remediation } from \"./types.js\";\nimport type { StandardsProfile } from \"./standards-profiles.js\";\n\n/** Canonical remediation table, keyed by algorithm family. */\nconst REMEDIATIONS: Record<AlgorithmFamily, Remediation> = {\n RSA: {\n algorithm: \"RSA\",\n recommendation: \"ML-KEM-768 for encryption/KEM; ML-DSA-65 for signatures\",\n detail:\n \"RSA is broken by Shor's algorithm. For key transport / encryption move to \" +\n \"ML-KEM-768 (FIPS 203), ideally as the hybrid X25519MLKEM768. For digital \" +\n \"signatures move to ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).\",\n },\n ECDH: {\n algorithm: \"ECDH\",\n recommendation: \"hybrid X25519MLKEM768 (ML-KEM-768)\",\n detail:\n \"Elliptic-curve Diffie-Hellman is broken by Shor's algorithm and is exposed \" +\n \"to harvest-now-decrypt-later. Adopt the hybrid X25519MLKEM768 key exchange so \" +\n \"confidentiality survives even if one component is broken.\",\n },\n ECDSA: {\n algorithm: \"ECDSA\",\n recommendation: \"ML-DSA-65 (FIPS 204)\",\n detail:\n \"ECDSA signatures can be forged by a quantum attacker via Shor's algorithm. \" +\n \"Migrate to ML-DSA (Dilithium, FIPS 204) or SLH-DSA (SPHINCS+, FIPS 205) for \" +\n \"long-lived signatures.\",\n },\n EdDSA: {\n algorithm: \"EdDSA\",\n recommendation: \"ML-DSA-65 (FIPS 204)\",\n detail:\n \"Ed25519 / Ed448 (EdDSA) are classical signatures broken by Shor's algorithm. \" +\n \"Replace with ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205) for forgery resistance.\",\n },\n DH: {\n algorithm: \"DH\",\n recommendation: \"hybrid X25519MLKEM768 (ML-KEM-768)\",\n detail:\n \"Finite-field Diffie-Hellman is broken by Shor's algorithm and exposed to \" +\n \"harvest-now-decrypt-later. Move to a hybrid PQC KEM such as X25519MLKEM768.\",\n },\n DSA: {\n algorithm: \"DSA\",\n recommendation: \"ML-DSA-65 (FIPS 204)\",\n detail:\n \"DSA is a classical, quantum-broken signature scheme (and already deprecated). \" +\n \"Replace with ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).\",\n },\n X25519: {\n algorithm: \"X25519\",\n recommendation: \"hybrid X25519MLKEM768 (ML-KEM-768)\",\n detail:\n \"X25519 is a modern, well-built classical key-agreement primitive but is still \" +\n \"broken by Shor's algorithm. Wrap it in the hybrid X25519MLKEM768 construction \" +\n \"so it stays useful during the PQC transition.\",\n },\n X448: {\n algorithm: \"X448\",\n recommendation: \"hybrid SecP384r1MLKEM1024 (or X25519MLKEM768)\",\n detail:\n \"X448 (Goldilocks curve) is a modern classical key-agreement primitive at a \" +\n \"higher classical security level, but it is still broken by Shor's algorithm. \" +\n \"To preserve that assurance level, prefer the SecP384r1MLKEM1024 hybrid \" +\n \"(ML-KEM-1024); X25519MLKEM768 is acceptable at the commercial tier.\",\n },\n ECIES: {\n algorithm: \"ECIES\",\n recommendation: \"ML-KEM-768 hybrid encryption (X-Wing for HPKE)\",\n detail:\n \"ECIES relies on classical ECDH for its key encapsulation and is exposed to \" +\n \"harvest-now-decrypt-later. Replace the KEM step with ML-KEM-768 (FIPS 203) in \" +\n \"a hybrid construction — for HPKE-style application-layer encryption, X-Wing \" +\n \"(X25519 + ML-KEM-768) is the emerging hybrid KEM target.\",\n },\n unknown: {\n algorithm: \"unknown\",\n recommendation: \"review for post-quantum migration\",\n detail:\n \"This usage involves classical public-key cryptography. Audit it and plan a \" +\n \"migration to NIST PQC standards (ML-KEM / FIPS 203, ML-DSA / FIPS 204).\",\n },\n};\n\n/** Look up the recommended post-quantum remediation for a classical algorithm. */\nexport function remediationFor(algorithm: AlgorithmFamily): Remediation | undefined {\n return REMEDIATIONS[algorithm];\n}\n\n/** Convenience: just the short recommendation string for a family (always defined). */\nexport function remediationText(algorithm: AlgorithmFamily): string {\n return REMEDIATIONS[algorithm].recommendation;\n}\n\n/**\n * True when a family's PQC replacement is a KEM — i.e. it's used for\n * confidentiality / key-agreement (and is therefore harvest-now-decrypt-later\n * exposed). RSA is in both this set and {@link isSignatureFamily}. Single\n * source of truth for the family→target taxonomy used by tier guidance and the\n * multi-family remediation composer.\n */\nexport function isConfidentialityFamily(algorithm: AlgorithmFamily): boolean {\n return (\n algorithm === \"RSA\" ||\n algorithm === \"ECDH\" ||\n algorithm === \"DH\" ||\n algorithm === \"X25519\" ||\n algorithm === \"X448\" ||\n algorithm === \"ECIES\"\n );\n}\n\n/** True when a family's PQC replacement is a signature scheme (ML-DSA / SLH-DSA). */\nexport function isSignatureFamily(algorithm: AlgorithmFamily): boolean {\n return (\n algorithm === \"RSA\" || algorithm === \"ECDSA\" || algorithm === \"EdDSA\" || algorithm === \"DSA\"\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Security-tier guidance (CNSA 2.0 Category 5) + stateful HBS (SP 800-208) */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Security tier for remediation guidance.\n * - `\"category-3\"` (default): commercial use — ML-KEM-768 / ML-DSA-65.\n * - `\"category-5\"`: CNSA 2.0 national-security-systems / long-lived secrets —\n * ML-KEM-1024 / ML-DSA-87.\n */\nexport type SecurityTier = \"category-3\" | \"category-5\";\n\n/** Per-tier KEM / signature parameter sets. */\nexport const TIER_PARAMS: Record<SecurityTier, { kem: string; signature: string; note: string }> = {\n \"category-3\": {\n kem: \"ML-KEM-768 (FIPS 203)\",\n signature: \"ML-DSA-65 (FIPS 204)\",\n note: \"NIST Category 3 — default for general commercial use.\",\n },\n \"category-5\": {\n kem: \"ML-KEM-1024 (FIPS 203)\",\n signature: \"ML-DSA-87 (FIPS 204)\",\n note: \"NIST Category 5 — CNSA 2.0 for national-security systems and long-lived secrets (2030/2033 milestones).\",\n },\n};\n\n/**\n * Tier-aware remediation. Returns the base family remediation plus the\n * parameter sets for the requested CNSA tier. Category 5 surfaces the\n * ML-KEM-1024 / ML-DSA-87 sets mandated by CNSA 2.0; category 3 is the\n * commercial default.\n */\nexport function remediationForTier(\n algorithm: AlgorithmFamily,\n tier: SecurityTier = \"category-3\",\n): Remediation {\n const base = REMEDIATIONS[algorithm];\n const params = TIER_PARAMS[tier];\n // Confidentiality families lean on the KEM; signature families on the signer.\n const isConf = isConfidentialityFamily(algorithm);\n const primary = isConf ? params.kem : params.signature;\n\n // Category-5 (CNSA 2.0 / NSS) mandates the ML-KEM-1024 / ML-DSA-87 parameter\n // sets and must NOT surface the category-3 X25519MLKEM768 hybrid (its PQC\n // component is ML-KEM-768 — sub-CNSA). Lead with the mandated set; only point\n // at a hybrid TLS group at the 1024 level (audit: quantum #1, crypto S5).\n if (tier === \"category-5\") {\n const hybridNote = isConf\n ? \" If a hybrid TLS group is required, use SecP384r1MLKEM1024 (draft-ietf-tls-ecdhe-mlkem) — not X25519MLKEM768, whose ML-KEM-768 component does not meet CNSA 2.0.\"\n : \"\";\n return {\n algorithm,\n recommendation: `${primary} — CNSA 2.0 mandates this parameter set (hybrids optional)`,\n detail: `${base.detail} ${params.note} For CNSA 2.0 / national-security systems use ${params.kem} (KEM) and ${params.signature} (signatures).${hybridNote}`,\n };\n }\n\n return {\n algorithm,\n recommendation: `${base.recommendation} — ${tier}: ${primary}`,\n detail: `${base.detail} ${params.note} For this tier use ${params.kem} (KEM) and ${params.signature} (signatures).`,\n };\n}\n\n/**\n * Regime-aware remediation. Composes the base family guidance with a\n * {@link StandardsProfile}'s parameter sets, HYBRID STANCE, and deprecation\n * deadlines, so an ANSSI/BSI audience is told hybrid is *required* while a CNSA 2.0\n * audience is told it is *optional* (and pointed at the 1024-level hybrid). This is\n * the profile-driven successor to {@link remediationForTier}; `--tier category-5`\n * resolves to the `cnsa-2.0` profile.\n */\nexport function remediationForProfile(\n algorithm: AlgorithmFamily,\n profile: StandardsProfile,\n): Remediation {\n const base = REMEDIATIONS[algorithm];\n const isConf = isConfidentialityFamily(algorithm);\n const primary = isConf ? profile.paramSets.kem : profile.paramSets.signature;\n // The hybrid stance governs KEY ESTABLISHMENT, so it is surfaced for confidentiality\n // families; signature families migrate to a stateless PQC signer directly.\n const stanceWord =\n profile.hybridStance === \"required\"\n ? \"hybrid required\"\n : profile.hybridStance === \"recommended\"\n ? \"hybrid recommended\"\n : \"hybrids optional\";\n const recommendation = isConf\n ? `${primary} — ${profile.name}: ${stanceWord}`\n : `${primary} — ${profile.name}`;\n const hybridClause = isConf ? ` ${profile.hybridGuidance}` : \"\";\n return {\n algorithm,\n recommendation,\n detail:\n `${base.detail} Under ${profile.name} (${profile.citation}), use ${profile.paramSets.kem} for ` +\n `key establishment and ${profile.paramSets.signature} for signatures; classical public-key ` +\n `crypto is deprecated after ${profile.deprecateAfter} and disallowed after ${profile.disallowAfter}.` +\n hybridClause,\n };\n}\n\n/**\n * Guidance for stateful hash-based signatures (SP 800-208: LMS / XMSS / HSS).\n * These are NIST-approved for firmware / boot signing but are STATEFUL — each\n * private key may sign a bounded number of messages and the state MUST be\n * managed to avoid catastrophic key reuse. Surfaced where a long-lived,\n * low-volume signing root is appropriate.\n */\nexport const STATEFUL_HBS_NOTE =\n \"For firmware / secure-boot signing, the stateful hash-based signatures \" +\n \"LMS, XMSS and HSS (NIST SP 800-208) are approved alternatives to ML-DSA, \" +\n \"but they are STATEFUL: the signer must never reuse a one-time key index. \" +\n \"Use only with rigorous state management; otherwise prefer stateless ML-DSA \" +\n \"(FIPS 204) or SLH-DSA (FIPS 205).\";\n\n/**\n * Forward-looking PQC standards worth tracking beyond the current FIPS 203/204/205\n * targets. Surfaced for operators planning multi-year migrations.\n */\nexport const PQC_TRANSITION_NOTE =\n \"Migration urgency: NIST IR 8547 deprecates classical public-key crypto after \" +\n \"2030 and disallows it after 2035 — long-lived (harvest-now-decrypt-later) data \" +\n \"must move sooner. Standards to track: HQC (NIST's code-based backup KEM, \" +\n \"selected March 2025; draft FIPS expected ~2026) as a diversity hedge against \" +\n \"ML-KEM; FN-DSA / Falcon (draft FIPS 206) for compact lattice signatures; and \" +\n \"X-Wing (X25519 + ML-KEM-768) for HPKE-style hybrid encryption.\";\n\n/** True when stateful HBS (SP 800-208) is a reasonable alternative for a family. */\nexport function statefulHbsApplies(algorithm: AlgorithmFamily): boolean {\n // Signature families only — LMS/XMSS are signatures, not KEMs.\n return isSignatureFamily(algorithm);\n}\n"]}
package/dist/report.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { RuleMeta, ScanResult } from "./types.js";
7
7
  import type { SecurityTier } from "./remediation.js";
8
+ import type { StandardsProfile } from "./standards-profiles.js";
8
9
  /** Minimal SARIF 2.1.0 log shape (kept permissive on purpose). */
9
10
  export interface SarifLog {
10
11
  $schema: string;
@@ -48,4 +49,12 @@ export declare function formatSummary(result: ScanResult, options?: {
48
49
  * long-lived secrets. Returns plain (un-coloured) lines; the caller styles them.
49
50
  */
50
51
  export declare function formatTierGuidance(byAlgorithm: Record<string, number>, tier: SecurityTier): string[];
52
+ /**
53
+ * Per-family migration targets tailored to a selected {@link StandardsProfile}
54
+ * (`--profile`). Unlike {@link formatTierGuidance} (CNSA-tier only), this surfaces the
55
+ * regime's parameter sets AND its hybrid stance — required (ANSSI/BSI) vs recommended
56
+ * (NIST/NCSC) vs optional (CNSA 2.0) — so guidance isn't regime-wrong. Returns plain
57
+ * (un-coloured) lines; the caller styles them.
58
+ */
59
+ export declare function formatProfileGuidance(byAlgorithm: Record<string, number>, profile: StandardsProfile): string[];
51
60
  //# sourceMappingURL=report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAA4B,QAAQ,EAAE,UAAU,EAAY,MAAM,YAAY,CAAC;AAK3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AAED,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;CACtB;AAqED,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,QAAQ,CAmI1E;AAkBD,+DAA+D;AAC/D,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqCxF;AAwCD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,GACjD,MAAM,CAyGR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,IAAI,EAAE,YAAY,GACjB,MAAM,EAAE,CAmBV"}
1
+ {"version":3,"file":"report.d.ts","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B,GACxB,MAAM,EAAE,CAsBV"}
package/dist/report.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { VERSION } from "./version.js";
2
2
  import { SEVERITY_ORDER, sarifLevel } from "./severity.js";
3
3
  import { ANALYZABLE_LANGUAGES_LABEL } from "./detect-utils.js";
4
- import { remediationFor, remediationForTier } from "./remediation.js";
4
+ import { remediationFor, remediationForTier, remediationForProfile } from "./remediation.js";
5
5
  import { fingerprintFinding } from "./baseline.js";
6
6
  const SARIF_SCHEMA = "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json";
7
7
  const INFORMATION_URI = "https://github.com/quantakrypto/pqc-tools";
@@ -369,4 +369,34 @@ export function formatTierGuidance(byAlgorithm, tier) {
369
369
  }
370
370
  return out;
371
371
  }
372
+ /**
373
+ * Per-family migration targets tailored to a selected {@link StandardsProfile}
374
+ * (`--profile`). Unlike {@link formatTierGuidance} (CNSA-tier only), this surfaces the
375
+ * regime's parameter sets AND its hybrid stance — required (ANSSI/BSI) vs recommended
376
+ * (NIST/NCSC) vs optional (CNSA 2.0) — so guidance isn't regime-wrong. Returns plain
377
+ * (un-coloured) lines; the caller styles them.
378
+ */
379
+ export function formatProfileGuidance(byAlgorithm, profile) {
380
+ const out = [`${profile.name} migration targets:`];
381
+ const seen = new Set();
382
+ for (const [k, n] of Object.entries(byAlgorithm)) {
383
+ if (n <= 0)
384
+ continue;
385
+ const fam = k;
386
+ if (fam === "unknown" || !remediationFor(fam))
387
+ continue; // skip unmapped families
388
+ const rem = remediationForProfile(fam, profile);
389
+ if (seen.has(rem.recommendation))
390
+ continue;
391
+ seen.add(rem.recommendation);
392
+ out.push(` ${fam} → ${rem.recommendation}`);
393
+ }
394
+ const stance = profile.hybridStance === "required"
395
+ ? "requires classical+PQC hybridization"
396
+ : profile.hybridStance === "recommended"
397
+ ? "recommends hybridization"
398
+ : "does not require hybridization";
399
+ out.push(` ${profile.authority} ${stance}; classical public-key crypto disallowed after ${profile.disallowAfter} (${profile.citation}).`);
400
+ return out;
401
+ }
372
402
  //# sourceMappingURL=report.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA4BnD,MAAM,YAAY,GAChB,gGAAgG,CAAC;AAEnG,MAAM,eAAe,GAAG,2CAA2C,CAAC;AAEpE;;;;GAIG;AACH,SAAS,cAAc,CAAC,CAAU,EAAE,cAAuB;IACzD,IAAI,cAAc,IAAI,CAAC,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;AAC5B,CAAC;AAED,6FAA6F;AAC7F,SAAS,SAAS,CAAC,QAAkB;IACnC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,GAAG,CAAC;QACb,KAAK,MAAM;YACT,OAAO,EAAE,CAAC;QACZ,KAAK,QAAQ;YACX,OAAO,EAAE,CAAC;QACZ,KAAK,KAAK;YACR,OAAO,EAAE,CAAC;QACZ;YACE,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,SAAS,SAAS,CAAC,IAUlB;IACC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,EAAE;QACb,gBAAgB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;QACtC,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;QAC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CACN,0HAA0H,CAC3H,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Reporters: turn a {@link ScanResult} into SARIF 2.1.0, a clean JSON object,\n * or a human-readable text summary. No third-party dependencies — ANSI colour\n * is emitted with raw escape codes and is off by default.\n */\nimport type { AlgorithmFamily, Finding, RuleMeta, ScanResult, Severity } from \"./types.js\";\nimport { VERSION } from \"./version.js\";\nimport { SEVERITY_ORDER, sarifLevel } from \"./severity.js\";\nimport { ANALYZABLE_LANGUAGES_LABEL } from \"./detect-utils.js\";\nimport { remediationFor, remediationForTier } from \"./remediation.js\";\nimport type { SecurityTier } from \"./remediation.js\";\nimport { fingerprintFinding } from \"./baseline.js\";\n\n/** Minimal SARIF 2.1.0 log shape (kept permissive on purpose). */\nexport interface SarifLog {\n $schema: string;\n version: \"2.1.0\";\n runs: unknown[];\n}\n\n/** Options shared by the structured reporters ({@link toSarif} / {@link toJson}). */\nexport interface ReportOptions {\n /**\n * Omit `location.snippet` from every finding in the output. Defaults to false\n * (snippets are included). Snippets of `sensitive` findings (e.g. PEM key\n * blocks, SSH public keys) are ALWAYS omitted regardless of this flag — the\n * snippet there IS the sensitive value.\n */\n redactSnippets?: boolean;\n /**\n * Full rule catalog to advertise in SARIF `tool.driver.rules[]`, even for\n * rules that produced no finding in this run. Pass\n * `defaultRegistry.ruleCatalog()`. When omitted, only the rules that actually\n * fired are emitted (the historical behaviour). SARIF-only; ignored by\n * {@link toJson}.\n */\n catalog?: RuleMeta[];\n}\n\nconst SARIF_SCHEMA =\n \"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\";\n\nconst INFORMATION_URI = \"https://github.com/quantakrypto/pqc-tools\";\n\n/**\n * Resolve the snippet to emit for a finding, honouring redaction. Sensitive\n * findings (key material) never expose their snippet; otherwise the snippet is\n * dropped only when `redactSnippets` is set.\n */\nfunction emittedSnippet(f: Finding, redactSnippets: boolean): string | undefined {\n if (redactSnippets || f.sensitive) return undefined;\n return f.location.snippet;\n}\n\n/** Map our severity to a SARIF rule-level default (used in rules[].defaultConfiguration). */\nfunction sarifRank(severity: Severity): number {\n switch (severity) {\n case \"critical\":\n return 100;\n case \"high\":\n return 80;\n case \"medium\":\n return 50;\n case \"low\":\n return 20;\n default:\n return 5;\n }\n}\n\n/** Build a SARIF `rules[]` entry from a rule's severity/title/message/etc. */\nfunction sarifRule(spec: {\n id: string;\n title: string;\n message: string;\n severity: Severity;\n category: string;\n algorithm?: string;\n hndl: boolean;\n cwe?: string;\n remediation?: string;\n}): Record<string, unknown> {\n return {\n id: spec.id,\n name: spec.id,\n shortDescription: { text: spec.title },\n fullDescription: { text: spec.message },\n defaultConfiguration: { level: sarifLevel(spec.severity), rank: sarifRank(spec.severity) },\n ...(spec.remediation ? { help: { text: `Remediation: ${spec.remediation}` } } : {}),\n properties: {\n category: spec.category,\n ...(spec.algorithm ? { algorithm: spec.algorithm } : {}),\n hndl: spec.hndl,\n ...(spec.cwe ? { cwe: spec.cwe, \"security-severity\": securitySeverity(spec.severity) } : {}),\n ...(spec.cwe ? { tags: [\"security\", spec.cwe] } : {}),\n },\n ...(spec.cwe\n ? {\n relationships: [\n { target: { id: spec.cwe, toolComponent: { name: \"CWE\" } }, kinds: [\"relevant\"] },\n ],\n }\n : {}),\n };\n}\n\n/** Serialize a scan result as SARIF 2.1.0. */\nexport function toSarif(result: ScanResult, opts?: ReportOptions): SarifLog {\n const redactSnippets = opts?.redactSnippets ?? false;\n // Build the rule set and collect the CWE taxa referenced by any rule. When a\n // full catalog is supplied, advertise every rule (even ones that didn't fire);\n // otherwise emit one rule per ruleId encountered (the historical behaviour).\n const ruleIndex = new Map<string, number>();\n const rules: Array<Record<string, unknown>> = [];\n const cweTaxa = new Set<string>();\n\n for (const r of opts?.catalog ?? []) {\n if (ruleIndex.has(r.id)) continue;\n if (r.cwe) cweTaxa.add(r.cwe);\n ruleIndex.set(r.id, rules.length);\n rules.push(\n sarifRule({\n id: r.id,\n title: r.title,\n message: r.message,\n severity: r.severity,\n category: r.category,\n algorithm: r.algorithm,\n hndl: r.hndl,\n cwe: r.cwe,\n remediation: r.remediation,\n }),\n );\n }\n\n for (const f of result.findings) {\n if (f.cwe) cweTaxa.add(f.cwe);\n if (ruleIndex.has(f.ruleId)) continue;\n ruleIndex.set(f.ruleId, rules.length);\n rules.push(\n sarifRule({\n id: f.ruleId,\n title: f.title,\n message: f.message,\n severity: f.severity,\n category: f.category,\n algorithm: f.algorithm,\n hndl: f.hndl,\n cwe: f.cwe,\n remediation: f.remediation,\n }),\n );\n }\n\n const results = result.findings.map((f) => {\n const region: Record<string, number> = { startLine: f.location.line };\n if (typeof f.location.column === \"number\") region.startColumn = f.location.column;\n if (typeof f.location.endLine === \"number\") region.endLine = f.location.endLine;\n const snippet = emittedSnippet(f, redactSnippets);\n\n return {\n ruleId: f.ruleId,\n ruleIndex: ruleIndex.get(f.ruleId),\n level: sarifLevel(f.severity),\n message: { text: f.message },\n // Line-INSENSITIVE fingerprint (the same one the baseline uses:\n // sha256 of ruleId|file|normalizedSnippet). GitHub code scanning keys\n // alert identity + dedup off partialFingerprints, so a finding survives\n // line shifts and reformatting instead of re-alerting as \"new\" on every\n // edit above it. `quantakrypto/v1` names our scheme.\n partialFingerprints: { \"quantakrypto/v1\": fingerprintFinding(f) },\n properties: {\n category: f.category,\n severity: f.severity,\n confidence: f.confidence,\n hndl: f.hndl,\n ...(f.algorithm ? { algorithm: f.algorithm } : {}),\n ...(f.remediation ? { remediation: f.remediation } : {}),\n ...(f.cwe ? { cwe: f.cwe } : {}),\n },\n ...(f.cwe\n ? {\n taxa: [\n {\n target: { id: f.cwe, toolComponent: { name: \"CWE\" } },\n },\n ],\n }\n : {}),\n locations: [\n {\n physicalLocation: {\n artifactLocation: { uri: f.location.file },\n region: {\n ...region,\n ...(snippet ? { snippet: { text: snippet } } : {}),\n },\n },\n },\n ],\n };\n });\n\n // CWE taxonomy component (SARIF taxonomies), referenced by rules + results.\n const taxonomies =\n cweTaxa.size > 0\n ? [\n {\n name: \"CWE\",\n informationUri: \"https://cwe.mitre.org/\",\n organization: \"MITRE\",\n shortDescription: { text: \"The MITRE Common Weakness Enumeration\" },\n taxa: [...cweTaxa].sort().map((id) => ({\n id,\n helpUri: `https://cwe.mitre.org/data/definitions/${id.replace(/^CWE-/, \"\")}.html`,\n })),\n },\n ]\n : [];\n\n return {\n $schema: SARIF_SCHEMA,\n version: \"2.1.0\",\n runs: [\n {\n tool: {\n driver: {\n name: \"qScan\",\n informationUri: INFORMATION_URI,\n version: result.toolVersion || VERSION,\n rules,\n },\n },\n ...(taxonomies.length > 0 ? { taxonomies } : {}),\n results,\n },\n ],\n };\n}\n\n/** GitHub-code-scanning `security-severity` (0–10) derived from our severity. */\nfunction securitySeverity(severity: Severity): string {\n switch (severity) {\n case \"critical\":\n return \"9.5\";\n case \"high\":\n return \"8.0\";\n case \"medium\":\n return \"5.0\";\n case \"low\":\n return \"3.0\";\n default:\n return \"1.0\";\n }\n}\n\n/** Serialize a scan result as a plain JSON-friendly object. */\nexport function toJson(result: ScanResult, opts?: ReportOptions): Record<string, unknown> {\n const redactSnippets = opts?.redactSnippets ?? false;\n return {\n toolVersion: result.toolVersion,\n root: result.root,\n startedAt: result.startedAt,\n finishedAt: result.finishedAt,\n filesScanned: result.filesScanned,\n ...(result.analyzedFiles !== undefined ? { analyzedFiles: result.analyzedFiles } : {}),\n ...(result.diagnostics ? { diagnostics: result.diagnostics } : {}),\n inventory: {\n readinessScore: result.inventory.readinessScore,\n hndlCount: result.inventory.hndlCount,\n bySeverity: result.inventory.bySeverity,\n byCategory: result.inventory.byCategory,\n byAlgorithm: result.inventory.byAlgorithm,\n },\n findings: result.findings.map((f) => ({\n ruleId: f.ruleId,\n title: f.title,\n category: f.category,\n severity: f.severity,\n confidence: f.confidence,\n algorithm: f.algorithm,\n hndl: f.hndl,\n message: f.message,\n remediation: f.remediation,\n cwe: f.cwe,\n location: {\n file: f.location.file,\n line: f.location.line,\n column: f.location.column,\n endLine: f.location.endLine,\n snippet: emittedSnippet(f, redactSnippets),\n },\n })),\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Human-readable summary */\n/* -------------------------------------------------------------------------- */\n\n/** Raw ANSI codes (no chalk). Disabled when colour is off. */\nconst ANSI = {\n reset: \"\\x1b[0m\",\n bold: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n} as const;\n\nfunction severityColor(sev: Severity): string {\n switch (sev) {\n case \"critical\":\n return ANSI.magenta;\n case \"high\":\n return ANSI.red;\n case \"medium\":\n return ANSI.yellow;\n case \"low\":\n return ANSI.blue;\n default:\n return ANSI.dim;\n }\n}\n\nfunction scoreColor(score: number): string {\n if (score >= 80) return ANSI.green;\n if (score >= 50) return ANSI.yellow;\n return ANSI.red;\n}\n\n/**\n * Render a human-readable summary of a scan result. Colour is off by default;\n * pass `{ color: true }` to emit ANSI escape codes.\n */\nexport function formatSummary(\n result: ScanResult,\n options?: { color?: boolean; tier?: SecurityTier },\n): string {\n const color = options?.color ?? false;\n const c = (code: string, text: string): string => (color ? `${code}${text}${ANSI.reset}` : text);\n\n const lines: string[] = [];\n const inv = result.inventory;\n\n lines.push(c(ANSI.bold, \"qScan — post-quantum readiness report\"));\n lines.push(c(ANSI.dim, `tool v${result.toolVersion} · root: ${result.root}`));\n lines.push(\"\");\n\n // Readiness score banner.\n lines.push(\n `Readiness score: ${c(`${ANSI.bold}${scoreColor(inv.readinessScore)}`, `${inv.readinessScore}/100`)}`,\n );\n const analyzed =\n result.analyzedFiles !== undefined\n ? ` Analyzed (${ANALYZABLE_LANGUAGES_LABEL}): ${result.analyzedFiles}`\n : \"\";\n lines.push(\n `Files scanned: ${result.filesScanned}${analyzed} Findings: ${result.findings.length} HNDL-exposed: ${c(\n inv.hndlCount > 0 ? ANSI.red : ANSI.green,\n String(inv.hndlCount),\n )}`,\n );\n // Coverage honesty: a score over zero analyzable files is not a clean bill of health.\n if (result.analyzedFiles === 0 && result.filesScanned > 0) {\n lines.push(\n c(\n ANSI.yellow,\n `Note: 0 files were in a supported source language (${ANALYZABLE_LANGUAGES_LABEL}) — the readiness score does not reflect this codebase.`,\n ),\n );\n }\n // Coverage diagnostics: skipped files mean the finding count may be incomplete.\n const diag = result.diagnostics;\n if (diag && (diag.unreadable > 0 || diag.skippedMinified > 0)) {\n lines.push(\n c(\n ANSI.yellow,\n `Coverage: ${diag.unreadable} unreadable, ${diag.skippedMinified} skipped as minified — results may be incomplete.`,\n ),\n );\n }\n lines.push(\"\");\n\n // Severity breakdown.\n const sevParts = SEVERITY_ORDER.filter((s) => inv.bySeverity[s] > 0).map((s) =>\n c(severityColor(s), `${s}: ${inv.bySeverity[s]}`),\n );\n lines.push(`By severity: ${sevParts.length ? sevParts.join(\" \") : c(ANSI.green, \"none\")}`);\n\n // Algorithm breakdown.\n const algoParts = Object.entries(inv.byAlgorithm)\n .sort((a, b) => b[1] - a[1])\n .map(([k, v]) => `${k}: ${v}`);\n if (algoParts.length) lines.push(`By algorithm: ${algoParts.join(\" \")}`);\n lines.push(\"\");\n\n if (result.findings.length === 0) {\n lines.push(c(ANSI.green, \"No classical asymmetric cryptography detected. ✓\"));\n return lines.join(\"\\n\");\n }\n\n // Top findings, grouped by severity (most severe first), capped for readability.\n const sorted = [...result.findings].sort(\n (a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity),\n );\n const MAX_SHOWN = 25;\n lines.push(\n c(ANSI.bold, `Top findings (${Math.min(MAX_SHOWN, sorted.length)} of ${sorted.length}):`),\n );\n\n for (const f of sorted.slice(0, MAX_SHOWN)) {\n const loc = `${f.location.file}:${f.location.line}${\n f.location.column ? `:${f.location.column}` : \"\"\n }`;\n const tag = c(severityColor(f.severity), `[${f.severity}]`);\n const hndl = f.hndl ? c(ANSI.red, \" (HNDL)\") : \"\";\n lines.push(` ${tag} ${f.title}${hndl}`);\n lines.push(c(ANSI.dim, ` ${loc} — ${f.message}`));\n if (f.remediation) lines.push(c(ANSI.cyan, ` → ${f.remediation}`));\n }\n\n if (sorted.length > MAX_SHOWN) {\n lines.push(c(ANSI.dim, ` …and ${sorted.length - MAX_SHOWN} more.`));\n }\n\n lines.push(\"\");\n if (inv.hndlCount > 0) {\n lines.push(\n c(\n ANSI.yellow,\n `Note: ${inv.hndlCount} finding(s) are exposed to \"harvest now, decrypt later\" — ` +\n \"encrypted traffic captured today can be decrypted once a quantum computer exists. \" +\n \"Prioritise migrating key exchange / encryption to hybrid PQC (X25519MLKEM768).\",\n ),\n );\n }\n\n if (options?.tier) {\n lines.push(\"\", ...formatTierGuidance(inv.byAlgorithm, options.tier));\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Per-family migration targets for a CNSA security tier — surfaces the otherwise\n * library-only {@link remediationForTier} in human reports. Category 5 shows the\n * ML-KEM-1024 / ML-DSA-87 sets CNSA 2.0 mandates for national-security systems and\n * long-lived secrets. Returns plain (un-coloured) lines; the caller styles them.\n */\nexport function formatTierGuidance(\n byAlgorithm: Record<string, number>,\n tier: SecurityTier,\n): string[] {\n const label = tier === \"category-5\" ? \"CNSA 2.0 (Category 5)\" : \"Category 3 (commercial)\";\n const out: string[] = [`${label} migration targets:`];\n const seen = new Set<string>();\n for (const [k, n] of Object.entries(byAlgorithm)) {\n if (n <= 0) continue;\n const fam = k as AlgorithmFamily;\n if (fam === \"unknown\" || !remediationFor(fam)) continue; // skip unmapped families\n const rem = remediationForTier(fam, tier);\n if (seen.has(rem.recommendation)) continue;\n seen.add(rem.recommendation);\n out.push(` ${fam} → ${rem.recommendation}`);\n }\n if (tier === \"category-5\") {\n out.push(\n \" CNSA 2.0 mandates ML-KEM-1024 / ML-DSA-87 for national-security systems and long-lived secrets (2030/2033 milestones).\",\n );\n }\n return out;\n}\n"]}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b,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAmC,EACnC,OAAyB;IAEzB,MAAM,GAAG,GAAa,CAAC,GAAG,OAAO,CAAC,IAAI,qBAAqB,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QACrB,MAAM,GAAG,GAAG,CAAoB,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;YAAE,SAAS,CAAC,yBAAyB;QAClF,MAAM,GAAG,GAAG,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;YAAE,SAAS;QAC3C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC7B,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,MAAM,GACV,OAAO,CAAC,YAAY,KAAK,UAAU;QACjC,CAAC,CAAC,sCAAsC;QACxC,CAAC,CAAC,OAAO,CAAC,YAAY,KAAK,aAAa;YACtC,CAAC,CAAC,0BAA0B;YAC5B,CAAC,CAAC,gCAAgC,CAAC;IACzC,GAAG,CAAC,IAAI,CACN,KAAK,OAAO,CAAC,SAAS,IAAI,MAAM,kDAAkD,OAAO,CAAC,aAAa,KAAK,OAAO,CAAC,QAAQ,IAAI,CACjI,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Reporters: turn a {@link ScanResult} into SARIF 2.1.0, a clean JSON object,\n * or a human-readable text summary. No third-party dependencies — ANSI colour\n * is emitted with raw escape codes and is off by default.\n */\nimport type { AlgorithmFamily, Finding, RuleMeta, ScanResult, Severity } from \"./types.js\";\nimport { VERSION } from \"./version.js\";\nimport { SEVERITY_ORDER, sarifLevel } from \"./severity.js\";\nimport { ANALYZABLE_LANGUAGES_LABEL } from \"./detect-utils.js\";\nimport { remediationFor, remediationForTier, remediationForProfile } from \"./remediation.js\";\nimport type { SecurityTier } from \"./remediation.js\";\nimport type { StandardsProfile } from \"./standards-profiles.js\";\nimport { fingerprintFinding } from \"./baseline.js\";\n\n/** Minimal SARIF 2.1.0 log shape (kept permissive on purpose). */\nexport interface SarifLog {\n $schema: string;\n version: \"2.1.0\";\n runs: unknown[];\n}\n\n/** Options shared by the structured reporters ({@link toSarif} / {@link toJson}). */\nexport interface ReportOptions {\n /**\n * Omit `location.snippet` from every finding in the output. Defaults to false\n * (snippets are included). Snippets of `sensitive` findings (e.g. PEM key\n * blocks, SSH public keys) are ALWAYS omitted regardless of this flag — the\n * snippet there IS the sensitive value.\n */\n redactSnippets?: boolean;\n /**\n * Full rule catalog to advertise in SARIF `tool.driver.rules[]`, even for\n * rules that produced no finding in this run. Pass\n * `defaultRegistry.ruleCatalog()`. When omitted, only the rules that actually\n * fired are emitted (the historical behaviour). SARIF-only; ignored by\n * {@link toJson}.\n */\n catalog?: RuleMeta[];\n}\n\nconst SARIF_SCHEMA =\n \"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\";\n\nconst INFORMATION_URI = \"https://github.com/quantakrypto/pqc-tools\";\n\n/**\n * Resolve the snippet to emit for a finding, honouring redaction. Sensitive\n * findings (key material) never expose their snippet; otherwise the snippet is\n * dropped only when `redactSnippets` is set.\n */\nfunction emittedSnippet(f: Finding, redactSnippets: boolean): string | undefined {\n if (redactSnippets || f.sensitive) return undefined;\n return f.location.snippet;\n}\n\n/** Map our severity to a SARIF rule-level default (used in rules[].defaultConfiguration). */\nfunction sarifRank(severity: Severity): number {\n switch (severity) {\n case \"critical\":\n return 100;\n case \"high\":\n return 80;\n case \"medium\":\n return 50;\n case \"low\":\n return 20;\n default:\n return 5;\n }\n}\n\n/** Build a SARIF `rules[]` entry from a rule's severity/title/message/etc. */\nfunction sarifRule(spec: {\n id: string;\n title: string;\n message: string;\n severity: Severity;\n category: string;\n algorithm?: string;\n hndl: boolean;\n cwe?: string;\n remediation?: string;\n}): Record<string, unknown> {\n return {\n id: spec.id,\n name: spec.id,\n shortDescription: { text: spec.title },\n fullDescription: { text: spec.message },\n defaultConfiguration: { level: sarifLevel(spec.severity), rank: sarifRank(spec.severity) },\n ...(spec.remediation ? { help: { text: `Remediation: ${spec.remediation}` } } : {}),\n properties: {\n category: spec.category,\n ...(spec.algorithm ? { algorithm: spec.algorithm } : {}),\n hndl: spec.hndl,\n ...(spec.cwe ? { cwe: spec.cwe, \"security-severity\": securitySeverity(spec.severity) } : {}),\n ...(spec.cwe ? { tags: [\"security\", spec.cwe] } : {}),\n },\n ...(spec.cwe\n ? {\n relationships: [\n { target: { id: spec.cwe, toolComponent: { name: \"CWE\" } }, kinds: [\"relevant\"] },\n ],\n }\n : {}),\n };\n}\n\n/** Serialize a scan result as SARIF 2.1.0. */\nexport function toSarif(result: ScanResult, opts?: ReportOptions): SarifLog {\n const redactSnippets = opts?.redactSnippets ?? false;\n // Build the rule set and collect the CWE taxa referenced by any rule. When a\n // full catalog is supplied, advertise every rule (even ones that didn't fire);\n // otherwise emit one rule per ruleId encountered (the historical behaviour).\n const ruleIndex = new Map<string, number>();\n const rules: Array<Record<string, unknown>> = [];\n const cweTaxa = new Set<string>();\n\n for (const r of opts?.catalog ?? []) {\n if (ruleIndex.has(r.id)) continue;\n if (r.cwe) cweTaxa.add(r.cwe);\n ruleIndex.set(r.id, rules.length);\n rules.push(\n sarifRule({\n id: r.id,\n title: r.title,\n message: r.message,\n severity: r.severity,\n category: r.category,\n algorithm: r.algorithm,\n hndl: r.hndl,\n cwe: r.cwe,\n remediation: r.remediation,\n }),\n );\n }\n\n for (const f of result.findings) {\n if (f.cwe) cweTaxa.add(f.cwe);\n if (ruleIndex.has(f.ruleId)) continue;\n ruleIndex.set(f.ruleId, rules.length);\n rules.push(\n sarifRule({\n id: f.ruleId,\n title: f.title,\n message: f.message,\n severity: f.severity,\n category: f.category,\n algorithm: f.algorithm,\n hndl: f.hndl,\n cwe: f.cwe,\n remediation: f.remediation,\n }),\n );\n }\n\n const results = result.findings.map((f) => {\n const region: Record<string, number> = { startLine: f.location.line };\n if (typeof f.location.column === \"number\") region.startColumn = f.location.column;\n if (typeof f.location.endLine === \"number\") region.endLine = f.location.endLine;\n const snippet = emittedSnippet(f, redactSnippets);\n\n return {\n ruleId: f.ruleId,\n ruleIndex: ruleIndex.get(f.ruleId),\n level: sarifLevel(f.severity),\n message: { text: f.message },\n // Line-INSENSITIVE fingerprint (the same one the baseline uses:\n // sha256 of ruleId|file|normalizedSnippet). GitHub code scanning keys\n // alert identity + dedup off partialFingerprints, so a finding survives\n // line shifts and reformatting instead of re-alerting as \"new\" on every\n // edit above it. `quantakrypto/v1` names our scheme.\n partialFingerprints: { \"quantakrypto/v1\": fingerprintFinding(f) },\n properties: {\n category: f.category,\n severity: f.severity,\n confidence: f.confidence,\n hndl: f.hndl,\n ...(f.algorithm ? { algorithm: f.algorithm } : {}),\n ...(f.remediation ? { remediation: f.remediation } : {}),\n ...(f.cwe ? { cwe: f.cwe } : {}),\n },\n ...(f.cwe\n ? {\n taxa: [\n {\n target: { id: f.cwe, toolComponent: { name: \"CWE\" } },\n },\n ],\n }\n : {}),\n locations: [\n {\n physicalLocation: {\n artifactLocation: { uri: f.location.file },\n region: {\n ...region,\n ...(snippet ? { snippet: { text: snippet } } : {}),\n },\n },\n },\n ],\n };\n });\n\n // CWE taxonomy component (SARIF taxonomies), referenced by rules + results.\n const taxonomies =\n cweTaxa.size > 0\n ? [\n {\n name: \"CWE\",\n informationUri: \"https://cwe.mitre.org/\",\n organization: \"MITRE\",\n shortDescription: { text: \"The MITRE Common Weakness Enumeration\" },\n taxa: [...cweTaxa].sort().map((id) => ({\n id,\n helpUri: `https://cwe.mitre.org/data/definitions/${id.replace(/^CWE-/, \"\")}.html`,\n })),\n },\n ]\n : [];\n\n return {\n $schema: SARIF_SCHEMA,\n version: \"2.1.0\",\n runs: [\n {\n tool: {\n driver: {\n name: \"qScan\",\n informationUri: INFORMATION_URI,\n version: result.toolVersion || VERSION,\n rules,\n },\n },\n ...(taxonomies.length > 0 ? { taxonomies } : {}),\n results,\n },\n ],\n };\n}\n\n/** GitHub-code-scanning `security-severity` (0–10) derived from our severity. */\nfunction securitySeverity(severity: Severity): string {\n switch (severity) {\n case \"critical\":\n return \"9.5\";\n case \"high\":\n return \"8.0\";\n case \"medium\":\n return \"5.0\";\n case \"low\":\n return \"3.0\";\n default:\n return \"1.0\";\n }\n}\n\n/** Serialize a scan result as a plain JSON-friendly object. */\nexport function toJson(result: ScanResult, opts?: ReportOptions): Record<string, unknown> {\n const redactSnippets = opts?.redactSnippets ?? false;\n return {\n toolVersion: result.toolVersion,\n root: result.root,\n startedAt: result.startedAt,\n finishedAt: result.finishedAt,\n filesScanned: result.filesScanned,\n ...(result.analyzedFiles !== undefined ? { analyzedFiles: result.analyzedFiles } : {}),\n ...(result.diagnostics ? { diagnostics: result.diagnostics } : {}),\n inventory: {\n readinessScore: result.inventory.readinessScore,\n hndlCount: result.inventory.hndlCount,\n bySeverity: result.inventory.bySeverity,\n byCategory: result.inventory.byCategory,\n byAlgorithm: result.inventory.byAlgorithm,\n },\n findings: result.findings.map((f) => ({\n ruleId: f.ruleId,\n title: f.title,\n category: f.category,\n severity: f.severity,\n confidence: f.confidence,\n algorithm: f.algorithm,\n hndl: f.hndl,\n message: f.message,\n remediation: f.remediation,\n cwe: f.cwe,\n location: {\n file: f.location.file,\n line: f.location.line,\n column: f.location.column,\n endLine: f.location.endLine,\n snippet: emittedSnippet(f, redactSnippets),\n },\n })),\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Human-readable summary */\n/* -------------------------------------------------------------------------- */\n\n/** Raw ANSI codes (no chalk). Disabled when colour is off. */\nconst ANSI = {\n reset: \"\\x1b[0m\",\n bold: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n} as const;\n\nfunction severityColor(sev: Severity): string {\n switch (sev) {\n case \"critical\":\n return ANSI.magenta;\n case \"high\":\n return ANSI.red;\n case \"medium\":\n return ANSI.yellow;\n case \"low\":\n return ANSI.blue;\n default:\n return ANSI.dim;\n }\n}\n\nfunction scoreColor(score: number): string {\n if (score >= 80) return ANSI.green;\n if (score >= 50) return ANSI.yellow;\n return ANSI.red;\n}\n\n/**\n * Render a human-readable summary of a scan result. Colour is off by default;\n * pass `{ color: true }` to emit ANSI escape codes.\n */\nexport function formatSummary(\n result: ScanResult,\n options?: { color?: boolean; tier?: SecurityTier },\n): string {\n const color = options?.color ?? false;\n const c = (code: string, text: string): string => (color ? `${code}${text}${ANSI.reset}` : text);\n\n const lines: string[] = [];\n const inv = result.inventory;\n\n lines.push(c(ANSI.bold, \"qScan — post-quantum readiness report\"));\n lines.push(c(ANSI.dim, `tool v${result.toolVersion} · root: ${result.root}`));\n lines.push(\"\");\n\n // Readiness score banner.\n lines.push(\n `Readiness score: ${c(`${ANSI.bold}${scoreColor(inv.readinessScore)}`, `${inv.readinessScore}/100`)}`,\n );\n const analyzed =\n result.analyzedFiles !== undefined\n ? ` Analyzed (${ANALYZABLE_LANGUAGES_LABEL}): ${result.analyzedFiles}`\n : \"\";\n lines.push(\n `Files scanned: ${result.filesScanned}${analyzed} Findings: ${result.findings.length} HNDL-exposed: ${c(\n inv.hndlCount > 0 ? ANSI.red : ANSI.green,\n String(inv.hndlCount),\n )}`,\n );\n // Coverage honesty: a score over zero analyzable files is not a clean bill of health.\n if (result.analyzedFiles === 0 && result.filesScanned > 0) {\n lines.push(\n c(\n ANSI.yellow,\n `Note: 0 files were in a supported source language (${ANALYZABLE_LANGUAGES_LABEL}) — the readiness score does not reflect this codebase.`,\n ),\n );\n }\n // Coverage diagnostics: skipped files mean the finding count may be incomplete.\n const diag = result.diagnostics;\n if (diag && (diag.unreadable > 0 || diag.skippedMinified > 0)) {\n lines.push(\n c(\n ANSI.yellow,\n `Coverage: ${diag.unreadable} unreadable, ${diag.skippedMinified} skipped as minified — results may be incomplete.`,\n ),\n );\n }\n lines.push(\"\");\n\n // Severity breakdown.\n const sevParts = SEVERITY_ORDER.filter((s) => inv.bySeverity[s] > 0).map((s) =>\n c(severityColor(s), `${s}: ${inv.bySeverity[s]}`),\n );\n lines.push(`By severity: ${sevParts.length ? sevParts.join(\" \") : c(ANSI.green, \"none\")}`);\n\n // Algorithm breakdown.\n const algoParts = Object.entries(inv.byAlgorithm)\n .sort((a, b) => b[1] - a[1])\n .map(([k, v]) => `${k}: ${v}`);\n if (algoParts.length) lines.push(`By algorithm: ${algoParts.join(\" \")}`);\n lines.push(\"\");\n\n if (result.findings.length === 0) {\n lines.push(c(ANSI.green, \"No classical asymmetric cryptography detected. ✓\"));\n return lines.join(\"\\n\");\n }\n\n // Top findings, grouped by severity (most severe first), capped for readability.\n const sorted = [...result.findings].sort(\n (a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity),\n );\n const MAX_SHOWN = 25;\n lines.push(\n c(ANSI.bold, `Top findings (${Math.min(MAX_SHOWN, sorted.length)} of ${sorted.length}):`),\n );\n\n for (const f of sorted.slice(0, MAX_SHOWN)) {\n const loc = `${f.location.file}:${f.location.line}${\n f.location.column ? `:${f.location.column}` : \"\"\n }`;\n const tag = c(severityColor(f.severity), `[${f.severity}]`);\n const hndl = f.hndl ? c(ANSI.red, \" (HNDL)\") : \"\";\n lines.push(` ${tag} ${f.title}${hndl}`);\n lines.push(c(ANSI.dim, ` ${loc} — ${f.message}`));\n if (f.remediation) lines.push(c(ANSI.cyan, ` → ${f.remediation}`));\n }\n\n if (sorted.length > MAX_SHOWN) {\n lines.push(c(ANSI.dim, ` …and ${sorted.length - MAX_SHOWN} more.`));\n }\n\n lines.push(\"\");\n if (inv.hndlCount > 0) {\n lines.push(\n c(\n ANSI.yellow,\n `Note: ${inv.hndlCount} finding(s) are exposed to \"harvest now, decrypt later\" — ` +\n \"encrypted traffic captured today can be decrypted once a quantum computer exists. \" +\n \"Prioritise migrating key exchange / encryption to hybrid PQC (X25519MLKEM768).\",\n ),\n );\n }\n\n if (options?.tier) {\n lines.push(\"\", ...formatTierGuidance(inv.byAlgorithm, options.tier));\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Per-family migration targets for a CNSA security tier — surfaces the otherwise\n * library-only {@link remediationForTier} in human reports. Category 5 shows the\n * ML-KEM-1024 / ML-DSA-87 sets CNSA 2.0 mandates for national-security systems and\n * long-lived secrets. Returns plain (un-coloured) lines; the caller styles them.\n */\nexport function formatTierGuidance(\n byAlgorithm: Record<string, number>,\n tier: SecurityTier,\n): string[] {\n const label = tier === \"category-5\" ? \"CNSA 2.0 (Category 5)\" : \"Category 3 (commercial)\";\n const out: string[] = [`${label} migration targets:`];\n const seen = new Set<string>();\n for (const [k, n] of Object.entries(byAlgorithm)) {\n if (n <= 0) continue;\n const fam = k as AlgorithmFamily;\n if (fam === \"unknown\" || !remediationFor(fam)) continue; // skip unmapped families\n const rem = remediationForTier(fam, tier);\n if (seen.has(rem.recommendation)) continue;\n seen.add(rem.recommendation);\n out.push(` ${fam} → ${rem.recommendation}`);\n }\n if (tier === \"category-5\") {\n out.push(\n \" CNSA 2.0 mandates ML-KEM-1024 / ML-DSA-87 for national-security systems and long-lived secrets (2030/2033 milestones).\",\n );\n }\n return out;\n}\n\n/**\n * Per-family migration targets tailored to a selected {@link StandardsProfile}\n * (`--profile`). Unlike {@link formatTierGuidance} (CNSA-tier only), this surfaces the\n * regime's parameter sets AND its hybrid stance — required (ANSSI/BSI) vs recommended\n * (NIST/NCSC) vs optional (CNSA 2.0) — so guidance isn't regime-wrong. Returns plain\n * (un-coloured) lines; the caller styles them.\n */\nexport function formatProfileGuidance(\n byAlgorithm: Record<string, number>,\n profile: StandardsProfile,\n): string[] {\n const out: string[] = [`${profile.name} migration targets:`];\n const seen = new Set<string>();\n for (const [k, n] of Object.entries(byAlgorithm)) {\n if (n <= 0) continue;\n const fam = k as AlgorithmFamily;\n if (fam === \"unknown\" || !remediationFor(fam)) continue; // skip unmapped families\n const rem = remediationForProfile(fam, profile);\n if (seen.has(rem.recommendation)) continue;\n seen.add(rem.recommendation);\n out.push(` ${fam} → ${rem.recommendation}`);\n }\n const stance =\n profile.hybridStance === \"required\"\n ? \"requires classical+PQC hybridization\"\n : profile.hybridStance === \"recommended\"\n ? \"recommends hybridization\"\n : \"does not require hybridization\";\n out.push(\n ` ${profile.authority} ${stance}; classical public-key crypto disallowed after ${profile.disallowAfter} (${profile.citation}).`,\n );\n return out;\n}\n"]}
@@ -13,7 +13,7 @@ import * as path from "node:path";
13
13
  import { parentPort, workerData } from "node:worker_threads";
14
14
  import { defaultRegistry } from "./registry.js";
15
15
  import { detectFile } from "./scan.js";
16
- import { looksMinified } from "./walk.js";
16
+ import { isKeystorePath, looksMinified } from "./walk.js";
17
17
  import { isManifestFile } from "./dependencies.js";
18
18
  if (parentPort) {
19
19
  const data = (workerData ?? {});
@@ -30,15 +30,17 @@ if (parentPort) {
30
30
  const scannedNames = [];
31
31
  for (const rel of req.files) {
32
32
  const abs = path.join(baseDir, ...rel.split("/"));
33
+ // Keystores (.jks/.p12/…) are read byte-preserving (latin1); see scan.ts.
34
+ const keystore = isKeystorePath(rel);
33
35
  let content;
34
36
  try {
35
- content = readFileSync(abs, "utf8");
37
+ content = readFileSync(abs, keystore ? "latin1" : "utf8");
36
38
  }
37
39
  catch {
38
40
  unreadable += 1;
39
41
  continue;
40
42
  }
41
- if (!toggles.scanMinified && !isManifestFile(rel) && looksMinified(content)) {
43
+ if (!toggles.scanMinified && !isManifestFile(rel) && !keystore && looksMinified(content)) {
42
44
  skippedMinified += 1;
43
45
  continue;
44
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scan-worker.js","sourceRoot":"","sources":["../src/scan-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAenD,IAAI,UAAU,EAAE,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,UAAU,IAAI,EAAE,CAAgD,CAAC;IAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,UAAU,CAAC;IAExB,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAiB,EAAE,EAAE;QACvC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAc,EAAE,CAAC;YAC/B,IAAI,YAAY,GAAG,CAAC,CAAC;YACrB,IAAI,UAAU,GAAG,CAAC,CAAC;YACnB,IAAI,eAAe,GAAG,CAAC,CAAC;YACxB,MAAM,YAAY,GAAa,EAAE,CAAC;YAElC,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;gBAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,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built to `dist/scan-worker.js`\n * and spawned by `parallel.ts`. Each worker reads its assigned files and runs\n * the SAME pure detector pipeline as the serial scan (`detectFile`), returning\n * `{ findings, filesScanned }` per chunk. No shared mutable state.\n *\n * This file performs side effects (wires up message handlers) only when it is\n * actually running inside a worker thread, so importing it from the main thread\n * (e.g. for coverage) is harmless.\n */\nimport { readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { parentPort, workerData } from \"node:worker_threads\";\n\nimport type { Finding } from \"./types.js\";\nimport { defaultRegistry } from \"./registry.js\";\nimport { detectFile } from \"./scan.js\";\nimport { looksMinified } from \"./walk.js\";\nimport { isManifestFile } from \"./dependencies.js\";\n\ninterface WorkerToggles {\n source: boolean;\n config: boolean;\n deps: boolean;\n scanMinified: boolean;\n disabledRules?: string[];\n}\n\ninterface ChunkRequest {\n index: number;\n files: string[];\n}\n\nif (parentPort) {\n const data = (workerData ?? {}) as { baseDir: string; toggles: WorkerToggles };\n const baseDir = data.baseDir;\n const toggles = data.toggles;\n const dets = defaultRegistry.all();\n const port = parentPort;\n\n port.on(\"message\", (req: ChunkRequest) => {\n try {\n const findings: Finding[] = [];\n let filesScanned = 0;\n let unreadable = 0;\n let skippedMinified = 0;\n const scannedNames: string[] = [];\n\n for (const rel of req.files) {\n const abs = path.join(baseDir, ...rel.split(\"/\"));\n let content: string;\n try {\n content = readFileSync(abs, \"utf8\");\n } catch {\n unreadable += 1;\n continue;\n }\n if (!toggles.scanMinified && !isManifestFile(rel) && looksMinified(content)) {\n skippedMinified += 1;\n continue;\n }\n filesScanned += 1;\n scannedNames.push(rel);\n findings.push(\n ...detectFile(\n rel,\n content,\n dets,\n {\n source: toggles.source,\n config: toggles.config,\n deps: toggles.deps,\n },\n toggles.disabledRules,\n ),\n );\n }\n\n port.postMessage({\n index: req.index,\n files: scannedNames,\n result: { findings, filesScanned, unreadable, skippedMinified },\n });\n } catch (err) {\n port.postMessage({\n index: req.index,\n error: err instanceof Error ? err.message : String(err),\n });\n }\n });\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AAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Worker-thread entry for {@link scanParallel}. Built to `dist/scan-worker.js`\n * and spawned by `parallel.ts`. Each worker reads its assigned files and runs\n * the SAME pure detector pipeline as the serial scan (`detectFile`), returning\n * `{ findings, filesScanned }` per chunk. No shared mutable state.\n *\n * This file performs side effects (wires up message handlers) only when it is\n * actually running inside a worker thread, so importing it from the main thread\n * (e.g. for coverage) is harmless.\n */\nimport { readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { parentPort, workerData } from \"node:worker_threads\";\n\nimport type { Finding } from \"./types.js\";\nimport { defaultRegistry } from \"./registry.js\";\nimport { detectFile } from \"./scan.js\";\nimport { isKeystorePath, looksMinified } from \"./walk.js\";\nimport { isManifestFile } from \"./dependencies.js\";\n\ninterface WorkerToggles {\n source: boolean;\n config: boolean;\n deps: boolean;\n scanMinified: boolean;\n disabledRules?: string[];\n}\n\ninterface ChunkRequest {\n index: number;\n files: string[];\n}\n\nif (parentPort) {\n const data = (workerData ?? {}) as { baseDir: string; toggles: WorkerToggles };\n const baseDir = data.baseDir;\n const toggles = data.toggles;\n const dets = defaultRegistry.all();\n const port = parentPort;\n\n port.on(\"message\", (req: ChunkRequest) => {\n try {\n const findings: Finding[] = [];\n let filesScanned = 0;\n let unreadable = 0;\n let skippedMinified = 0;\n const scannedNames: string[] = [];\n\n for (const rel of req.files) {\n const abs = path.join(baseDir, ...rel.split(\"/\"));\n // Keystores (.jks/.p12/…) are read byte-preserving (latin1); see scan.ts.\n const keystore = isKeystorePath(rel);\n let content: string;\n try {\n content = readFileSync(abs, keystore ? \"latin1\" : \"utf8\");\n } catch {\n unreadable += 1;\n continue;\n }\n if (!toggles.scanMinified && !isManifestFile(rel) && !keystore && looksMinified(content)) {\n skippedMinified += 1;\n continue;\n }\n filesScanned += 1;\n scannedNames.push(rel);\n findings.push(\n ...detectFile(\n rel,\n content,\n dets,\n {\n source: toggles.source,\n config: toggles.config,\n deps: toggles.deps,\n },\n toggles.disabledRules,\n ),\n );\n }\n\n port.postMessage({\n index: req.index,\n files: scannedNames,\n result: { findings, filesScanned, unreadable, skippedMinified },\n });\n } catch (err) {\n port.postMessage({\n index: req.index,\n error: err instanceof Error ? err.message : String(err),\n });\n }\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAuB7E;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,EAAqB,CAAC;AAEtD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAI9D;AAOD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,EAC5D,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAChC,OAAO,EAAE,CA8BX;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA0IpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,SAAS,CAAC,GAChD,MAAM,EAAE,CAmBV"}
1
+ {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAwC7E;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,EAAqB,CAAC;AAEtD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAI9D;AAOD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,EAC5D,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAChC,OAAO,EAAE,CA8BX;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA4JpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,SAAS,CAAC,GAChD,MAAM,EAAE,CAmBV"}
package/dist/scan.js CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import { readFile, stat } from "node:fs/promises";
13
13
  import * as path from "node:path";
14
- import { walkFiles, toPosix, isBinaryPath, looksMinified, matchesAny } from "./walk.js";
14
+ import { walkFiles, toPosix, isBinaryPath, isKeystorePath, looksMinified, matchesAny, DEFAULT_MAX_FILE_SIZE, } from "./walk.js";
15
15
  import { isAnalyzableSource } from "./detect-utils.js";
16
16
  import { stripCommentFindings, stripIgnoredFindings, stripStringLiteralFindings, } from "./comments.js";
17
17
  /**
@@ -19,7 +19,16 @@ import { stripCommentFindings, stripIgnoredFindings, stripStringLiteralFindings,
19
19
  * A match inside a string (e.g. `t.Error("SigningMethodPS256 …")`) is prose and
20
20
  * is dropped. Rules that legitimately match quoted tokens are NOT listed here.
21
21
  */
22
- const CODE_ONLY_RULES = new Set(["go-jwt-signingmethod"]);
22
+ const CODE_ONLY_RULES = new Set([
23
+ "go-jwt-signingmethod",
24
+ // Identifier-form JWT alg constants (jjwt `SignatureAlgorithm.RS256`, auth0
25
+ // `Algorithm.RSA256`, C# `SecurityAlgorithms.*`, Rust `Algorithm::RS256`). Like the
26
+ // Go rule, these are only meaningful as code; the SAME token inside a string literal
27
+ // (an error message that names/forbids the alg) is prose, not a usage.
28
+ "java-jwt-alg",
29
+ "csharp-jwt-alg",
30
+ "rust-jwt-algorithm",
31
+ ]);
23
32
  import { hashContent, loadCache, rulesetFingerprint, saveCache } from "./cache.js";
24
33
  import { builtinDetectors, defaultRegistry, detectorScope } from "./registry.js";
25
34
  import { isManifestFile, scanManifest } from "./dependencies.js";
@@ -139,22 +148,42 @@ export async function scan(options) {
139
148
  const absPath = singleFileName ? options.root : path.join(baseDir, ...rel.split("/"));
140
149
  const reportedPath = singleFileName ? toPosix(rel) : rel;
141
150
  options.onFile?.(reportedPath);
151
+ // Cryptographic keystores (.jks/.p12/…) are binary; read them byte-preserving
152
+ // (latin1) so the keystore detector can inspect magic bytes.
153
+ const keystore = isKeystorePath(reportedPath);
154
+ // Keystores are read whole into memory as latin1. The walker already caps file
155
+ // size, but the explicit-file-list (incremental) path does not — so stat and
156
+ // skip an oversized binary here to avoid reading a huge encrypted archive
157
+ // (`.gpg`) into a string.
158
+ if (keystore) {
159
+ try {
160
+ const { size } = await stat(absPath);
161
+ if (size > (options.maxFileSize ?? DEFAULT_MAX_FILE_SIZE))
162
+ continue;
163
+ }
164
+ catch {
165
+ unreadable += 1;
166
+ continue;
167
+ }
168
+ }
142
169
  let content;
143
170
  try {
144
- content = await readFile(absPath, "utf8");
171
+ content = await readFile(absPath, keystore ? "latin1" : "utf8");
145
172
  }
146
173
  catch {
147
174
  unreadable += 1; // permissions / vanished / decode failure — tracked, not silent.
148
175
  continue;
149
176
  }
150
177
  // Skip machine-minified / generated content (unless explicitly enabled).
151
- // Manifests are always scanned (their findings are dependency findings).
152
- if (!scanMinified && !isManifestFile(reportedPath) && looksMinified(content)) {
178
+ // Manifests and keystores are always scanned.
179
+ if (!scanMinified && !isManifestFile(reportedPath) && !keystore && looksMinified(content)) {
153
180
  skippedMinified += 1;
154
181
  continue;
155
182
  }
156
183
  // Cumulative-byte budget: enforced once this file's bytes are accounted for.
157
- bytesScanned += Buffer.byteLength(content, "utf8");
184
+ // Use the read encoding so a latin1 keystore is counted at its on-disk size
185
+ // (a utf8 byteLength would double-count every byte ≥ 0x80).
186
+ bytesScanned += Buffer.byteLength(content, keystore ? "latin1" : "utf8");
158
187
  if (typeof maxBytes === "number" && bytesScanned > maxBytes) {
159
188
  throw new BudgetExceededError(`maxBytes budget exceeded (limit: ${maxBytes}).`);
160
189
  }
package/dist/scan.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,C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AkF;AAClF,KAAK,SAAS,CAAC,CAAC,mBAAmB,CAAC,KAAe,EAAE,OAAoB;IACvE,KAAK,MAAM,GAAG,IAAI,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC;QAAE,MAAM,GAAG,CAAC;AACtE,CAAC","sourcesContent":["/**\n * Scan orchestrator. Walks the target (or an explicit file list), runs the\n * applicable detectors over each file, parses dependency manifests, aggregates\n * everything into an inventory, and returns a {@link ScanResult} with timing and\n * the tool version.\n *\n * Detector scope (source vs config) is driven by each {@link Detector}'s\n * declared `scope` (defaulting to \"source\"), not by ruleId prefixes. The\n * detector set comes from {@link defaultRegistry} unless overridden via\n * `options.detectors`.\n */\nimport { readFile, stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport type { Detector, Finding, ScanOptions, ScanResult } from \"./types.js\";\nimport { walkFiles, toPosix, isBinaryPath, looksMinified, matchesAny } from \"./walk.js\";\nimport { isAnalyzableSource } from \"./detect-utils.js\";\nimport {\n stripCommentFindings,\n stripIgnoredFindings,\n stripStringLiteralFindings,\n} from \"./comments.js\";\n\n/**\n * Rules whose token is only meaningful as code, never inside a string literal.\n * A match inside a string (e.g. `t.Error(\"SigningMethodPS256 …\")`) is prose and\n * is dropped. Rules that legitimately match quoted tokens are NOT listed here.\n */\nconst CODE_ONLY_RULES: ReadonlySet<string> = new Set([\"go-jwt-signingmethod\"]);\nimport { hashContent, loadCache, rulesetFingerprint, saveCache } from \"./cache.js\";\nimport type { CacheEntry } from \"./cache.js\";\nimport { builtinDetectors, defaultRegistry, detectorScope } from \"./registry.js\";\nimport { isManifestFile, scanManifest } from \"./dependencies.js\";\nimport { buildInventory } from \"./inventory.js\";\nimport { AbortError, BudgetExceededError } from \"./errors.js\";\nimport { VERSION } from \"./version.js\";\n\n/**\n * The full set of built-in detectors exposed on the public API. Re-exported\n * from {@link builtinDetectors} in `registry.ts` — the single source of truth\n * the {@link defaultRegistry} is also built from — so the public array and the\n * registry can never drift apart. The manifest scanner is handled separately\n * (it parses JSON rather than running a Detector).\n */\nexport const detectors: Detector[] = builtinDetectors;\n\n/** Stable comparator: by file, then line, then ruleId. Exported for reuse. */\nexport function compareFindings(a: Finding, b: Finding): number {\n if (a.location.file !== b.location.file) return a.location.file < b.location.file ? -1 : 1;\n if (a.location.line !== b.location.line) return a.location.line - b.location.line;\n return a.ruleId < b.ruleId ? -1 : a.ruleId > b.ruleId ? 1 : 0;\n}\n\n/** Resolve the active detector list for a scan (override or the default registry). */\nfunction resolveDetectors(options: ScanOptions): Detector[] {\n return options.detectors ?? defaultRegistry.all();\n}\n\n/**\n * Run all applicable detectors + the manifest scanner over a single file's\n * contents, honouring the source / config / dependencies toggles. Pure: no I/O.\n * Exported so the parallel worker and unit tests can drive it directly.\n */\nexport function detectFile(\n file: string,\n content: string,\n dets: readonly Detector[],\n toggles: { source: boolean; config: boolean; deps: boolean },\n disabledRules?: readonly string[],\n): Finding[] {\n let out: Finding[] = [];\n\n for (const det of dets) {\n if (!det.appliesTo(file)) continue;\n const isConfig = detectorScope(det) === \"config\";\n if (isConfig ? !toggles.config : !toggles.source) continue;\n out.push(...det.detect({ file, content }));\n }\n\n // Drop lexical false positives that land inside comments (`// migrated off\n // createECDH()`), then honour inline `// qscan-ignore-line` /\n // `qscan-ignore-next-line` directives. Both run before the dependency scan\n // appends its findings (manifests carry neither).\n out = stripCommentFindings(out, content, file);\n out = stripStringLiteralFindings(out, content, file, CODE_ONLY_RULES);\n out = stripIgnoredFindings(out, content);\n\n if (toggles.deps && isManifestFile(file)) {\n out.push(...scanManifest(file, content));\n }\n\n // Per-rule suppression: drop findings whose ruleId was disabled. Applied here\n // so both the serial scan and the worker path honour it identically.\n if (disabledRules && disabledRules.length > 0) {\n const disabled = new Set(disabledRules);\n return out.filter((f) => !disabled.has(f.ruleId));\n }\n\n return out;\n}\n\n/**\n * Recursively scan a directory (or single file, or explicit file list) for\n * classical asymmetric crypto. Honours the source / dependencies / config\n * toggles (all default true) and reports progress through `options.onFile`.\n */\nexport async function scan(options: ScanOptions): Promise<ScanResult> {\n const startedAt = new Date();\n\n const doSource = options.source !== false;\n const doDeps = options.dependencies !== false;\n const doConfig = options.config !== false;\n const scanMinified = options.scanMinified === true;\n const dets = resolveDetectors(options);\n\n // Resolve whether the root is a file so we can rebuild absolute paths to read.\n const rootStat = await stat(options.root);\n const rootIsFile = rootStat.isFile();\n const baseDir = rootIsFile ? path.dirname(options.root) : options.root;\n const singleFileName = rootIsFile ? path.basename(options.root) : null;\n\n const findings: Finding[] = [];\n let filesScanned = 0;\n let analyzedFiles = 0;\n let bytesScanned = 0;\n let unreadable = 0;\n let skippedMinified = 0;\n\n // Optional content-hash scan cache: unchanged files reuse prior findings.\n const cacheFile = options.cacheFile;\n const ruleset = cacheFile ? rulesetFingerprint(dets, options.disabledRules) : \"\";\n const cache = cacheFile ? await loadCache(cacheFile, ruleset) : null;\n // A full scan starts with an empty next-cache so files that vanished are\n // evicted. An INCREMENTAL scan (explicit `files` list) only visits a subset,\n // so seed the next-cache with the existing entries — otherwise saving would\n // drop every file we didn't happen to scan this run (audit: arch #4).\n const incremental = Array.isArray(options.files);\n const nextEntries: Map<string, CacheEntry> | null = cacheFile\n ? new Map(incremental && cache ? cache : [])\n : null;\n\n // Work-budget / cancellation controls (all optional, unlimited when omitted).\n const signal = options.signal;\n const maxFiles = options.maxFiles;\n const maxBytes = options.maxBytes;\n\n // Source of relative paths: an explicit file list (incremental) or the walker.\n const relPaths: AsyncIterable<string> = options.files\n ? filterExplicitFiles(options.files, options)\n : walkFiles(options.root, {\n include: options.include,\n exclude: options.exclude,\n noDefaultIgnores: options.noDefaultIgnores,\n maxFileSize: options.maxFileSize,\n });\n\n for await (const rel of relPaths) {\n // Cooperative cancellation: check the signal at the top of every iteration.\n if (signal?.aborted) throw new AbortError();\n\n // File-count budget: enforced before reading the next file.\n if (typeof maxFiles === \"number\" && filesScanned >= maxFiles) {\n throw new BudgetExceededError(`maxFiles budget exceeded (limit: ${maxFiles}).`);\n }\n\n // In single-file mode, walkFiles yields the basename; map back to the file.\n const absPath = singleFileName ? options.root : path.join(baseDir, ...rel.split(\"/\"));\n const reportedPath = singleFileName ? toPosix(rel) : rel;\n\n options.onFile?.(reportedPath);\n\n let content: string;\n try {\n content = await readFile(absPath, \"utf8\");\n } catch {\n unreadable += 1; // permissions / vanished / decode failure — tracked, not silent.\n continue;\n }\n\n // Skip machine-minified / generated content (unless explicitly enabled).\n // Manifests are always scanned (their findings are dependency findings).\n if (!scanMinified && !isManifestFile(reportedPath) && looksMinified(content)) {\n skippedMinified += 1;\n continue;\n }\n\n // Cumulative-byte budget: enforced once this file's bytes are accounted for.\n bytesScanned += Buffer.byteLength(content, \"utf8\");\n if (typeof maxBytes === \"number\" && bytesScanned > maxBytes) {\n throw new BudgetExceededError(`maxBytes budget exceeded (limit: ${maxBytes}).`);\n }\n\n filesScanned += 1;\n if (isAnalyzableSource(reportedPath)) analyzedFiles += 1;\n\n // Cache: reuse prior findings when the content hash matches; otherwise scan\n // and record. `nextEntries` becomes the new cache (dropping vanished files).\n let fileFindings: Finding[];\n if (cache && nextEntries) {\n const hash = hashContent(content);\n const hit = cache.get(reportedPath);\n fileFindings =\n hit && hit.hash === hash\n ? hit.findings\n : detectFile(\n reportedPath,\n content,\n dets,\n { source: doSource, config: doConfig, deps: doDeps },\n options.disabledRules,\n );\n nextEntries.set(reportedPath, { hash, findings: fileFindings });\n } else {\n fileFindings = detectFile(\n reportedPath,\n content,\n dets,\n { source: doSource, config: doConfig, deps: doDeps },\n options.disabledRules,\n );\n }\n findings.push(...fileFindings);\n }\n\n // Persist the cache (best effort) before ordering/returning.\n if (cacheFile && nextEntries) await saveCache(cacheFile, ruleset, nextEntries);\n\n // Stable ordering: by file, then line, then ruleId.\n findings.sort(compareFindings);\n\n const inventory = buildInventory(findings);\n const finishedAt = new Date();\n\n return {\n root: options.root,\n findings,\n filesScanned,\n analyzedFiles,\n diagnostics: { unreadable, skippedMinified },\n inventory,\n startedAt: startedAt.toISOString(),\n finishedAt: finishedAt.toISOString(),\n toolVersion: VERSION,\n };\n}\n\n/**\n * Filter an explicit relative file list down to the paths that pass the binary\n * filter and the include/exclude patterns, returning them deduped and sorted for\n * deterministic output. Size limits are enforced later (we still read manifests\n * over the cap). Non-existent files are simply skipped at read time.\n *\n * Pure + synchronous, and exported so the parallel enumerator applies the EXACT\n * same filtering for explicit file lists as the serial path (byte-for-byte\n * identical results under `--parallel`).\n */\nexport function filterExplicitFileList(\n files: readonly string[],\n options: Pick<ScanOptions, \"include\" | \"exclude\">,\n): string[] {\n const include = options.include ?? [];\n const exclude = options.exclude ?? [];\n const seen = new Set<string>();\n const list = [...files]\n .map((f) => toPosix(f))\n .filter((f) => {\n if (seen.has(f)) return false;\n seen.add(f);\n return true;\n })\n .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n\n return list.filter((rel) => {\n if (isBinaryPath(rel)) return false;\n if (include.length > 0 && !matchesAny(rel, include)) return false;\n if (matchesAny(rel, exclude)) return false;\n return true;\n });\n}\n\n/** Async-generator wrapper around {@link filterExplicitFileList} for `scan()`. */\nasync function* filterExplicitFiles(files: string[], options: ScanOptions): AsyncGenerator<string> {\n for (const rel of filterExplicitFileList(files, options)) yield rel;\n}\n"]}
1
+ {"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EACL,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,EACV,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,MAAM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/B,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;SACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACZ,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QACzB,IAAI,YAAY,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACpC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QAClE,IAAI,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,KAAK,SAAS,CAAC,CAAC,mBAAmB,CAAC,KAAe,EAAE,OAAoB;IACvE,KAAK,MAAM,GAAG,IAAI,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC;QAAE,MAAM,GAAG,CAAC;AACtE,CAAC","sourcesContent":["/**\n * Scan orchestrator. Walks the target (or an explicit file list), runs the\n * applicable detectors over each file, parses dependency manifests, aggregates\n * everything into an inventory, and returns a {@link ScanResult} with timing and\n * the tool version.\n *\n * Detector scope (source vs config) is driven by each {@link Detector}'s\n * declared `scope` (defaulting to \"source\"), not by ruleId prefixes. The\n * detector set comes from {@link defaultRegistry} unless overridden via\n * `options.detectors`.\n */\nimport { readFile, stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport type { Detector, Finding, ScanOptions, ScanResult } from \"./types.js\";\nimport {\n walkFiles,\n toPosix,\n isBinaryPath,\n isKeystorePath,\n looksMinified,\n matchesAny,\n DEFAULT_MAX_FILE_SIZE,\n} from \"./walk.js\";\nimport { isAnalyzableSource } from \"./detect-utils.js\";\nimport {\n stripCommentFindings,\n stripIgnoredFindings,\n stripStringLiteralFindings,\n} from \"./comments.js\";\n\n/**\n * Rules whose token is only meaningful as code, never inside a string literal.\n * A match inside a string (e.g. `t.Error(\"SigningMethodPS256 …\")`) is prose and\n * is dropped. Rules that legitimately match quoted tokens are NOT listed here.\n */\nconst CODE_ONLY_RULES: ReadonlySet<string> = new Set([\n \"go-jwt-signingmethod\",\n // Identifier-form JWT alg constants (jjwt `SignatureAlgorithm.RS256`, auth0\n // `Algorithm.RSA256`, C# `SecurityAlgorithms.*`, Rust `Algorithm::RS256`). Like the\n // Go rule, these are only meaningful as code; the SAME token inside a string literal\n // (an error message that names/forbids the alg) is prose, not a usage.\n \"java-jwt-alg\",\n \"csharp-jwt-alg\",\n \"rust-jwt-algorithm\",\n]);\nimport { hashContent, loadCache, rulesetFingerprint, saveCache } from \"./cache.js\";\nimport type { CacheEntry } from \"./cache.js\";\nimport { builtinDetectors, defaultRegistry, detectorScope } from \"./registry.js\";\nimport { isManifestFile, scanManifest } from \"./dependencies.js\";\nimport { buildInventory } from \"./inventory.js\";\nimport { AbortError, BudgetExceededError } from \"./errors.js\";\nimport { VERSION } from \"./version.js\";\n\n/**\n * The full set of built-in detectors exposed on the public API. Re-exported\n * from {@link builtinDetectors} in `registry.ts` — the single source of truth\n * the {@link defaultRegistry} is also built from — so the public array and the\n * registry can never drift apart. The manifest scanner is handled separately\n * (it parses JSON rather than running a Detector).\n */\nexport const detectors: Detector[] = builtinDetectors;\n\n/** Stable comparator: by file, then line, then ruleId. Exported for reuse. */\nexport function compareFindings(a: Finding, b: Finding): number {\n if (a.location.file !== b.location.file) return a.location.file < b.location.file ? -1 : 1;\n if (a.location.line !== b.location.line) return a.location.line - b.location.line;\n return a.ruleId < b.ruleId ? -1 : a.ruleId > b.ruleId ? 1 : 0;\n}\n\n/** Resolve the active detector list for a scan (override or the default registry). */\nfunction resolveDetectors(options: ScanOptions): Detector[] {\n return options.detectors ?? defaultRegistry.all();\n}\n\n/**\n * Run all applicable detectors + the manifest scanner over a single file's\n * contents, honouring the source / config / dependencies toggles. Pure: no I/O.\n * Exported so the parallel worker and unit tests can drive it directly.\n */\nexport function detectFile(\n file: string,\n content: string,\n dets: readonly Detector[],\n toggles: { source: boolean; config: boolean; deps: boolean },\n disabledRules?: readonly string[],\n): Finding[] {\n let out: Finding[] = [];\n\n for (const det of dets) {\n if (!det.appliesTo(file)) continue;\n const isConfig = detectorScope(det) === \"config\";\n if (isConfig ? !toggles.config : !toggles.source) continue;\n out.push(...det.detect({ file, content }));\n }\n\n // Drop lexical false positives that land inside comments (`// migrated off\n // createECDH()`), then honour inline `// qscan-ignore-line` /\n // `qscan-ignore-next-line` directives. Both run before the dependency scan\n // appends its findings (manifests carry neither).\n out = stripCommentFindings(out, content, file);\n out = stripStringLiteralFindings(out, content, file, CODE_ONLY_RULES);\n out = stripIgnoredFindings(out, content);\n\n if (toggles.deps && isManifestFile(file)) {\n out.push(...scanManifest(file, content));\n }\n\n // Per-rule suppression: drop findings whose ruleId was disabled. Applied here\n // so both the serial scan and the worker path honour it identically.\n if (disabledRules && disabledRules.length > 0) {\n const disabled = new Set(disabledRules);\n return out.filter((f) => !disabled.has(f.ruleId));\n }\n\n return out;\n}\n\n/**\n * Recursively scan a directory (or single file, or explicit file list) for\n * classical asymmetric crypto. Honours the source / dependencies / config\n * toggles (all default true) and reports progress through `options.onFile`.\n */\nexport async function scan(options: ScanOptions): Promise<ScanResult> {\n const startedAt = new Date();\n\n const doSource = options.source !== false;\n const doDeps = options.dependencies !== false;\n const doConfig = options.config !== false;\n const scanMinified = options.scanMinified === true;\n const dets = resolveDetectors(options);\n\n // Resolve whether the root is a file so we can rebuild absolute paths to read.\n const rootStat = await stat(options.root);\n const rootIsFile = rootStat.isFile();\n const baseDir = rootIsFile ? path.dirname(options.root) : options.root;\n const singleFileName = rootIsFile ? path.basename(options.root) : null;\n\n const findings: Finding[] = [];\n let filesScanned = 0;\n let analyzedFiles = 0;\n let bytesScanned = 0;\n let unreadable = 0;\n let skippedMinified = 0;\n\n // Optional content-hash scan cache: unchanged files reuse prior findings.\n const cacheFile = options.cacheFile;\n const ruleset = cacheFile ? rulesetFingerprint(dets, options.disabledRules) : \"\";\n const cache = cacheFile ? await loadCache(cacheFile, ruleset) : null;\n // A full scan starts with an empty next-cache so files that vanished are\n // evicted. An INCREMENTAL scan (explicit `files` list) only visits a subset,\n // so seed the next-cache with the existing entries — otherwise saving would\n // drop every file we didn't happen to scan this run (audit: arch #4).\n const incremental = Array.isArray(options.files);\n const nextEntries: Map<string, CacheEntry> | null = cacheFile\n ? new Map(incremental && cache ? cache : [])\n : null;\n\n // Work-budget / cancellation controls (all optional, unlimited when omitted).\n const signal = options.signal;\n const maxFiles = options.maxFiles;\n const maxBytes = options.maxBytes;\n\n // Source of relative paths: an explicit file list (incremental) or the walker.\n const relPaths: AsyncIterable<string> = options.files\n ? filterExplicitFiles(options.files, options)\n : walkFiles(options.root, {\n include: options.include,\n exclude: options.exclude,\n noDefaultIgnores: options.noDefaultIgnores,\n maxFileSize: options.maxFileSize,\n });\n\n for await (const rel of relPaths) {\n // Cooperative cancellation: check the signal at the top of every iteration.\n if (signal?.aborted) throw new AbortError();\n\n // File-count budget: enforced before reading the next file.\n if (typeof maxFiles === \"number\" && filesScanned >= maxFiles) {\n throw new BudgetExceededError(`maxFiles budget exceeded (limit: ${maxFiles}).`);\n }\n\n // In single-file mode, walkFiles yields the basename; map back to the file.\n const absPath = singleFileName ? options.root : path.join(baseDir, ...rel.split(\"/\"));\n const reportedPath = singleFileName ? toPosix(rel) : rel;\n\n options.onFile?.(reportedPath);\n\n // Cryptographic keystores (.jks/.p12/…) are binary; read them byte-preserving\n // (latin1) so the keystore detector can inspect magic bytes.\n const keystore = isKeystorePath(reportedPath);\n // Keystores are read whole into memory as latin1. The walker already caps file\n // size, but the explicit-file-list (incremental) path does not — so stat and\n // skip an oversized binary here to avoid reading a huge encrypted archive\n // (`.gpg`) into a string.\n if (keystore) {\n try {\n const { size } = await stat(absPath);\n if (size > (options.maxFileSize ?? DEFAULT_MAX_FILE_SIZE)) continue;\n } catch {\n unreadable += 1;\n continue;\n }\n }\n let content: string;\n try {\n content = await readFile(absPath, keystore ? \"latin1\" : \"utf8\");\n } catch {\n unreadable += 1; // permissions / vanished / decode failure — tracked, not silent.\n continue;\n }\n\n // Skip machine-minified / generated content (unless explicitly enabled).\n // Manifests and keystores are always scanned.\n if (!scanMinified && !isManifestFile(reportedPath) && !keystore && looksMinified(content)) {\n skippedMinified += 1;\n continue;\n }\n\n // Cumulative-byte budget: enforced once this file's bytes are accounted for.\n // Use the read encoding so a latin1 keystore is counted at its on-disk size\n // (a utf8 byteLength would double-count every byte ≥ 0x80).\n bytesScanned += Buffer.byteLength(content, keystore ? \"latin1\" : \"utf8\");\n if (typeof maxBytes === \"number\" && bytesScanned > maxBytes) {\n throw new BudgetExceededError(`maxBytes budget exceeded (limit: ${maxBytes}).`);\n }\n\n filesScanned += 1;\n if (isAnalyzableSource(reportedPath)) analyzedFiles += 1;\n\n // Cache: reuse prior findings when the content hash matches; otherwise scan\n // and record. `nextEntries` becomes the new cache (dropping vanished files).\n let fileFindings: Finding[];\n if (cache && nextEntries) {\n const hash = hashContent(content);\n const hit = cache.get(reportedPath);\n fileFindings =\n hit && hit.hash === hash\n ? hit.findings\n : detectFile(\n reportedPath,\n content,\n dets,\n { source: doSource, config: doConfig, deps: doDeps },\n options.disabledRules,\n );\n nextEntries.set(reportedPath, { hash, findings: fileFindings });\n } else {\n fileFindings = detectFile(\n reportedPath,\n content,\n dets,\n { source: doSource, config: doConfig, deps: doDeps },\n options.disabledRules,\n );\n }\n findings.push(...fileFindings);\n }\n\n // Persist the cache (best effort) before ordering/returning.\n if (cacheFile && nextEntries) await saveCache(cacheFile, ruleset, nextEntries);\n\n // Stable ordering: by file, then line, then ruleId.\n findings.sort(compareFindings);\n\n const inventory = buildInventory(findings);\n const finishedAt = new Date();\n\n return {\n root: options.root,\n findings,\n filesScanned,\n analyzedFiles,\n diagnostics: { unreadable, skippedMinified },\n inventory,\n startedAt: startedAt.toISOString(),\n finishedAt: finishedAt.toISOString(),\n toolVersion: VERSION,\n };\n}\n\n/**\n * Filter an explicit relative file list down to the paths that pass the binary\n * filter and the include/exclude patterns, returning them deduped and sorted for\n * deterministic output. Size limits are enforced later (we still read manifests\n * over the cap). Non-existent files are simply skipped at read time.\n *\n * Pure + synchronous, and exported so the parallel enumerator applies the EXACT\n * same filtering for explicit file lists as the serial path (byte-for-byte\n * identical results under `--parallel`).\n */\nexport function filterExplicitFileList(\n files: readonly string[],\n options: Pick<ScanOptions, \"include\" | \"exclude\">,\n): string[] {\n const include = options.include ?? [];\n const exclude = options.exclude ?? [];\n const seen = new Set<string>();\n const list = [...files]\n .map((f) => toPosix(f))\n .filter((f) => {\n if (seen.has(f)) return false;\n seen.add(f);\n return true;\n })\n .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n\n return list.filter((rel) => {\n if (isBinaryPath(rel)) return false;\n if (include.length > 0 && !matchesAny(rel, include)) return false;\n if (matchesAny(rel, exclude)) return false;\n return true;\n });\n}\n\n/** Async-generator wrapper around {@link filterExplicitFileList} for `scan()`. */\nasync function* filterExplicitFiles(files: string[], options: ScanOptions): AsyncGenerator<string> {\n for (const rel of filterExplicitFileList(files, options)) yield rel;\n}\n"]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Selectable STANDARDS PROFILES — the regime a scan's remediation, deadlines, and
3
+ * hybrid guidance are tailored to. Different national/regional authorities agree on
4
+ * the PQC primitives (ML-KEM / ML-DSA) but diverge on two things this tool must not
5
+ * hardcode: (a) the required PARAMETER SETS (a commercial ML-KEM-768 vs a
6
+ * national-security ML-KEM-1024), and (b) the HYBRID STANCE — whether classical+PQC
7
+ * hybridization is required, recommended, or optional during the transition. Baking
8
+ * in NIST/CNSA's "hybrids optional" is wrong for an ANSSI or BSI audience, where
9
+ * hybrid is required. `--profile <id>` selects the regime; `--policy` composes an
10
+ * org's own exceptions on top.
11
+ *
12
+ * Like {@link PqcStandards}, every profile carries a citation + `asOf` date and is
13
+ * re-verified on the quarterly standards cadence. These are guidance summaries, not
14
+ * legal advice — consult the cited source of record.
15
+ */
16
+ /** Whether classical+PQC hybridization is required during the transition, per regime. */
17
+ export type HybridStance = "required" | "recommended" | "optional";
18
+ /** A regime's PQC guidance profile. */
19
+ export interface StandardsProfile {
20
+ /** Stable id used by `--profile` (kebab-case). */
21
+ readonly id: string;
22
+ /** Human-readable name. */
23
+ readonly name: string;
24
+ /** The authority / document of record. */
25
+ readonly authority: string;
26
+ /** The KEM / signature parameter sets this regime calls for. */
27
+ readonly paramSets: {
28
+ readonly kem: string;
29
+ readonly signature: string;
30
+ };
31
+ /** Whether hybridization is required / recommended / optional under this regime. */
32
+ readonly hybridStance: HybridStance;
33
+ /** One-line regime-specific hybrid guidance surfaced in remediation. */
34
+ readonly hybridGuidance: string;
35
+ /** Year after which classical public-key crypto is deprecated under this regime. */
36
+ readonly deprecateAfter: number;
37
+ /** Year after which it is disallowed. */
38
+ readonly disallowAfter: number;
39
+ /** Spec identifier / publication of record. */
40
+ readonly citation: string;
41
+ /** `YYYY-MM` — when this profile was last verified against its source. */
42
+ readonly asOf: string;
43
+ }
44
+ /** The default profile id when `--profile` is not given. */
45
+ export declare const DEFAULT_PROFILE_ID = "nist";
46
+ /**
47
+ * Built-in regime profiles. Facts reflect each authority's published PQC-transition
48
+ * position as of the `asOf` date; verify against the cited source before relying on a
49
+ * deadline or a hybrid mandate for a compliance decision.
50
+ */
51
+ export declare const STANDARDS_PROFILES: Readonly<Record<string, StandardsProfile>>;
52
+ /** All built-in profile ids, in a stable order (default first). */
53
+ export declare function standardsProfileIds(): string[];
54
+ /** Look up a built-in profile by id, or `undefined` when unknown. */
55
+ export declare function getStandardsProfile(id: string): StandardsProfile | undefined;
56
+ /** The default profile (NIST). Always defined. */
57
+ export declare function defaultStandardsProfile(): StandardsProfile;
58
+ //# sourceMappingURL=standards-profiles.d.ts.map