@quantakrypto/core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-types.d.ts +48 -0
- package/dist/agent-types.d.ts.map +1 -0
- package/dist/agent-types.js +2 -0
- package/dist/agent-types.js.map +1 -0
- package/dist/cache.d.ts +27 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +93 -0
- package/dist/cache.js.map +1 -0
- package/dist/cbom.d.ts.map +1 -1
- package/dist/cbom.js +26 -1
- package/dist/cbom.js.map +1 -1
- package/dist/changed.d.ts.map +1 -1
- package/dist/changed.js +14 -2
- package/dist/changed.js.map +1 -1
- package/dist/codemods/config-toggle.d.ts +3 -0
- package/dist/codemods/config-toggle.d.ts.map +1 -0
- package/dist/codemods/config-toggle.js +26 -0
- package/dist/codemods/config-toggle.js.map +1 -0
- package/dist/codemods/registry.d.ts +26 -0
- package/dist/codemods/registry.d.ts.map +1 -0
- package/dist/codemods/registry.js +8 -0
- package/dist/codemods/registry.js.map +1 -0
- package/dist/comments.d.ts +45 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +164 -0
- package/dist/comments.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -1
- package/dist/dependencies.d.ts +31 -13
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +460 -40
- package/dist/dependencies.js.map +1 -1
- package/dist/detect-utils.d.ts +44 -1
- package/dist/detect-utils.d.ts.map +1 -1
- package/dist/detect-utils.js +113 -17
- package/dist/detect-utils.js.map +1 -1
- package/dist/detectors/c.d.ts +20 -0
- package/dist/detectors/c.d.ts.map +1 -0
- package/dist/detectors/c.js +104 -0
- package/dist/detectors/c.js.map +1 -0
- package/dist/detectors/csharp.d.ts +15 -0
- package/dist/detectors/csharp.d.ts.map +1 -0
- package/dist/detectors/csharp.js +76 -0
- package/dist/detectors/csharp.js.map +1 -0
- package/dist/detectors/go.d.ts +25 -0
- package/dist/detectors/go.d.ts.map +1 -0
- package/dist/detectors/go.js +132 -0
- package/dist/detectors/go.js.map +1 -0
- package/dist/detectors/java.d.ts +25 -0
- package/dist/detectors/java.d.ts.map +1 -0
- package/dist/detectors/java.js +200 -0
- package/dist/detectors/java.js.map +1 -0
- package/dist/detectors/python.d.ts +26 -0
- package/dist/detectors/python.d.ts.map +1 -0
- package/dist/detectors/python.js +171 -0
- package/dist/detectors/python.js.map +1 -0
- package/dist/detectors/ruby.d.ts +15 -0
- package/dist/detectors/ruby.d.ts.map +1 -0
- package/dist/detectors/ruby.js +75 -0
- package/dist/detectors/ruby.js.map +1 -0
- package/dist/detectors/rust.d.ts +13 -0
- package/dist/detectors/rust.d.ts.map +1 -0
- package/dist/detectors/rust.js +94 -0
- package/dist/detectors/rust.js.map +1 -0
- package/dist/detectors/source.d.ts.map +1 -1
- package/dist/detectors/source.js +70 -22
- package/dist/detectors/source.js.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/parallel.d.ts +4 -0
- package/dist/parallel.d.ts.map +1 -1
- package/dist/parallel.js +59 -8
- package/dist/parallel.js.map +1 -1
- package/dist/patch-policy.d.ts +22 -0
- package/dist/patch-policy.d.ts.map +1 -0
- package/dist/patch-policy.js +21 -0
- package/dist/patch-policy.js.map +1 -0
- package/dist/redact.d.ts +19 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +77 -0
- package/dist/redact.js.map +1 -0
- package/dist/registry.d.ts +13 -3
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +31 -4
- package/dist/registry.js.map +1 -1
- package/dist/remediate-pipeline.d.ts +41 -0
- package/dist/remediate-pipeline.d.ts.map +1 -0
- package/dist/remediate-pipeline.js +38 -0
- package/dist/remediate-pipeline.js.map +1 -0
- package/dist/remediate-request.d.ts +21 -0
- package/dist/remediate-request.d.ts.map +1 -0
- package/dist/remediate-request.js +28 -0
- package/dist/remediate-request.js.map +1 -0
- package/dist/remediation.d.ts +10 -0
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +21 -8
- package/dist/remediation.js.map +1 -1
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +16 -1
- package/dist/report.js.map +1 -1
- package/dist/scan-worker.js +6 -2
- package/dist/scan-worker.js.map +1 -1
- package/dist/scan.d.ts +5 -4
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +52 -29
- package/dist/scan.js.map +1 -1
- package/dist/triage.d.ts +27 -0
- package/dist/triage.d.ts.map +1 -0
- package/dist/triage.js +33 -0
- package/dist/triage.js.map +1 -0
- package/dist/types.d.ts +53 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/verify.d.ts +30 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +65 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walk.d.ts +7 -0
- package/dist/walk.d.ts.map +1 -1
- package/dist/walk.js +85 -11
- package/dist/walk.js.map +1 -1
- package/dist/worktree.d.ts +6 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +43 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +1 -1
- package/src/agent-types.ts +52 -0
- package/src/cache.ts +120 -0
- package/src/cbom.ts +27 -1
- package/src/changed.ts +13 -4
- package/src/codemods/config-toggle.ts +35 -0
- package/src/codemods/registry.ts +31 -0
- package/src/comments.ts +180 -0
- package/src/config.ts +8 -0
- package/src/dependencies.ts +483 -51
- package/src/detect-utils.ts +123 -15
- package/src/detectors/c.ts +132 -0
- package/src/detectors/csharp.ts +98 -0
- package/src/detectors/go.ts +167 -0
- package/src/detectors/java.ts +235 -0
- package/src/detectors/python.ts +212 -0
- package/src/detectors/ruby.ts +97 -0
- package/src/detectors/rust.ts +112 -0
- package/src/detectors/source.ts +69 -21
- package/src/index.ts +45 -1
- package/src/parallel.ts +63 -6
- package/src/patch-policy.ts +42 -0
- package/src/redact.ts +92 -0
- package/src/registry.ts +32 -4
- package/src/remediate-pipeline.ts +81 -0
- package/src/remediate-request.ts +52 -0
- package/src/remediation.ts +27 -11
- package/src/report.ts +27 -1
- package/src/scan-worker.ts +6 -2
- package/src/scan.ts +62 -31
- package/src/triage.ts +58 -0
- package/src/types.ts +66 -3
- package/src/verify.ts +82 -0
- package/src/version.ts +1 -1
- package/src/walk.ts +81 -12
- package/src/worktree.ts +45 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { GO_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO } from "../cwe.js";
|
|
3
|
+
/* -------------------------------------------------------------------------- */
|
|
4
|
+
/* Precompiled regexes (module scope) */
|
|
5
|
+
/* -------------------------------------------------------------------------- */
|
|
6
|
+
const RE_GO_RSA_KEYGEN = /\brsa\.GenerateKey\s*\(|\brsa\.GenerateMultiPrimeKey\s*\(/g;
|
|
7
|
+
const RE_GO_RSA_ENCRYPT = /\brsa\.EncryptOAEP\s*\(|\brsa\.EncryptPKCS1v15\s*\(/g;
|
|
8
|
+
const RE_GO_RSA_SIGN = /\brsa\.SignPKCS1v15\s*\(|\brsa\.SignPSS\s*\(/g;
|
|
9
|
+
const RE_GO_ECDSA = /\becdsa\.GenerateKey\s*\(|\becdsa\.SignASN1\s*\(|\becdsa\.Sign\s*\(/g;
|
|
10
|
+
const RE_GO_ECDH = /\becdh\.(?:P256|P384|P521|X25519)\s*\(/g;
|
|
11
|
+
const RE_GO_ED25519 = /\bed25519\.GenerateKey\s*\(|\bed25519\.Sign\s*\(/g;
|
|
12
|
+
const RE_GO_DSA = /\bdsa\.GenerateKey\s*\(|\bdsa\.GenerateParameters\s*\(/g;
|
|
13
|
+
/* -------------------------------------------------------------------------- */
|
|
14
|
+
/* Rule catalog */
|
|
15
|
+
/* -------------------------------------------------------------------------- */
|
|
16
|
+
const RULE_GO_RSA_KEYGEN = {
|
|
17
|
+
id: "go-rsa-keygen",
|
|
18
|
+
title: "Go RSA key generation",
|
|
19
|
+
description: "crypto/rsa GenerateKey / GenerateMultiPrimeKey",
|
|
20
|
+
category: "kem",
|
|
21
|
+
severity: "high",
|
|
22
|
+
confidence: "high",
|
|
23
|
+
algorithm: "RSA",
|
|
24
|
+
hndl: true,
|
|
25
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
26
|
+
message: "Generates a classical RSA key pair (Go), which is not quantum-safe.",
|
|
27
|
+
};
|
|
28
|
+
const RULE_GO_RSA_ENCRYPT = {
|
|
29
|
+
id: "go-rsa-encrypt",
|
|
30
|
+
title: "Go RSA public-key encryption",
|
|
31
|
+
description: "crypto/rsa EncryptOAEP / EncryptPKCS1v15",
|
|
32
|
+
category: "kem",
|
|
33
|
+
severity: "high",
|
|
34
|
+
confidence: "high",
|
|
35
|
+
algorithm: "RSA",
|
|
36
|
+
hndl: true,
|
|
37
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
38
|
+
message: "RSA public-key encryption (Go) is broken by Shor's algorithm and exposed to harvest-now-decrypt-later.",
|
|
39
|
+
};
|
|
40
|
+
const RULE_GO_RSA_SIGN = {
|
|
41
|
+
id: "go-rsa-sign",
|
|
42
|
+
title: "Go RSA signature",
|
|
43
|
+
description: "crypto/rsa SignPKCS1v15 / SignPSS",
|
|
44
|
+
category: "signature",
|
|
45
|
+
severity: "high",
|
|
46
|
+
confidence: "high",
|
|
47
|
+
algorithm: "RSA",
|
|
48
|
+
hndl: false,
|
|
49
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
50
|
+
message: "Classical RSA signing (Go) is forgeable by a quantum attacker.",
|
|
51
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
52
|
+
};
|
|
53
|
+
const RULE_GO_ECDSA = {
|
|
54
|
+
id: "go-ecdsa",
|
|
55
|
+
title: "Go ECDSA key/signature",
|
|
56
|
+
description: "crypto/ecdsa GenerateKey / Sign / SignASN1",
|
|
57
|
+
category: "signature",
|
|
58
|
+
severity: "high",
|
|
59
|
+
confidence: "high",
|
|
60
|
+
algorithm: "ECDSA",
|
|
61
|
+
hndl: false,
|
|
62
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
63
|
+
message: "Classical ECDSA (Go) is forgeable by a quantum attacker.",
|
|
64
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
65
|
+
};
|
|
66
|
+
const RULE_GO_ECDH = {
|
|
67
|
+
id: "go-ecdh",
|
|
68
|
+
title: "Go ECDH key exchange",
|
|
69
|
+
description: "crypto/ecdh P256/P384/P521/X25519 key agreement",
|
|
70
|
+
category: "key-exchange",
|
|
71
|
+
severity: "high",
|
|
72
|
+
confidence: "high",
|
|
73
|
+
algorithm: "ECDH",
|
|
74
|
+
hndl: true,
|
|
75
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
76
|
+
message: "Elliptic-curve Diffie-Hellman (Go crypto/ecdh) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
77
|
+
};
|
|
78
|
+
const RULE_GO_ED25519 = {
|
|
79
|
+
id: "go-ed25519",
|
|
80
|
+
title: "Go Ed25519 signature",
|
|
81
|
+
description: "crypto/ed25519 GenerateKey / Sign",
|
|
82
|
+
category: "signature",
|
|
83
|
+
severity: "low",
|
|
84
|
+
confidence: "high",
|
|
85
|
+
algorithm: "EdDSA",
|
|
86
|
+
hndl: false,
|
|
87
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
88
|
+
message: "Ed25519 (Go) is a modern but still classical signature scheme.",
|
|
89
|
+
};
|
|
90
|
+
const RULE_GO_DSA = {
|
|
91
|
+
id: "go-dsa",
|
|
92
|
+
title: "Go DSA key/usage",
|
|
93
|
+
description: "crypto/dsa GenerateKey / GenerateParameters",
|
|
94
|
+
category: "signature",
|
|
95
|
+
severity: "high",
|
|
96
|
+
confidence: "high",
|
|
97
|
+
algorithm: "DSA",
|
|
98
|
+
hndl: false,
|
|
99
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
100
|
+
message: "Classical DSA (Go) is deprecated and forgeable by a quantum attacker.",
|
|
101
|
+
remediation: "Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).",
|
|
102
|
+
};
|
|
103
|
+
/** Detects classical asymmetric crypto in Go source (crypto/* standard library). */
|
|
104
|
+
export const goDetector = {
|
|
105
|
+
id: "go-crypto",
|
|
106
|
+
description: "Classical asymmetric crypto in Go (crypto/rsa, ecdsa, ecdh, ed25519, dsa)",
|
|
107
|
+
scope: "source",
|
|
108
|
+
language: "go",
|
|
109
|
+
rules: [
|
|
110
|
+
RULE_GO_RSA_KEYGEN,
|
|
111
|
+
RULE_GO_RSA_ENCRYPT,
|
|
112
|
+
RULE_GO_RSA_SIGN,
|
|
113
|
+
RULE_GO_ECDSA,
|
|
114
|
+
RULE_GO_ECDH,
|
|
115
|
+
RULE_GO_ED25519,
|
|
116
|
+
RULE_GO_DSA,
|
|
117
|
+
],
|
|
118
|
+
appliesTo: (f) => hasExtension(f, GO_EXTENSIONS),
|
|
119
|
+
detect({ file, content }) {
|
|
120
|
+
const findings = [];
|
|
121
|
+
const add = (re, rule) => eachMatch(re, content, (m) => findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length })));
|
|
122
|
+
add(RE_GO_RSA_KEYGEN, RULE_GO_RSA_KEYGEN);
|
|
123
|
+
add(RE_GO_RSA_ENCRYPT, RULE_GO_RSA_ENCRYPT);
|
|
124
|
+
add(RE_GO_RSA_SIGN, RULE_GO_RSA_SIGN);
|
|
125
|
+
add(RE_GO_ECDSA, RULE_GO_ECDSA);
|
|
126
|
+
add(RE_GO_ECDH, RULE_GO_ECDH);
|
|
127
|
+
add(RE_GO_ED25519, RULE_GO_ED25519);
|
|
128
|
+
add(RE_GO_DSA, RULE_GO_DSA);
|
|
129
|
+
return findings;
|
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AG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAChC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9B,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QACpC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAE5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-code detector for classical, non-quantum-safe asymmetric cryptography
|
|
3
|
+
* in Java / Kotlin (the JCA — Java Cryptography Architecture). Same lexical
|
|
4
|
+
* strategy as the other language packs.
|
|
5
|
+
*
|
|
6
|
+
* The JCA funnels almost everything through a handful of factory methods keyed
|
|
7
|
+
* by an ALGORITHM STRING: `KeyPairGenerator.getInstance("RSA")`,
|
|
8
|
+
* `Signature.getInstance("SHA256withECDSA")`, `Cipher.getInstance("RSA/ECB/…")`,
|
|
9
|
+
* `KeyAgreement.getInstance("ECDH")`. So detection here is two steps: match the
|
|
10
|
+
* `<Factory>.getInstance("<alg>")` call, then classify the (factory, alg) pair
|
|
11
|
+
* into a rule. Symmetric / hashing algorithms ("AES", "HmacSHA256", …) classify
|
|
12
|
+
* to nothing and are ignored. A small set of BouncyCastle lightweight-API class
|
|
13
|
+
* names (`new ECDSASigner()`, `new X25519Agreement()`, …) is matched directly.
|
|
14
|
+
*
|
|
15
|
+
* HNDL policy mirrors the other detectors: KEM / key agreement (RSA encryption,
|
|
16
|
+
* (EC)DH, X25519/X448) is harvest-now-decrypt-later exposed (hndl:true);
|
|
17
|
+
* signatures (RSA/ECDSA/DSA/EdDSA) are hndl:false but forgeable by a quantum
|
|
18
|
+
* attacker. `KeyPairGenerator.getInstance("EC")` is ambiguous (an EC key feeds
|
|
19
|
+
* both ECDSA and ECDH), so it is classified conservatively as
|
|
20
|
+
* key-exchange-capable (hndl:true), exactly as the Node/Python EC keygen rules.
|
|
21
|
+
*/
|
|
22
|
+
import type { Detector } from "../types.js";
|
|
23
|
+
/** Detects classical asymmetric crypto in Java / Kotlin (JCA + BouncyCastle). */
|
|
24
|
+
export declare const javaDetector: Detector;
|
|
25
|
+
//# sourceMappingURL=java.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../src/detectors/java.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA8K/D,iFAAiF;AACjF,eAAO,MAAM,YAAY,EAAE,QAsC1B,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { JAVA_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO } from "../cwe.js";
|
|
3
|
+
/* -------------------------------------------------------------------------- */
|
|
4
|
+
/* Regexes */
|
|
5
|
+
/* -------------------------------------------------------------------------- */
|
|
6
|
+
// <Factory>.getInstance("<alg>") — the JCA entry points that carry asymmetric
|
|
7
|
+
// algorithms. KeyGenerator/MessageDigest/Mac are intentionally excluded (they
|
|
8
|
+
// are symmetric / hashing only).
|
|
9
|
+
const RE_JAVA_GETINSTANCE = /\b(KeyPairGenerator|Signature|Cipher|KeyAgreement|KeyFactory)\s*\.\s*getInstance\s*\(\s*"([^"]+)"/g;
|
|
10
|
+
// BouncyCastle lightweight-API class instantiations.
|
|
11
|
+
const RE_JAVA_BC = /\bnew\s+(RSAKeyPairGenerator|DSAKeyPairGenerator|ECKeyPairGenerator|ECDSASigner|Ed25519Signer|Ed448Signer|X25519Agreement|X448Agreement)\s*\(/g;
|
|
12
|
+
/* -------------------------------------------------------------------------- */
|
|
13
|
+
/* Rule catalog */
|
|
14
|
+
/* -------------------------------------------------------------------------- */
|
|
15
|
+
const RULE_JAVA_RSA = {
|
|
16
|
+
id: "java-rsa",
|
|
17
|
+
title: "Java RSA key/encryption",
|
|
18
|
+
description: "JCA RSA KeyPairGenerator / Cipher / KeyFactory",
|
|
19
|
+
category: "kem",
|
|
20
|
+
severity: "high",
|
|
21
|
+
confidence: "high",
|
|
22
|
+
algorithm: "RSA",
|
|
23
|
+
hndl: true,
|
|
24
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
25
|
+
message: "Classical RSA (Java/JCA) is not quantum-safe and RSA encryption is HNDL-exposed.",
|
|
26
|
+
};
|
|
27
|
+
const RULE_JAVA_RSA_SIGN = {
|
|
28
|
+
id: "java-rsa-sign",
|
|
29
|
+
title: "Java RSA signature",
|
|
30
|
+
description: 'JCA Signature.getInstance("…withRSA")',
|
|
31
|
+
category: "signature",
|
|
32
|
+
severity: "high",
|
|
33
|
+
confidence: "high",
|
|
34
|
+
algorithm: "RSA",
|
|
35
|
+
hndl: false,
|
|
36
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
37
|
+
message: "Classical RSA signing (Java/JCA) is forgeable by a quantum attacker.",
|
|
38
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
39
|
+
};
|
|
40
|
+
const RULE_JAVA_EC_KEYGEN = {
|
|
41
|
+
id: "java-ec-keygen",
|
|
42
|
+
title: "Java EC key generation",
|
|
43
|
+
description: 'JCA KeyPairGenerator.getInstance("EC")',
|
|
44
|
+
category: "key-exchange",
|
|
45
|
+
severity: "high",
|
|
46
|
+
confidence: "high",
|
|
47
|
+
algorithm: "ECDH",
|
|
48
|
+
hndl: true,
|
|
49
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
50
|
+
message: "Generates a classical EC key pair (Java/JCA). EC keys feed BOTH ECDSA signatures and ECDH key agreement; the ECDH path is harvest-now-decrypt-later exposed.",
|
|
51
|
+
remediation: "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
|
|
52
|
+
};
|
|
53
|
+
const RULE_JAVA_ECDSA_SIGN = {
|
|
54
|
+
id: "java-ecdsa-sign",
|
|
55
|
+
title: "Java ECDSA signature",
|
|
56
|
+
description: 'JCA Signature.getInstance("…withECDSA")',
|
|
57
|
+
category: "signature",
|
|
58
|
+
severity: "high",
|
|
59
|
+
confidence: "high",
|
|
60
|
+
algorithm: "ECDSA",
|
|
61
|
+
hndl: false,
|
|
62
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
63
|
+
message: "Classical ECDSA signing (Java/JCA) is forgeable by a quantum attacker.",
|
|
64
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
65
|
+
};
|
|
66
|
+
const RULE_JAVA_ECDH = {
|
|
67
|
+
id: "java-ecdh",
|
|
68
|
+
title: "Java ECDH key agreement",
|
|
69
|
+
description: 'JCA KeyAgreement.getInstance("ECDH")',
|
|
70
|
+
category: "key-exchange",
|
|
71
|
+
severity: "high",
|
|
72
|
+
confidence: "high",
|
|
73
|
+
algorithm: "ECDH",
|
|
74
|
+
hndl: true,
|
|
75
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
76
|
+
message: "Elliptic-curve Diffie-Hellman (Java/JCA) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
77
|
+
};
|
|
78
|
+
const RULE_JAVA_DSA = {
|
|
79
|
+
id: "java-dsa",
|
|
80
|
+
title: "Java DSA key/signature",
|
|
81
|
+
description: "JCA DSA KeyPairGenerator / Signature",
|
|
82
|
+
category: "signature",
|
|
83
|
+
severity: "high",
|
|
84
|
+
confidence: "high",
|
|
85
|
+
algorithm: "DSA",
|
|
86
|
+
hndl: false,
|
|
87
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
88
|
+
message: "Classical DSA (Java/JCA) is deprecated and forgeable by a quantum attacker.",
|
|
89
|
+
remediation: "Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).",
|
|
90
|
+
};
|
|
91
|
+
const RULE_JAVA_DH = {
|
|
92
|
+
id: "java-dh",
|
|
93
|
+
title: "Java Diffie-Hellman key exchange",
|
|
94
|
+
description: "JCA DiffieHellman KeyPairGenerator / KeyAgreement",
|
|
95
|
+
category: "key-exchange",
|
|
96
|
+
severity: "high",
|
|
97
|
+
confidence: "high",
|
|
98
|
+
algorithm: "DH",
|
|
99
|
+
hndl: true,
|
|
100
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
101
|
+
message: "Finite-field Diffie-Hellman (Java/JCA) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
102
|
+
};
|
|
103
|
+
const RULE_JAVA_XDH = {
|
|
104
|
+
id: "java-xdh",
|
|
105
|
+
title: "Java X25519/X448 key agreement",
|
|
106
|
+
description: "JCA XDH / X25519 / X448 (KeyPairGenerator / KeyAgreement)",
|
|
107
|
+
category: "key-exchange",
|
|
108
|
+
severity: "low",
|
|
109
|
+
confidence: "high",
|
|
110
|
+
algorithm: "X25519",
|
|
111
|
+
hndl: true,
|
|
112
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
113
|
+
message: "X25519/X448 (Java/JCA) is modern but still classical key agreement — harvest-now-decrypt-later.",
|
|
114
|
+
};
|
|
115
|
+
const RULE_JAVA_EDDSA = {
|
|
116
|
+
id: "java-eddsa",
|
|
117
|
+
title: "Java Ed25519/Ed448 signature",
|
|
118
|
+
description: "JCA EdDSA / Ed25519 / Ed448",
|
|
119
|
+
category: "signature",
|
|
120
|
+
severity: "low",
|
|
121
|
+
confidence: "high",
|
|
122
|
+
algorithm: "EdDSA",
|
|
123
|
+
hndl: false,
|
|
124
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
125
|
+
message: "Ed25519/Ed448 (Java/JCA) is a modern but still classical signature scheme.",
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Classify a `<factory>.getInstance("<alg>")` pair into a rule, or null when the
|
|
129
|
+
* algorithm is not classical asymmetric crypto (AES, HMAC, PBKDF2, hashes, …).
|
|
130
|
+
* `alg` is normalised to upper-case with any Cipher transformation suffix
|
|
131
|
+
* (`RSA/ECB/OAEPPadding` → `RSA`) stripped.
|
|
132
|
+
*/
|
|
133
|
+
function classifyGetInstance(factory, rawAlg) {
|
|
134
|
+
const alg = rawAlg.split("/")[0].trim().toUpperCase();
|
|
135
|
+
const isSignature = factory === "Signature";
|
|
136
|
+
if (alg.includes("ECDSA"))
|
|
137
|
+
return RULE_JAVA_ECDSA_SIGN;
|
|
138
|
+
if (alg.includes("ECDH"))
|
|
139
|
+
return RULE_JAVA_ECDH;
|
|
140
|
+
if (alg === "EC")
|
|
141
|
+
return isSignature ? RULE_JAVA_ECDSA_SIGN : RULE_JAVA_EC_KEYGEN;
|
|
142
|
+
if (alg.includes("ED25519") || alg.includes("ED448") || alg.includes("EDDSA"))
|
|
143
|
+
return RULE_JAVA_EDDSA;
|
|
144
|
+
if (alg.includes("X25519") || alg.includes("X448") || alg === "XDH")
|
|
145
|
+
return RULE_JAVA_XDH;
|
|
146
|
+
if (alg.includes("RSA"))
|
|
147
|
+
return isSignature ? RULE_JAVA_RSA_SIGN : RULE_JAVA_RSA;
|
|
148
|
+
if (alg.includes("DSA"))
|
|
149
|
+
return RULE_JAVA_DSA; // ECDSA already handled above
|
|
150
|
+
if (alg.includes("DH") || alg.includes("DIFFIEHELLMAN"))
|
|
151
|
+
return RULE_JAVA_DH;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
/** BouncyCastle lightweight-API class name → rule. */
|
|
155
|
+
const BC_CLASS_RULES = {
|
|
156
|
+
RSAKeyPairGenerator: RULE_JAVA_RSA,
|
|
157
|
+
DSAKeyPairGenerator: RULE_JAVA_DSA,
|
|
158
|
+
ECKeyPairGenerator: RULE_JAVA_EC_KEYGEN,
|
|
159
|
+
ECDSASigner: RULE_JAVA_ECDSA_SIGN,
|
|
160
|
+
Ed25519Signer: RULE_JAVA_EDDSA,
|
|
161
|
+
Ed448Signer: RULE_JAVA_EDDSA,
|
|
162
|
+
X25519Agreement: RULE_JAVA_XDH,
|
|
163
|
+
X448Agreement: RULE_JAVA_XDH,
|
|
164
|
+
};
|
|
165
|
+
/** Detects classical asymmetric crypto in Java / Kotlin (JCA + BouncyCastle). */
|
|
166
|
+
export const javaDetector = {
|
|
167
|
+
id: "java-crypto",
|
|
168
|
+
description: "Classical asymmetric crypto in Java/Kotlin (JCA getInstance + BouncyCastle)",
|
|
169
|
+
scope: "source",
|
|
170
|
+
language: "java",
|
|
171
|
+
rules: [
|
|
172
|
+
RULE_JAVA_RSA,
|
|
173
|
+
RULE_JAVA_RSA_SIGN,
|
|
174
|
+
RULE_JAVA_EC_KEYGEN,
|
|
175
|
+
RULE_JAVA_ECDSA_SIGN,
|
|
176
|
+
RULE_JAVA_ECDH,
|
|
177
|
+
RULE_JAVA_DSA,
|
|
178
|
+
RULE_JAVA_DH,
|
|
179
|
+
RULE_JAVA_XDH,
|
|
180
|
+
RULE_JAVA_EDDSA,
|
|
181
|
+
],
|
|
182
|
+
appliesTo: (f) => hasExtension(f, JAVA_EXTENSIONS),
|
|
183
|
+
detect({ file, content }) {
|
|
184
|
+
const findings = [];
|
|
185
|
+
eachMatch(RE_JAVA_GETINSTANCE, content, (m) => {
|
|
186
|
+
const rule = classifyGetInstance(m[1], m[2]);
|
|
187
|
+
if (!rule)
|
|
188
|
+
return; // symmetric / hashing algorithm — not our concern.
|
|
189
|
+
findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length }));
|
|
190
|
+
});
|
|
191
|
+
eachMatch(RE_JAVA_BC, content, (m) => {
|
|
192
|
+
const rule = BC_CLASS_RULES[m[1]];
|
|
193
|
+
if (!rule)
|
|
194
|
+
return;
|
|
195
|
+
findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length }));
|
|
196
|
+
});
|
|
197
|
+
return findings;
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=java.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java.js","sourceRoot":"","sources":["../../src/detectors/java.ts"],"names":[],"mappings":"AAsBA,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E,CAAC;QAE/B,SAAS,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YAC5C,MAAM,IAAI,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,IAAI;gBAAE,OAAO,CAAC,mDAAmD;YACtE,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CACnF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CACnF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-code detector for classical, non-quantum-safe asymmetric cryptography
|
|
3
|
+
* in Python. Same lexical (regex-over-source) strategy as the JS/TS detectors:
|
|
4
|
+
* robust to formatting, dependency-free, and confidence-tagged per pattern.
|
|
5
|
+
*
|
|
6
|
+
* Covers the three libraries that carry ~all real-world Python asymmetric
|
|
7
|
+
* crypto:
|
|
8
|
+
* - `cryptography` (hazmat): rsa/ec/dh/x25519/x448/ed25519/ed448 + OAEP padding
|
|
9
|
+
* - PyCryptodome (`Crypto.PublicKey`): RSA/ECC/DSA generate + PKCS1_OAEP
|
|
10
|
+
* - paramiko (SSH): RSAKey / ECDSAKey / Ed25519Key / DSSKey
|
|
11
|
+
*
|
|
12
|
+
* JWT/JOSE algorithm strings (`algorithm="RS256"`) are NOT handled here — the
|
|
13
|
+
* language-agnostic `jwt-jose` detector now applies to Python too (a quoted
|
|
14
|
+
* `"RS256"` is the same evidence in any language).
|
|
15
|
+
*
|
|
16
|
+
* HNDL policy mirrors the JS detectors: key agreement / KEM (RSA-OAEP, ECDH, DH,
|
|
17
|
+
* X25519/X448) is harvest-now-decrypt-later exposed (hndl:true); signatures
|
|
18
|
+
* (ECDSA, DSA, Ed25519/Ed448) are hndl:false but still high/low severity because
|
|
19
|
+
* a quantum attacker can forge them. EC key generation is ambiguous (an EC key
|
|
20
|
+
* feeds both ECDSA and ECDH), so it is classified conservatively as
|
|
21
|
+
* key-exchange-capable (hndl:true), exactly as the Node `ec` keygen rule is.
|
|
22
|
+
*/
|
|
23
|
+
import type { Detector } from "../types.js";
|
|
24
|
+
/** Detects classical asymmetric crypto in Python source. */
|
|
25
|
+
export declare const pythonDetector: Detector;
|
|
26
|
+
//# sourceMappingURL=python.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/detectors/python.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAsJ/D,4DAA4D;AAC5D,eAAO,MAAM,cAAc,EAAE,QAsC5B,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { PYTHON_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO } from "../cwe.js";
|
|
3
|
+
/* -------------------------------------------------------------------------- */
|
|
4
|
+
/* Precompiled regexes (module scope) */
|
|
5
|
+
/* -------------------------------------------------------------------------- */
|
|
6
|
+
// RSA key generation: cryptography `rsa.generate_private_key(`, PyCryptodome
|
|
7
|
+
// `RSA.generate(`, paramiko `paramiko.RSAKey` / `RSAKey.generate(`.
|
|
8
|
+
const RE_PY_RSA_KEYGEN = /\brsa\.generate_private_key\s*\(|\bRSA\.generate\s*\(|\bparamiko\.RSAKey\b|\bRSAKey\.generate\s*\(/g;
|
|
9
|
+
// RSA public-key encryption padding (RSA-OAEP): confidentiality → HNDL.
|
|
10
|
+
const RE_PY_RSA_ENCRYPT = /\bpadding\.OAEP\s*\(|\bPKCS1_OAEP\.new\s*\(/g;
|
|
11
|
+
// EC key generation (ambiguous ECDSA/ECDH): cryptography + PyCryptodome.
|
|
12
|
+
const RE_PY_EC_KEYGEN = /\bec\.generate_private_key\s*\(|\bECC\.generate\s*\(/g;
|
|
13
|
+
// ECDSA signatures: cryptography `ec.ECDSA(`, paramiko ECDSAKey.
|
|
14
|
+
const RE_PY_ECDSA = /\bec\.ECDSA\s*\(|\bparamiko\.ECDSAKey\b|\bECDSAKey\.generate\s*\(/g;
|
|
15
|
+
// DSA: PyCryptodome `DSA.generate(`, paramiko DSSKey.
|
|
16
|
+
const RE_PY_DSA = /\bDSA\.generate\s*\(|\bparamiko\.DSSKey\b|\bDSSKey\.generate\s*\(/g;
|
|
17
|
+
// Finite-field Diffie-Hellman (cryptography `dh`).
|
|
18
|
+
const RE_PY_DH = /\bdh\.generate_parameters\s*\(|\bdh\.DHParameterNumbers\s*\(/g;
|
|
19
|
+
// Modern-but-classical curve primitives (cryptography). `.generate(` anchors so
|
|
20
|
+
// a bare import of the class name does not fire.
|
|
21
|
+
const RE_PY_X25519 = /\bX25519PrivateKey\.generate\s*\(/g;
|
|
22
|
+
const RE_PY_X448 = /\bX448PrivateKey\.generate\s*\(/g;
|
|
23
|
+
const RE_PY_EDDSA = /\b(?:Ed25519|Ed448)PrivateKey\.generate\s*\(|\bparamiko\.Ed25519Key\b/g;
|
|
24
|
+
/* -------------------------------------------------------------------------- */
|
|
25
|
+
/* Rule catalog */
|
|
26
|
+
/* -------------------------------------------------------------------------- */
|
|
27
|
+
const RULE_PY_RSA_KEYGEN = {
|
|
28
|
+
id: "python-rsa-keygen",
|
|
29
|
+
title: "Python RSA key generation",
|
|
30
|
+
description: "cryptography rsa.generate_private_key / PyCryptodome RSA.generate / paramiko RSAKey",
|
|
31
|
+
category: "kem",
|
|
32
|
+
severity: "high",
|
|
33
|
+
confidence: "high",
|
|
34
|
+
algorithm: "RSA",
|
|
35
|
+
hndl: true,
|
|
36
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
37
|
+
message: "Generates a classical RSA key pair (Python), which is not quantum-safe.",
|
|
38
|
+
};
|
|
39
|
+
const RULE_PY_RSA_ENCRYPT = {
|
|
40
|
+
id: "python-rsa-encrypt",
|
|
41
|
+
title: "Python RSA public-key encryption",
|
|
42
|
+
description: "RSA-OAEP / PKCS1_OAEP encryption padding",
|
|
43
|
+
category: "kem",
|
|
44
|
+
severity: "high",
|
|
45
|
+
confidence: "high",
|
|
46
|
+
algorithm: "RSA",
|
|
47
|
+
hndl: true,
|
|
48
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
49
|
+
message: "RSA public-key encryption (OAEP) is broken by Shor's algorithm and exposed to harvest-now-decrypt-later.",
|
|
50
|
+
};
|
|
51
|
+
const RULE_PY_EC_KEYGEN = {
|
|
52
|
+
id: "python-ec-keygen",
|
|
53
|
+
title: "Python EC key generation",
|
|
54
|
+
description: "cryptography ec.generate_private_key / PyCryptodome ECC.generate",
|
|
55
|
+
category: "key-exchange",
|
|
56
|
+
severity: "high",
|
|
57
|
+
confidence: "high",
|
|
58
|
+
algorithm: "ECDH",
|
|
59
|
+
hndl: true,
|
|
60
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
61
|
+
message: "Generates a classical EC key pair (Python). EC keys feed BOTH ECDSA signatures and ECDH key agreement; the ECDH path is harvest-now-decrypt-later exposed.",
|
|
62
|
+
remediation: "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
|
|
63
|
+
};
|
|
64
|
+
const RULE_PY_ECDSA = {
|
|
65
|
+
id: "python-ecdsa",
|
|
66
|
+
title: "Python ECDSA signature",
|
|
67
|
+
description: "cryptography ec.ECDSA / paramiko ECDSAKey",
|
|
68
|
+
category: "signature",
|
|
69
|
+
severity: "high",
|
|
70
|
+
confidence: "medium",
|
|
71
|
+
algorithm: "ECDSA",
|
|
72
|
+
hndl: false,
|
|
73
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
74
|
+
message: "Classical ECDSA signing (Python) is forgeable by a quantum attacker.",
|
|
75
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
76
|
+
};
|
|
77
|
+
const RULE_PY_DSA = {
|
|
78
|
+
id: "python-dsa",
|
|
79
|
+
title: "Python DSA key/usage",
|
|
80
|
+
description: "PyCryptodome DSA.generate / paramiko DSSKey",
|
|
81
|
+
category: "signature",
|
|
82
|
+
severity: "high",
|
|
83
|
+
confidence: "high",
|
|
84
|
+
algorithm: "DSA",
|
|
85
|
+
hndl: false,
|
|
86
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
87
|
+
message: "Classical DSA (Python) is deprecated and forgeable by a quantum attacker.",
|
|
88
|
+
remediation: "Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).",
|
|
89
|
+
};
|
|
90
|
+
const RULE_PY_DH = {
|
|
91
|
+
id: "python-dh",
|
|
92
|
+
title: "Python Diffie-Hellman key exchange",
|
|
93
|
+
description: "cryptography dh.generate_parameters / DHParameterNumbers",
|
|
94
|
+
category: "key-exchange",
|
|
95
|
+
severity: "high",
|
|
96
|
+
confidence: "high",
|
|
97
|
+
algorithm: "DH",
|
|
98
|
+
hndl: true,
|
|
99
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
100
|
+
message: "Finite-field Diffie-Hellman (Python) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
101
|
+
};
|
|
102
|
+
const RULE_PY_X25519 = {
|
|
103
|
+
id: "python-x25519",
|
|
104
|
+
title: "Python X25519 key exchange",
|
|
105
|
+
description: "cryptography X25519PrivateKey.generate",
|
|
106
|
+
category: "key-exchange",
|
|
107
|
+
severity: "low",
|
|
108
|
+
confidence: "high",
|
|
109
|
+
algorithm: "X25519",
|
|
110
|
+
hndl: true,
|
|
111
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
112
|
+
message: "X25519 (Python) is modern but still classical key agreement — harvest-now-decrypt-later.",
|
|
113
|
+
};
|
|
114
|
+
const RULE_PY_X448 = {
|
|
115
|
+
id: "python-x448",
|
|
116
|
+
title: "Python X448 key exchange",
|
|
117
|
+
description: "cryptography X448PrivateKey.generate",
|
|
118
|
+
category: "key-exchange",
|
|
119
|
+
severity: "low",
|
|
120
|
+
confidence: "high",
|
|
121
|
+
algorithm: "X448",
|
|
122
|
+
hndl: true,
|
|
123
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
124
|
+
message: "X448 (Python) is modern but still classical key agreement — harvest-now-decrypt-later.",
|
|
125
|
+
};
|
|
126
|
+
const RULE_PY_EDDSA = {
|
|
127
|
+
id: "python-eddsa",
|
|
128
|
+
title: "Python Ed25519/Ed448 signature",
|
|
129
|
+
description: "cryptography Ed25519/Ed448 PrivateKey.generate / paramiko Ed25519Key",
|
|
130
|
+
category: "signature",
|
|
131
|
+
severity: "low",
|
|
132
|
+
confidence: "high",
|
|
133
|
+
algorithm: "EdDSA",
|
|
134
|
+
hndl: false,
|
|
135
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
136
|
+
message: "Ed25519/Ed448 (Python) is a modern but still classical signature scheme.",
|
|
137
|
+
};
|
|
138
|
+
/** Detects classical asymmetric crypto in Python source. */
|
|
139
|
+
export const pythonDetector = {
|
|
140
|
+
id: "python-crypto",
|
|
141
|
+
description: "Classical asymmetric crypto in Python (cryptography, PyCryptodome, paramiko)",
|
|
142
|
+
scope: "source",
|
|
143
|
+
language: "python",
|
|
144
|
+
rules: [
|
|
145
|
+
RULE_PY_RSA_KEYGEN,
|
|
146
|
+
RULE_PY_RSA_ENCRYPT,
|
|
147
|
+
RULE_PY_EC_KEYGEN,
|
|
148
|
+
RULE_PY_ECDSA,
|
|
149
|
+
RULE_PY_DSA,
|
|
150
|
+
RULE_PY_DH,
|
|
151
|
+
RULE_PY_X25519,
|
|
152
|
+
RULE_PY_X448,
|
|
153
|
+
RULE_PY_EDDSA,
|
|
154
|
+
],
|
|
155
|
+
appliesTo: (f) => hasExtension(f, PYTHON_EXTENSIONS),
|
|
156
|
+
detect({ file, content }) {
|
|
157
|
+
const findings = [];
|
|
158
|
+
const add = (re, rule) => eachMatch(re, content, (m) => findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length })));
|
|
159
|
+
add(RE_PY_RSA_KEYGEN, RULE_PY_RSA_KEYGEN);
|
|
160
|
+
add(RE_PY_RSA_ENCRYPT, RULE_PY_RSA_ENCRYPT);
|
|
161
|
+
add(RE_PY_EC_KEYGEN, RULE_PY_EC_KEYGEN);
|
|
162
|
+
add(RE_PY_ECDSA, RULE_PY_ECDSA);
|
|
163
|
+
add(RE_PY_DSA, RULE_PY_DSA);
|
|
164
|
+
add(RE_PY_DH, RULE_PY_DH);
|
|
165
|
+
add(RE_PY_X25519, RULE_PY_X25519);
|
|
166
|
+
add(RE_PY_X448, RULE_PY_X448);
|
|
167
|
+
add(RE_PY_EDDSA, RULE_PY_EDDSA);
|
|
168
|
+
return findings;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/detectors/python.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC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E,IAAI,EAAE,OAAO,EAAE;QACtB,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,IAAc,EAAE,EAAE,CACzC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAC3B,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CACnF,CACF,CAAC;QAEJ,GAAG,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAC1C,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;QAC5C,GAAG,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;QACxC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAChC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC5B,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC1B,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QAClC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9B,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAEhC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-code detector for classical asymmetric cryptography in Ruby. Ruby's
|
|
3
|
+
* asymmetric crypto is almost entirely `OpenSSL::PKey::{RSA,EC,DSA,DH}`, which
|
|
4
|
+
* makes the signals precise. Lexical, same strategy as the other packs.
|
|
5
|
+
*
|
|
6
|
+
* HNDL: RSA (keygen/encryption) and (EC)DH key agreement are harvest-now-
|
|
7
|
+
* decrypt-later exposed (hndl:true); DSA signatures are hndl:false but forgeable.
|
|
8
|
+
* `OpenSSL::PKey::EC` is ambiguous (feeds ECDSA + ECDH), so it is classified
|
|
9
|
+
* conservatively as key-exchange-capable (hndl:true), like the other EC keygen
|
|
10
|
+
* rules.
|
|
11
|
+
*/
|
|
12
|
+
import type { Detector } from "../types.js";
|
|
13
|
+
/** Detects classical asymmetric crypto in Ruby (OpenSSL::PKey). */
|
|
14
|
+
export declare const rubyDetector: Detector;
|
|
15
|
+
//# sourceMappingURL=ruby.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruby.d.ts","sourceRoot":"","sources":["../../src/detectors/ruby.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA+D/D,mEAAmE;AACnE,eAAO,MAAM,YAAY,EAAE,QAqB1B,CAAC"}
|