pqaudit 0.2.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +176 -22
  2. package/dist/cli.js +89 -25
  3. package/dist/cli.js.map +1 -1
  4. package/dist/grammars/tree-sitter-javascript.wasm +0 -0
  5. package/dist/grammars/tree-sitter-tsx.wasm +0 -0
  6. package/dist/grammars/tree-sitter-typescript.wasm +0 -0
  7. package/dist/policy/evaluator.d.ts +11 -0
  8. package/dist/policy/evaluator.d.ts.map +1 -0
  9. package/dist/policy/evaluator.js +75 -0
  10. package/dist/policy/evaluator.js.map +1 -0
  11. package/dist/policy/loader.d.ts +10 -0
  12. package/dist/policy/loader.d.ts.map +1 -0
  13. package/dist/policy/loader.js +55 -0
  14. package/dist/policy/loader.js.map +1 -0
  15. package/dist/reporter/cbom.d.ts.map +1 -1
  16. package/dist/reporter/cbom.js +2 -1
  17. package/dist/reporter/cbom.js.map +1 -1
  18. package/dist/reporter/html.d.ts +7 -0
  19. package/dist/reporter/html.d.ts.map +1 -0
  20. package/dist/reporter/html.js +415 -0
  21. package/dist/reporter/html.js.map +1 -0
  22. package/dist/reporter/sarif.d.ts.map +1 -1
  23. package/dist/reporter/sarif.js +2 -1
  24. package/dist/reporter/sarif.js.map +1 -1
  25. package/dist/reporter/text.d.ts.map +1 -1
  26. package/dist/reporter/text.js +16 -0
  27. package/dist/reporter/text.js.map +1 -1
  28. package/dist/sbom/enricher.d.ts +4 -0
  29. package/dist/sbom/enricher.d.ts.map +1 -0
  30. package/dist/sbom/enricher.js +144 -0
  31. package/dist/sbom/enricher.js.map +1 -0
  32. package/dist/sbom/parser.d.ts +4 -0
  33. package/dist/sbom/parser.d.ts.map +1 -0
  34. package/dist/sbom/parser.js +49 -0
  35. package/dist/sbom/parser.js.map +1 -0
  36. package/dist/scanner/ast-patterns.d.ts +40 -0
  37. package/dist/scanner/ast-patterns.d.ts.map +1 -0
  38. package/dist/scanner/ast-patterns.js +71 -0
  39. package/dist/scanner/ast-patterns.js.map +1 -0
  40. package/dist/scanner/ast-scanner.d.ts +8 -0
  41. package/dist/scanner/ast-scanner.d.ts.map +1 -0
  42. package/dist/scanner/ast-scanner.js +305 -0
  43. package/dist/scanner/ast-scanner.js.map +1 -0
  44. package/dist/scanner/certificate-scanner.d.ts +38 -0
  45. package/dist/scanner/certificate-scanner.d.ts.map +1 -0
  46. package/dist/scanner/certificate-scanner.js +241 -0
  47. package/dist/scanner/certificate-scanner.js.map +1 -0
  48. package/dist/scanner/dependency-scanner.d.ts +4 -0
  49. package/dist/scanner/dependency-scanner.d.ts.map +1 -1
  50. package/dist/scanner/dependency-scanner.js +477 -1
  51. package/dist/scanner/dependency-scanner.js.map +1 -1
  52. package/dist/scanner/engine.d.ts.map +1 -1
  53. package/dist/scanner/engine.js +84 -11
  54. package/dist/scanner/engine.js.map +1 -1
  55. package/dist/scanner/file-scanner.d.ts +16 -1
  56. package/dist/scanner/file-scanner.d.ts.map +1 -1
  57. package/dist/scanner/file-scanner.js +155 -42
  58. package/dist/scanner/file-scanner.js.map +1 -1
  59. package/dist/scanner/network-scanner.d.ts +26 -0
  60. package/dist/scanner/network-scanner.d.ts.map +1 -0
  61. package/dist/scanner/network-scanner.js +500 -0
  62. package/dist/scanner/network-scanner.js.map +1 -0
  63. package/dist/scanner/rules.d.ts +4 -0
  64. package/dist/scanner/rules.d.ts.map +1 -1
  65. package/dist/scanner/rules.js +26 -2
  66. package/dist/scanner/rules.js.map +1 -1
  67. package/dist/scanner/suppress.d.ts +3 -0
  68. package/dist/scanner/suppress.d.ts.map +1 -0
  69. package/dist/scanner/suppress.js +38 -0
  70. package/dist/scanner/suppress.js.map +1 -0
  71. package/dist/types.d.ts +76 -1
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/types.js.map +1 -1
  74. package/dist/version.d.ts +3 -0
  75. package/dist/version.d.ts.map +1 -0
  76. package/dist/version.js +13 -0
  77. package/dist/version.js.map +1 -0
  78. package/package.json +10 -6
  79. package/policies/cnsa-2.0.yaml +63 -0
  80. package/policies/eu-pqc-roadmap.yaml +48 -0
  81. package/policies/nist-ir-8547.yaml +69 -0
  82. package/rules/crypto-patterns.yaml +517 -143
@@ -0,0 +1,144 @@
1
+ /** Enrich an SBOM with cryptographic findings from the scan */
2
+ export function enrichSbom(sbom, findings) {
3
+ if (sbom.format === "cyclonedx") {
4
+ return enrichCycloneDX(sbom.raw, findings);
5
+ }
6
+ return enrichSPDX(sbom.raw, findings);
7
+ }
8
+ function enrichCycloneDX(raw, findings) {
9
+ const output = { ...raw };
10
+ const components = [...(raw.components ?? [])];
11
+ const matched = new Set();
12
+ // Try to match findings to existing components
13
+ for (const finding of findings) {
14
+ let foundMatch = false;
15
+ for (let i = 0; i < components.length; i++) {
16
+ const comp = components[i];
17
+ if (componentMatchesFinding(comp, finding)) {
18
+ // Enrich existing component
19
+ components[i] = addCryptoToComponent(comp, finding);
20
+ matched.add(i);
21
+ foundMatch = true;
22
+ break;
23
+ }
24
+ }
25
+ // If no match, add as new crypto-asset component
26
+ if (!foundMatch) {
27
+ components.push(makeCryptoComponent(finding));
28
+ }
29
+ }
30
+ output.components = components;
31
+ return output;
32
+ }
33
+ function enrichSPDX(raw, findings) {
34
+ const output = { ...raw };
35
+ const packages = [...(raw.packages ?? [])];
36
+ // Add crypto findings as annotations/external refs on matched packages
37
+ for (const finding of findings) {
38
+ let foundMatch = false;
39
+ for (let i = 0; i < packages.length; i++) {
40
+ const pkg = packages[i];
41
+ const refs = (pkg.externalRefs ?? []);
42
+ const purlRef = refs.find((r) => r.referenceType === "purl");
43
+ if (purlRef && findingMatchesPurl(purlRef.referenceLocator, finding)) {
44
+ // Add pqaudit annotation
45
+ packages[i] = addAnnotationToPackage(pkg, finding);
46
+ foundMatch = true;
47
+ break;
48
+ }
49
+ }
50
+ if (!foundMatch) {
51
+ packages.push(makeSpdxCryptoPackage(finding));
52
+ }
53
+ }
54
+ output.packages = packages;
55
+ return output;
56
+ }
57
+ function componentMatchesFinding(comp, finding) {
58
+ const purl = String(comp.purl ?? "").toLowerCase();
59
+ const name = String(comp.name ?? "").toLowerCase();
60
+ const algo = finding.algorithm.toLowerCase();
61
+ // Match by PURL containing algorithm-related package name
62
+ if (purl && findingMatchesPurl(purl, finding))
63
+ return true;
64
+ // Match by component name containing algorithm
65
+ if (name.includes(algo) || algo.includes(name))
66
+ return true;
67
+ return false;
68
+ }
69
+ function findingMatchesPurl(purl, finding) {
70
+ const p = purl.toLowerCase();
71
+ const algo = finding.algorithm.toLowerCase();
72
+ // Check if the PURL package name relates to the finding
73
+ if (p.includes(algo))
74
+ return true;
75
+ if (algo === "rsa" && p.includes("rsa"))
76
+ return true;
77
+ if (algo.includes("ecdsa") && (p.includes("ecdsa") || p.includes("secp256")))
78
+ return true;
79
+ if (algo.includes("ed25519") && p.includes("ed25519"))
80
+ return true;
81
+ return false;
82
+ }
83
+ function addCryptoToComponent(comp, finding) {
84
+ const props = (comp.properties ?? []).slice();
85
+ props.push({ name: "pqaudit:severity", value: finding.severity }, { name: "pqaudit:algorithm", value: finding.algorithm }, { name: "pqaudit:confidence", value: String(finding.confidence) }, { name: "pqaudit:replacement", value: finding.replacement ?? "none" });
86
+ return {
87
+ ...comp,
88
+ properties: props,
89
+ cryptoProperties: {
90
+ assetType: "algorithm",
91
+ algorithmProperties: {
92
+ variant: finding.algorithm,
93
+ },
94
+ },
95
+ };
96
+ }
97
+ function makeCryptoComponent(finding) {
98
+ return {
99
+ type: "crypto-asset",
100
+ name: finding.algorithm,
101
+ description: finding.description,
102
+ cryptoProperties: {
103
+ assetType: finding.category === "protocol" ? "protocol" : "algorithm",
104
+ algorithmProperties: {
105
+ variant: finding.algorithm,
106
+ },
107
+ },
108
+ evidence: {
109
+ occurrences: [
110
+ {
111
+ location: finding.location.file,
112
+ line: finding.location.line,
113
+ symbol: finding.location.snippet,
114
+ },
115
+ ],
116
+ },
117
+ properties: [
118
+ { name: "pqaudit:severity", value: finding.severity },
119
+ { name: "pqaudit:confidence", value: String(finding.confidence) },
120
+ { name: "pqaudit:detectionMethod", value: finding.detectionMethod },
121
+ { name: "pqaudit:replacement", value: finding.replacement ?? "none" },
122
+ ],
123
+ };
124
+ }
125
+ function addAnnotationToPackage(pkg, finding) {
126
+ const comment = String(pkg.comment ?? "");
127
+ const annotation = `[pqaudit] ${finding.severity}: ${finding.algorithm} — ${finding.description}. Replace with: ${finding.replacement ?? "N/A"}`;
128
+ return {
129
+ ...pkg,
130
+ comment: comment ? `${comment}\n${annotation}` : annotation,
131
+ };
132
+ }
133
+ function makeSpdxCryptoPackage(finding) {
134
+ return {
135
+ SPDXID: `SPDXRef-pqaudit-${finding.ruleId}-${Date.now()}`,
136
+ name: `crypto:${finding.algorithm}`,
137
+ versionInfo: "",
138
+ downloadLocation: "NOASSERTION",
139
+ filesAnalyzed: false,
140
+ description: `[pqaudit] ${finding.description}`,
141
+ comment: `Severity: ${finding.severity}. Confidence: ${finding.confidence}. Replace with: ${finding.replacement ?? "N/A"}`,
142
+ };
143
+ }
144
+ //# sourceMappingURL=enricher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enricher.js","sourceRoot":"","sources":["../../src/sbom/enricher.ts"],"names":[],"mappings":"AAEA,+DAA+D;AAC/D,MAAM,UAAU,UAAU,CACxB,IAAkB,EAClB,QAAmB;IAEnB,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,eAAe,CAAC,IAAI,CAAC,GAA8B,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,GAA8B,EAAE,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,eAAe,CACtB,GAA4B,EAC5B,QAAmB;IAEnB,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,CAAC,GAAI,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CA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AAC;IAC1C,MAAM,UAAU,GAAG,aAAa,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,SAAS,MAAM,OAAO,CAAC,WAAW,mBAAmB,OAAO,CAAC,WAAW,IAAI,KAAK,EAAE,CAAC;IAEjJ,OAAO;QACL,GAAG,GAAG;QACN,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU;KAC5D,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgB;IAC7C,OAAO;QACL,MAAM,EAAE,mBAAmB,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE;QACzD,IAAI,EAAE,UAAU,OAAO,CAAC,SAAS,EAAE;QACnC,WAAW,EAAE,EAAE;QACf,gBAAgB,EAAE,aAAa;QAC/B,aAAa,EAAE,KAAK;QACpB,WAAW,EAAE,aAAa,OAAO,CAAC,WAAW,EAAE;QAC/C,OAAO,EAAE,aAAa,OAAO,CAAC,QAAQ,iBAAiB,OAAO,CAAC,UAAU,mBAAmB,OAAO,CAAC,WAAW,IAAI,KAAK,EAAE;KAC3H,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SbomDocument } from "../types.js";
2
+ /** Parse a CycloneDX or SPDX JSON SBOM file */
3
+ export declare function parseSbom(filePath: string, format?: "cyclonedx" | "spdx"): SbomDocument;
4
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/sbom/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/D,+CAA+C;AAC/C,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAC5B,YAAY,CAcd"}
@@ -0,0 +1,49 @@
1
+ import { readFileSync } from "node:fs";
2
+ /** Parse a CycloneDX or SPDX JSON SBOM file */
3
+ export function parseSbom(filePath, format) {
4
+ const raw = JSON.parse(readFileSync(filePath, "utf-8"));
5
+ const detected = format ?? detectFormat(raw);
6
+ if (!detected) {
7
+ throw new Error(`Cannot detect SBOM format. Use --sbom-format cyclonedx or spdx.`);
8
+ }
9
+ const components = detected === "cyclonedx"
10
+ ? parseCycloneDX(raw)
11
+ : parseSPDX(raw);
12
+ return { format: detected, components, raw };
13
+ }
14
+ function detectFormat(raw) {
15
+ if (typeof raw !== "object" || raw === null)
16
+ return null;
17
+ const obj = raw;
18
+ if (obj.bomFormat === "CycloneDX")
19
+ return "cyclonedx";
20
+ if (typeof obj.spdxVersion === "string")
21
+ return "spdx";
22
+ return null;
23
+ }
24
+ function parseCycloneDX(raw) {
25
+ const components = (raw.components ?? []);
26
+ return components.map((c) => ({
27
+ name: String(c.name ?? ""),
28
+ version: c.version ? String(c.version) : undefined,
29
+ purl: c.purl ? String(c.purl) : undefined,
30
+ type: String(c.type ?? "library"),
31
+ original: c,
32
+ }));
33
+ }
34
+ function parseSPDX(raw) {
35
+ const packages = (raw.packages ?? []);
36
+ return packages.map((p) => {
37
+ // Extract PURL from externalRefs
38
+ const refs = (p.externalRefs ?? []);
39
+ const purlRef = refs.find((r) => r.referenceType === "purl");
40
+ return {
41
+ name: String(p.name ?? ""),
42
+ version: p.versionInfo ? String(p.versionInfo) : undefined,
43
+ purl: purlRef?.referenceLocator,
44
+ type: "library",
45
+ original: p,
46
+ };
47
+ });
48
+ }
49
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/sbom/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,+CAA+C;AAC/C,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,MAA6B;IAE7B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,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AI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,CAAC;QACjC,QAAQ,EAAE,CAAC;KACZ,CAAC,CAAC,CAAC;AACN,CAAC;AAED,SAAS,SAAS,CAAC,GAA4B;IAC7C,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAmC,CAAC;IACxE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACxB,iCAAiC;QACjC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAkC,CAAC;QACrE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,MAAM,CAAC,CAAC;QAE7D,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;YAC1D,IAAI,EAAE,OAAO,EAAE,gBAAgB;YAC/B,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,CAAC;SACZ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,40 @@
1
+ /** AST pattern definitions mapping code constructs to detection rule IDs */
2
+ export interface ImportPattern {
3
+ type: "import";
4
+ /** npm package names to match */
5
+ packages: string[];
6
+ /** Rule ID to emit */
7
+ ruleId: string;
8
+ confidence: number;
9
+ }
10
+ export interface CryptoCallPattern {
11
+ type: "crypto-call";
12
+ /** Method name, e.g. "createHash", "generateKeyPairSync" */
13
+ methodName: string;
14
+ /** Algorithm string arguments to match (case-insensitive). Empty = any call. */
15
+ algorithmArgs: string[];
16
+ /** How algorithmArgs are compared to the argument (default: "prefix") */
17
+ match?: "prefix" | "contains";
18
+ /** Rule ID to emit */
19
+ ruleId: string;
20
+ confidence: number;
21
+ }
22
+ export interface MethodCallPattern {
23
+ type: "method-call";
24
+ /** Object name, e.g. "jwt" */
25
+ objectName: string;
26
+ /** Method name, e.g. "sign" */
27
+ methodName: string;
28
+ /** Property in options object to check */
29
+ optionProperty: string;
30
+ /** Values of that property to match */
31
+ optionValues: string[];
32
+ /** Rule ID to emit */
33
+ ruleId: string;
34
+ confidence: number;
35
+ }
36
+ export type ASTPattern = ImportPattern | CryptoCallPattern | MethodCallPattern;
37
+ export declare const IMPORT_PATTERNS: ImportPattern[];
38
+ export declare const CRYPTO_CALL_PATTERNS: CryptoCallPattern[];
39
+ export declare const METHOD_CALL_PATTERNS: MethodCallPattern[];
40
+ //# sourceMappingURL=ast-patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-patterns.d.ts","sourceRoot":"","sources":["../../src/scanner/ast-patterns.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,iCAAiC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,yEAAyE;IACzE,KAAK,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAI/E,eAAO,MAAM,eAAe,EAAE,aAAa,EAe1C,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,EA+CnD,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,EAKnD,CAAC"}
@@ -0,0 +1,71 @@
1
+ /** AST pattern definitions mapping code constructs to detection rule IDs */
2
+ // --- Import patterns: detect crypto library imports/requires ---
3
+ export const IMPORT_PATTERNS = [
4
+ // Quantum-vulnerable
5
+ { type: "import", packages: ["@noble/ed25519"], ruleId: "ED25519_USAGE", confidence: 0.98 },
6
+ { type: "import", packages: ["@noble/secp256k1"], ruleId: "ECDSA_USAGE", confidence: 0.98 },
7
+ { type: "import", packages: ["node-rsa"], ruleId: "RSA_KEY_GEN", confidence: 0.95 },
8
+ { type: "import", packages: ["tweetnacl"], ruleId: "ED25519_USAGE", confidence: 0.95 },
9
+ { type: "import", packages: ["elliptic"], ruleId: "ECDSA_USAGE", confidence: 0.95 },
10
+ { type: "import", packages: ["jsonwebtoken"], ruleId: "RSA_SIGN", confidence: 0.90 },
11
+ { type: "import", packages: ["jose"], ruleId: "RSA_SIGN", confidence: 0.90 },
12
+ { type: "import", packages: ["@solana/web3.js"], ruleId: "ED25519_USAGE", confidence: 0.95 },
13
+ { type: "import", packages: ["ethers"], ruleId: "ECDSA_USAGE", confidence: 0.95 },
14
+ { type: "import", packages: ["web3"], ruleId: "ECDSA_USAGE", confidence: 0.95 },
15
+ { type: "import", packages: ["libsodium-wrappers"], ruleId: "ED25519_USAGE", confidence: 0.90 },
16
+ // PQC-safe
17
+ { type: "import", packages: ["@noble/post-quantum"], ruleId: "ML_KEM", confidence: 0.98 },
18
+ ];
19
+ // --- Crypto API call patterns: detect crypto.createHash("md5"), etc. ---
20
+ export const CRYPTO_CALL_PATTERNS = [
21
+ // Hashes. Order matters: "sha3-" must not swallow "sha384".
22
+ { type: "crypto-call", methodName: "createHash", algorithmArgs: ["md5"], ruleId: "MD5_USAGE", confidence: 0.95 },
23
+ { type: "crypto-call", methodName: "createHash", algorithmArgs: ["sha1", "sha-1"], ruleId: "SHA1_USAGE", confidence: 0.95 },
24
+ { type: "crypto-call", methodName: "createHash", algorithmArgs: ["sha256", "sha-256"], ruleId: "SHA256_SAFE", confidence: 0.95 },
25
+ { type: "crypto-call", methodName: "createHash", algorithmArgs: ["sha384", "sha-384", "sha512", "sha-512"], ruleId: "SHA384_SHA512_SAFE", confidence: 0.95 },
26
+ { type: "crypto-call", methodName: "createHash", algorithmArgs: ["sha3-", "shake"], ruleId: "SHA3_SAFE", confidence: 0.95 },
27
+ // Symmetric ciphers
28
+ { type: "crypto-call", methodName: "createCipheriv", algorithmArgs: ["aes-128-", "aes128", "id-aes128-"], ruleId: "AES_128", confidence: 0.95 },
29
+ { type: "crypto-call", methodName: "createCipheriv", algorithmArgs: ["aes-256-", "aes256", "id-aes256-"], ruleId: "AES_256", confidence: 0.95 },
30
+ { type: "crypto-call", methodName: "createCipheriv", algorithmArgs: ["chacha20-poly1305"], ruleId: "CHACHA20", confidence: 0.95 },
31
+ { type: "crypto-call", methodName: "createCipheriv", algorithmArgs: ["des"], ruleId: "DES_3DES", confidence: 0.95 },
32
+ // Key generation — the first argument is the key type
33
+ ...["generateKeyPair", "generateKeyPairSync"].flatMap((methodName) => [
34
+ { type: "crypto-call", methodName, algorithmArgs: ["rsa"], ruleId: "RSA_KEY_GEN", confidence: 0.96 },
35
+ { type: "crypto-call", methodName, algorithmArgs: ["ec"], ruleId: "ECDSA_USAGE", confidence: 0.96 },
36
+ { type: "crypto-call", methodName, algorithmArgs: ["ed25519", "ed448"], ruleId: "ED25519_USAGE", confidence: 0.96 },
37
+ { type: "crypto-call", methodName, algorithmArgs: ["x25519", "x448"], ruleId: "ECDH_KEY_EXCHANGE", confidence: 0.96 },
38
+ { type: "crypto-call", methodName, algorithmArgs: ["dsa"], ruleId: "DSA_USAGE", confidence: 0.96 },
39
+ { type: "crypto-call", methodName, algorithmArgs: ["dh"], ruleId: "DH_KEY_EXCHANGE", confidence: 0.96 },
40
+ // Node 24.7+ (OpenSSL 3.5) post-quantum key types; smallest sets first
41
+ { type: "crypto-call", methodName, algorithmArgs: ["ml-kem-512"], ruleId: "ML_KEM_512", confidence: 0.96 },
42
+ { type: "crypto-call", methodName, algorithmArgs: ["ml-dsa-44"], ruleId: "ML_DSA_44", confidence: 0.96 },
43
+ { type: "crypto-call", methodName, algorithmArgs: ["ml-kem"], ruleId: "ML_KEM", confidence: 0.96 },
44
+ { type: "crypto-call", methodName, algorithmArgs: ["ml-dsa"], ruleId: "ML_DSA", confidence: 0.96 },
45
+ { type: "crypto-call", methodName, algorithmArgs: ["slh-dsa"], ruleId: "SLH_DSA", confidence: 0.96 },
46
+ ]),
47
+ // Signatures: createSign("RSA-SHA256") is RSA, not a "safe" SHA-256 (issue #13).
48
+ // A digest-only name ("SHA256") means the key decides — RSA, DSA or ECDSA,
49
+ // all quantum-vulnerable — so the catch-all (no algorithmArgs) comes last.
50
+ ...["createSign", "createVerify"].flatMap((methodName) => [
51
+ { type: "crypto-call", methodName, algorithmArgs: ["rsa"], match: "contains", ruleId: "RSA_SIGN", confidence: 0.96 },
52
+ { type: "crypto-call", methodName, algorithmArgs: ["ecdsa"], match: "contains", ruleId: "ECDSA_USAGE", confidence: 0.96 },
53
+ { type: "crypto-call", methodName, algorithmArgs: ["dsa"], match: "contains", ruleId: "DSA_USAGE", confidence: 0.96 },
54
+ { type: "crypto-call", methodName, algorithmArgs: [], ruleId: "GENERIC_SIGNATURE", confidence: 0.9 },
55
+ ]),
56
+ // Key exchange / encryption
57
+ { type: "crypto-call", methodName: "createECDH", algorithmArgs: [], ruleId: "ECDH_KEY_EXCHANGE", confidence: 0.96 },
58
+ { type: "crypto-call", methodName: "createDiffieHellman", algorithmArgs: [], ruleId: "DH_KEY_EXCHANGE", confidence: 0.95 },
59
+ { type: "crypto-call", methodName: "createDiffieHellmanGroup", algorithmArgs: [], ruleId: "DH_KEY_EXCHANGE", confidence: 0.95 },
60
+ { type: "crypto-call", methodName: "getDiffieHellman", algorithmArgs: [], ruleId: "DH_KEY_EXCHANGE", confidence: 0.95 },
61
+ { type: "crypto-call", methodName: "publicEncrypt", algorithmArgs: [], ruleId: "RSA_ENCRYPT", confidence: 0.95 },
62
+ { type: "crypto-call", methodName: "privateDecrypt", algorithmArgs: [], ruleId: "RSA_ENCRYPT", confidence: 0.95 },
63
+ ];
64
+ // --- Method call patterns: detect jwt.sign with algorithm options ---
65
+ export const METHOD_CALL_PATTERNS = [
66
+ { type: "method-call", objectName: "jwt", methodName: "sign", optionProperty: "algorithm", optionValues: ["RS256", "RS384", "RS512", "PS256", "PS384", "PS512"], ruleId: "RSA_SIGN", confidence: 0.96 },
67
+ { type: "method-call", objectName: "jwt", methodName: "sign", optionProperty: "algorithm", optionValues: ["ES256", "ES384", "ES512"], ruleId: "ECDSA_USAGE", confidence: 0.96 },
68
+ { type: "method-call", objectName: "jwt", methodName: "verify", optionProperty: "algorithms", optionValues: ["RS256", "RS384", "RS512"], ruleId: "RSA_SIGN", confidence: 0.96 },
69
+ { type: "method-call", objectName: "jwt", methodName: "verify", optionProperty: "algorithms", optionValues: ["ES256", "ES384", "ES512"], ruleId: "ECDSA_USAGE", confidence: 0.96 },
70
+ ];
71
+ //# sourceMappingURL=ast-patterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-patterns.js","sourceRoot":"","sources":["../../src/scanner/ast-patterns.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAyC5E,kEAAkE;AAElE,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,qBAAqB;IACrB,EAAE,IAAI,E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,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE;CAClH,CAAC;AAEF,uEAAuE;AAEvE,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACvD,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE;IACvM,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE;IAC/K,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE;IAC/K,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE;CACnL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { DetectionRule, Finding } from "../types.js";
2
+ /**
3
+ * Scan a JavaScript/TypeScript file using AST parsing.
4
+ * Returns findings with detectionMethod "ast" and high confidence.
5
+ * Falls back gracefully: returns empty array if parsers fail to initialize.
6
+ */
7
+ export declare function scanFileAST(filePath: string, relativePath: string, content: string, language: string, rules: DetectionRule[]): Promise<Finding[]>;
8
+ //# sourceMappingURL=ast-scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-scanner.d.ts","sourceRoot":"","sources":["../../src/scanner/ast-scanner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AAiW3E;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,aAAa,EAAE,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC,CAmBpB"}