@hardkeel/benthic 0.0.0-stage → 1.0.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/CHANGELOG.md +121 -0
- package/LICENSE +92 -0
- package/NOTICE +16 -0
- package/README.md +424 -2
- package/action.yml +54 -0
- package/dist/agility.js +80 -0
- package/dist/badge.js +62 -0
- package/dist/baseline.js +81 -0
- package/dist/cbom-diff.js +273 -0
- package/dist/cbom.js +418 -0
- package/dist/cli.js +834 -0
- package/dist/cloud-aws-services.js +375 -0
- package/dist/cloud-aws.js +354 -0
- package/dist/cloud-azure-services.js +73 -0
- package/dist/cloud-azure.js +144 -0
- package/dist/cloud-common.js +242 -0
- package/dist/cloud-gcp-services.js +90 -0
- package/dist/cloud-gcp.js +150 -0
- package/dist/comments.js +138 -0
- package/dist/community-rules.js +37 -0
- package/dist/community.js +30 -0
- package/dist/deps.js +406 -0
- package/dist/der.js +571 -0
- package/dist/evidence-cli.js +235 -0
- package/dist/evidence-live.js +109 -0
- package/dist/evidence.js +512 -0
- package/dist/ignore.js +90 -0
- package/dist/image.js +1224 -0
- package/dist/infra.js +635 -0
- package/dist/inventory.js +277 -0
- package/dist/map-activity.js +24 -0
- package/dist/map-areas.js +60 -0
- package/dist/map-cloud-keys.js +110 -0
- package/dist/map-cloud.js +34 -0
- package/dist/map-ct.js +107 -0
- package/dist/map-host.js +335 -0
- package/dist/map-network.js +520 -0
- package/dist/map-people.js +79 -0
- package/dist/map-rank.js +70 -0
- package/dist/map-report.js +304 -0
- package/dist/map-run.js +327 -0
- package/dist/map-sarif.js +61 -0
- package/dist/map-signin.js +247 -0
- package/dist/map-types.js +19 -0
- package/dist/map-web.js +666 -0
- package/dist/native.js +168 -0
- package/dist/policy.js +221 -0
- package/dist/pqc.js +46 -0
- package/dist/profile.js +65 -0
- package/dist/project.js +928 -0
- package/dist/prose.js +159 -0
- package/dist/protocols.js +207 -0
- package/dist/registry.js +326 -0
- package/dist/report.js +190 -0
- package/dist/rules.js +230 -0
- package/dist/sarif-common.js +30 -0
- package/dist/sarif.js +114 -0
- package/dist/scan.js +601 -0
- package/dist/score.js +124 -0
- package/dist/secrets.js +192 -0
- package/dist/share-config.js +129 -0
- package/dist/share-lists.js +19 -0
- package/dist/share.js +125 -0
- package/dist/sonar.js +83 -0
- package/dist/structure.js +218 -0
- package/dist/suites.js +402 -0
- package/dist/tls-check.js +122 -0
- package/dist/types.js +4 -0
- package/dist/walk.js +78 -0
- package/dist/yaml.js +173 -0
- package/package.json +73 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Generated by scripts/build-rules.mjs from rules/community/*.json. Do not edit by hand.
|
|
4
|
+
export const COMMUNITY_RULES = [
|
|
5
|
+
{ "id": "c-openssl-3des", "title": "3DES with OpenSSL in C or C++", "extensions": [".c", ".cc", ".cpp", ".cxx", ".h", ".hpp"], "pattern": "\\bEVP_des_ede3?_\\w+\\s*\\(", "algorithm": "3DES" },
|
|
6
|
+
{ "id": "c-openssl-ec", "title": "Elliptic-curve keys with OpenSSL in C or C++", "extensions": [".c", ".cc", ".cpp", ".cxx", ".h", ".hpp"], "pattern": "\\bEC_KEY_new_by_curve_name\\s*\\(|\\bEVP_PKEY_EC\\b|\\bEVP_EC_gen\\s*\\(", "algorithm": "EC" },
|
|
7
|
+
{ "id": "c-openssl-ecb", "title": "AES in ECB mode with OpenSSL in C or C++", "extensions": [".c", ".cc", ".cpp", ".cxx", ".h", ".hpp"], "pattern": "\\bEVP_aes_\\d+_ecb\\s*\\(", "algorithm": "ECB mode" },
|
|
8
|
+
{ "id": "c-openssl-rsa", "title": "RSA with OpenSSL in C or C++", "extensions": [".c", ".cc", ".cpp", ".cxx", ".h", ".hpp"], "pattern": "\\bRSA_generate_key(?:_ex)?\\s*\\(|\\bEVP_PKEY_RSA\\b|\\bEVP_RSA_gen\\s*\\(", "algorithm": "RSA", "keySize": "(?:RSA_generate_key(?:_ex)?\\s*\\([^,]+,|EVP_RSA_gen\\s*\\()\\s*(\\d{3,5})" },
|
|
9
|
+
{ "id": "c-openssl-weak-hash", "title": "MD5 or SHA-1 with OpenSSL in C or C++", "extensions": [".c", ".cc", ".cpp", ".cxx", ".h", ".hpp"], "pattern": "\\bEVP_(md5|sha1)\\s*\\(\\s*\\)|\\b(MD5|SHA1)_Init\\s*\\(", "algorithm": { "groups": [1, 2], "map": { "md5": "MD5", "sha1": "SHA-1" } } },
|
|
10
|
+
{ "id": "c-openssl-x25519-dh", "title": "X25519, X448 and Diffie-Hellman with OpenSSL in C or C++", "extensions": [".c", ".cc", ".cpp", ".cxx", ".h", ".hpp"], "pattern": "\\bEVP_PKEY_(X25519|X448|DH|DHX)\\b|\\b(DH)_generate_(?:parameters_ex|key)\\s*\\(|\\bEVP_PKEY_CTX_new_from_name\\s*\\([^,]*,\\s*\"(X25519|X448|DH)\"", "algorithm": { "groups": [1, 2, 3], "map": { "x25519": "X25519", "x448": "X448", "dh": "DH", "dhx": "DH" } } },
|
|
11
|
+
{ "id": "cs-ecb", "title": "ECB mode in .NET", "extensions": [".cs"], "pattern": "\\bCipherMode\\.ECB\\b", "algorithm": "ECB mode" },
|
|
12
|
+
{ "id": "cs-ecdh", "title": "ECDH key exchange in .NET", "extensions": [".cs"], "pattern": "\\bECDiffieHellman\\.Create\\s*\\(|\\bnew\\s+ECDiffieHellmanCng\\s*\\(", "algorithm": "ECDH" },
|
|
13
|
+
{ "id": "cs-ecdsa", "title": "ECDSA in .NET", "extensions": [".cs"], "pattern": "\\bECDsa\\.Create\\s*\\(|\\bnew\\s+ECDsaCng\\s*\\(", "algorithm": "ECDSA" },
|
|
14
|
+
{ "id": "cs-rsa", "title": "RSA keys in .NET", "extensions": [".cs"], "pattern": "\\bRSA\\.Create\\s*\\(|\\bnew\\s+RSACryptoServiceProvider\\s*\\(", "algorithm": "RSA", "keySize": "(?:RSA\\.Create|RSACryptoServiceProvider)\\s*\\(\\s*(\\d{3,5})" },
|
|
15
|
+
{ "id": "cs-weak-cipher", "title": "DES or 3DES in .NET", "extensions": [".cs"], "pattern": "\\b(DES|TripleDES)\\.Create\\s*\\(", "algorithm": { "groups": [1], "map": { "des": "DES", "tripledes": "3DES" } } },
|
|
16
|
+
{ "id": "cs-weak-hash", "title": "MD5 or SHA-1 in .NET", "extensions": [".cs"], "pattern": "\\b(MD5|SHA1)\\.(?:Create|HashData)\\s*\\(|\\bnew\\s+(MD5|SHA1)(?:CryptoServiceProvider|Managed)\\s*\\(", "algorithm": { "groups": [1, 2], "map": { "md5": "MD5", "sha1": "SHA-1" } } },
|
|
17
|
+
{ "id": "php-openssl-ec", "title": "Elliptic-curve keys with PHP's OpenSSL extension", "extensions": [".php"], "pattern": "\\bOPENSSL_KEYTYPE_EC\\b", "algorithm": "ECDSA" },
|
|
18
|
+
{ "id": "php-openssl-rsa", "title": "RSA keys with PHP's OpenSSL extension", "extensions": [".php"], "pattern": "\\bOPENSSL_KEYTYPE_RSA\\b", "algorithm": "RSA", "keySize": "private_key_bits['\\\"]?\\s*=>\\s*(\\d{3,5})" },
|
|
19
|
+
{ "id": "php-sodium", "title": "Ed25519 and X25519 keys with libsodium in PHP", "extensions": [".php"], "pattern": "\\bsodium_crypto_(sign|box|kx)_(?:keypair|seed_keypair|detached|verify_detached)\\s*\\(", "algorithm": { "groups": [1], "map": { "sign": "Ed25519", "box": "X25519", "kx": "X25519" } } },
|
|
20
|
+
{ "id": "php-weak-hash", "title": "MD5 or SHA-1 of a variable in PHP", "extensions": [".php"], "pattern": "\\b(md5|sha1)\\s*\\(\\s*\\$|\\bhash\\s*\\(\\s*['\\\"](md5|sha1)['\\\"]", "algorithm": { "groups": [1, 2], "map": { "md5": "MD5", "sha1": "SHA-1" } } },
|
|
21
|
+
{ "id": "rb-openssl-ec", "title": "Elliptic-curve keys with Ruby's OpenSSL", "extensions": [".rb"], "pattern": "\\bOpenSSL::PKey::EC\\.(?:new|generate)\\b", "algorithm": "ECDSA" },
|
|
22
|
+
{ "id": "rb-openssl-rsa", "title": "RSA keys with Ruby's OpenSSL", "extensions": [".rb"], "pattern": "\\bOpenSSL::PKey::RSA\\.(?:new|generate)\\b", "algorithm": "RSA", "keySize": "RSA\\.(?:new|generate)\\s*\\(\\s*(\\d{3,5})" },
|
|
23
|
+
{ "id": "rb-weak-hash", "title": "MD5 or SHA-1 in Ruby", "extensions": [".rb"], "pattern": "\\bDigest::(MD5|SHA1)\\b", "algorithm": { "groups": [1], "map": { "md5": "MD5", "sha1": "SHA-1" } } },
|
|
24
|
+
{ "id": "rust-ed25519-dalek", "title": "Ed25519 signatures with ed25519-dalek", "extensions": [".rs"], "pattern": "\\bed25519_dalek::", "algorithm": "Ed25519" },
|
|
25
|
+
{ "id": "rust-k256-p256", "title": "ECDSA and ECDH with the RustCrypto k256, p256 and p384 crates", "extensions": [".rs"], "pattern": "\\b(?:k256|p256|p384|p521)::(?:ecdsa|ecdh|SecretKey|PublicKey)\\b", "algorithm": "ECDSA" },
|
|
26
|
+
{ "id": "rust-ring-ecdsa", "title": "ECDSA signing keys with ring", "extensions": [".rs"], "pattern": "\\bEcdsaKeyPair::(?:generate_pkcs8|from_pkcs8)\\s*\\(", "algorithm": "ECDSA" },
|
|
27
|
+
{ "id": "rust-ring-ed25519", "title": "Ed25519 signing keys with ring", "extensions": [".rs"], "pattern": "\\bEd25519KeyPair::(?:generate_pkcs8|from_pkcs8)\\s*\\(", "algorithm": "Ed25519" },
|
|
28
|
+
{ "id": "rust-rsa-crate", "title": "RSA key generation with the rsa crate", "extensions": [".rs"], "pattern": "\\bRsaPrivateKey::new\\s*\\(", "algorithm": "RSA", "keySize": "RsaPrivateKey::new\\s*\\([^,]+,\\s*(\\d{3,5})" },
|
|
29
|
+
{ "id": "rust-weak-hash", "title": "MD5 or SHA-1 hashing in Rust", "extensions": [".rs"], "pattern": "\\b(Md5|Sha1)::(?:new|digest)\\s*\\(|\\b(md5)::compute\\s*\\(", "algorithm": { "groups": [1, 2], "map": { "md5": "MD5", "sha1": "SHA-1" } } },
|
|
30
|
+
{ "id": "rust-x25519-dalek", "title": "X25519 key exchange with x25519-dalek", "extensions": [".rs"], "pattern": "\\bx25519_dalek::", "algorithm": "X25519" },
|
|
31
|
+
{ "id": "sol-ecdsa-recover", "title": "Signature checks with ecrecover in Solidity or Vyper", "extensions": [".sol", ".vy"], "pattern": "\\becrecover\\s*\\(|\\bECDSA\\.(?:recover|tryRecover)(?:Calldata)?\\s*\\(|\\bSignatureChecker\\.isValidSignatureNow\\s*\\(", "algorithm": "ECDSA" },
|
|
32
|
+
{ "id": "sol-eip712", "title": "EIP-712, EIP-2612 and EIP-3009 signed messages in Solidity", "extensions": [".sol", ".vy"], "pattern": "\\b_hashTypedDataV4\\s*\\(|\\bis\\s[^{;]*\\bEIP712\\b|\\bPERMIT_TYPEHASH\\b|\\b(?:TRANSFER|RECEIVE|CANCEL)_WITH_AUTHORIZATION_TYPEHASH\\b|\\bfunction\\s+(?:permit|transferWithAuthorization|receiveWithAuthorization)\\s*\\(", "algorithm": "ECDSA" },
|
|
33
|
+
{ "id": "swift-cryptokit-25519", "title": "Curve25519 with CryptoKit", "extensions": [".swift"], "pattern": "\\bCurve25519\\.(Signing|KeyAgreement)\\b", "algorithm": { "groups": [1], "map": { "signing": "Ed25519", "keyagreement": "X25519" } } },
|
|
34
|
+
{ "id": "swift-cryptokit-nist", "title": "P-256, P-384 or P-521 with CryptoKit", "extensions": [".swift"], "pattern": "\\bP(?:256|384|521)\\.(Signing|KeyAgreement)\\b", "algorithm": { "groups": [1], "map": { "signing": "ECDSA", "keyagreement": "ECDH" } } },
|
|
35
|
+
{ "id": "swift-insecure-hash", "title": "MD5 or SHA-1 with CryptoKit", "extensions": [".swift"], "pattern": "\\bInsecure\\.(MD5|SHA1)\\b", "algorithm": { "groups": [1], "map": { "md5": "MD5", "sha1": "SHA-1" } } },
|
|
36
|
+
{ "id": "swift-seckey-rsa", "title": "RSA keys with Apple's Security framework", "extensions": [".swift"], "pattern": "\\bkSecAttrKeyTypeRSA\\b", "algorithm": "RSA", "keySize": "kSecAttrKeySizeInBits[^:]*:\\s*(\\d{3,5})" },
|
|
37
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Community detection rules: plain JSON files in rules/community/, checked and bundled into
|
|
4
|
+
// src/community-rules.ts by scripts/build-rules.mjs. Contributors never touch TypeScript.
|
|
5
|
+
import { COMMUNITY_RULES } from "./community-rules.js";
|
|
6
|
+
export function compileRule(spec) {
|
|
7
|
+
const a = spec.algorithm;
|
|
8
|
+
return {
|
|
9
|
+
id: spec.id,
|
|
10
|
+
langs: ["any"],
|
|
11
|
+
extensions: spec.extensions.map((e) => e.toLowerCase()),
|
|
12
|
+
pattern: new RegExp(spec.pattern, spec.flags ?? ""),
|
|
13
|
+
keySize: spec.keySize ? new RegExp(spec.keySize) : undefined,
|
|
14
|
+
algorithm: typeof a === "string"
|
|
15
|
+
? a
|
|
16
|
+
: (m) => {
|
|
17
|
+
for (const g of a.groups)
|
|
18
|
+
if (m[g] !== undefined)
|
|
19
|
+
return a.map[m[g].toLowerCase()] ?? null;
|
|
20
|
+
return null;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const COMPILED = COMMUNITY_RULES.map(compileRule);
|
|
25
|
+
/** Community rules that apply to this file, by extension. */
|
|
26
|
+
export function communityRulesFor(path) {
|
|
27
|
+
const p = path.toLowerCase();
|
|
28
|
+
return COMPILED.filter((r) => r.extensions.some((e) => p.endsWith(e)));
|
|
29
|
+
}
|
|
30
|
+
export const COMMUNITY_RULE_COUNT = COMPILED.length;
|
package/dist/deps.js
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Encryption libraries a project depends on, read from its package manifests. A dependency is not
|
|
4
|
+
// proof the code uses it the risky way, so these are listed in the inventory and the CBOM only.
|
|
5
|
+
// They never change the grade.
|
|
6
|
+
const V = (provides) => ({ provides, risk: "quantum-vulnerable" });
|
|
7
|
+
const S = (provides) => ({ provides, risk: "quantum-safe" });
|
|
8
|
+
const M = (provides) => ({ provides, risk: "mixed" });
|
|
9
|
+
const C = (provides) => ({ provides, risk: "check" });
|
|
10
|
+
// Names are matched lower case. "mixed" means it offers both quantum-breakable methods and ones that hold up
|
|
11
|
+
// (AES, hashes, or post-quantum); which one is used is in the code. "check" means it depends on how it is set up.
|
|
12
|
+
const KNOWN = {
|
|
13
|
+
npm: {
|
|
14
|
+
"node-forge": V("RSA, ECDSA, X.509"),
|
|
15
|
+
"node-rsa": V("RSA"),
|
|
16
|
+
jsrsasign: V("RSA, ECDSA, X.509"),
|
|
17
|
+
jsonwebtoken: V("RS256, ES256 and other JWT signatures"),
|
|
18
|
+
jose: V("JWT and JOSE: RSA, ECDSA, EdDSA, ECDH-ES"),
|
|
19
|
+
"node-jose": V("JOSE: RSA, ECDSA, ECDH-ES"),
|
|
20
|
+
elliptic: V("ECDSA, ECDH"),
|
|
21
|
+
"@noble/curves": V("ECDSA, EdDSA, ECDH"),
|
|
22
|
+
"@noble/secp256k1": V("secp256k1 ECDSA"),
|
|
23
|
+
"@noble/ed25519": V("Ed25519"),
|
|
24
|
+
secp256k1: V("secp256k1 ECDSA"),
|
|
25
|
+
tweetnacl: V("X25519, Ed25519"),
|
|
26
|
+
"libsodium-wrappers": V("X25519, Ed25519"),
|
|
27
|
+
"sodium-native": V("X25519, Ed25519"),
|
|
28
|
+
openpgp: V("RSA, ECC (OpenPGP)"),
|
|
29
|
+
sshpk: V("SSH RSA, ECDSA, Ed25519 keys"),
|
|
30
|
+
ssh2: V("SSH key exchange and host keys"),
|
|
31
|
+
"@peculiar/x509": V("X.509 with RSA, ECDSA"),
|
|
32
|
+
pkijs: V("X.509 with RSA, ECDSA"),
|
|
33
|
+
"x509-tidewater": V("X.509 certificates with RSA and ECDSA keys"),
|
|
34
|
+
ethers: V("secp256k1 ECDSA (Ethereum)"),
|
|
35
|
+
web3: V("secp256k1 ECDSA (Ethereum)"),
|
|
36
|
+
viem: V("secp256k1 ECDSA (Ethereum)"),
|
|
37
|
+
"@openzeppelin/contracts": V("ECDSA recover, EIP-712"),
|
|
38
|
+
"@solana/web3.js": V("Ed25519 (Solana)"),
|
|
39
|
+
"bitcoinjs-lib": V("secp256k1 ECDSA (Bitcoin)"),
|
|
40
|
+
"@noble/post-quantum": S("ML-KEM, ML-DSA, SLH-DSA"),
|
|
41
|
+
mlkem: S("ML-KEM"),
|
|
42
|
+
"crystals-kyber": S("Kyber (pre-standard ML-KEM)"),
|
|
43
|
+
"@openquantumsafe/liboqs": S("liboqs post-quantum algorithms"),
|
|
44
|
+
"crypto-js": C("AES, SHA, MD5, HMAC"),
|
|
45
|
+
},
|
|
46
|
+
pypi: {
|
|
47
|
+
cryptography: M("RSA, ECDSA, Ed25519, X25519, AES and more"),
|
|
48
|
+
pycryptodome: V("RSA, ECC, DSA"),
|
|
49
|
+
pycryptodomex: V("RSA, ECC, DSA"),
|
|
50
|
+
rsa: V("RSA"),
|
|
51
|
+
ecdsa: V("ECDSA"),
|
|
52
|
+
pyjwt: V("RS256, ES256 and other JWT signatures"),
|
|
53
|
+
"python-jose": V("JOSE: RSA, ECDSA"),
|
|
54
|
+
jwcrypto: V("JOSE: RSA, ECDSA, ECDH-ES"),
|
|
55
|
+
authlib: V("JOSE: RSA, ECDSA"),
|
|
56
|
+
paramiko: V("SSH RSA, ECDSA, Ed25519"),
|
|
57
|
+
pynacl: V("X25519, Ed25519"),
|
|
58
|
+
pyopenssl: V("RSA, ECDSA, X.509"),
|
|
59
|
+
m2crypto: V("RSA, ECDSA, X.509"),
|
|
60
|
+
"pyx509-anchorage": V("X.509 parsing and signing: RSA, ECDSA"),
|
|
61
|
+
coincurve: V("secp256k1 ECDSA"),
|
|
62
|
+
"eth-account": V("secp256k1 ECDSA (Ethereum)"),
|
|
63
|
+
"eth-keys": V("secp256k1 ECDSA (Ethereum)"),
|
|
64
|
+
web3: V("secp256k1 ECDSA (Ethereum)"),
|
|
65
|
+
fido2: V("ECDSA, RSA (WebAuthn)"),
|
|
66
|
+
"liboqs-python": S("liboqs post-quantum algorithms"),
|
|
67
|
+
oqs: S("liboqs post-quantum algorithms"),
|
|
68
|
+
pqcrypto: S("post-quantum KEMs and signatures"),
|
|
69
|
+
"kyber-py": S("ML-KEM"),
|
|
70
|
+
"dilithium-py": S("ML-DSA"),
|
|
71
|
+
tink: M("AES, ECDSA, Ed25519 and more"),
|
|
72
|
+
},
|
|
73
|
+
golang: {
|
|
74
|
+
"github.com/golang-jwt/jwt": V("RS256, ES256 and other JWT signatures"),
|
|
75
|
+
"github.com/golang-jwt/jwt/v4": V("RS256, ES256 and other JWT signatures"),
|
|
76
|
+
"github.com/golang-jwt/jwt/v5": V("RS256, ES256 and other JWT signatures"),
|
|
77
|
+
"github.com/lestrrat-go/jwx": V("JOSE: RSA, ECDSA, EdDSA"),
|
|
78
|
+
"github.com/lestrrat-go/jwx/v2": V("JOSE: RSA, ECDSA, EdDSA"),
|
|
79
|
+
"github.com/go-jose/go-jose/v3": V("JOSE: RSA, ECDSA, ECDH-ES"),
|
|
80
|
+
"github.com/go-jose/go-jose/v4": V("JOSE: RSA, ECDSA, ECDH-ES"),
|
|
81
|
+
"gopkg.in/square/go-jose.v2": V("JOSE: RSA, ECDSA, ECDH-ES"),
|
|
82
|
+
"github.com/ethereum/go-ethereum": V("secp256k1 ECDSA (Ethereum)"),
|
|
83
|
+
"github.com/decred/dcrd/dcrec/secp256k1/v4": V("secp256k1 ECDSA"),
|
|
84
|
+
"github.com/btcsuite/btcd/btcec/v2": V("secp256k1 ECDSA (Bitcoin)"),
|
|
85
|
+
"golang.org/x/crypto": C("SSH, Ed25519, X25519, bcrypt, ChaCha20 and more"),
|
|
86
|
+
"github.com/cloudflare/circl": M("ML-KEM, ML-DSA, hybrids and classical curves"),
|
|
87
|
+
"github.com/open-quantum-safe/liboqs-go": S("liboqs post-quantum algorithms"),
|
|
88
|
+
"filippo.io/mlkem768": S("ML-KEM-768"),
|
|
89
|
+
},
|
|
90
|
+
maven: {
|
|
91
|
+
"org.bouncycastle:bcprov-jdk18on": M("RSA, ECDSA and post-quantum algorithms"),
|
|
92
|
+
"org.bouncycastle:bcprov-jdk15on": M("RSA, ECDSA; older releases with few post-quantum algorithms"),
|
|
93
|
+
"org.bouncycastle:bcpkix-jdk18on": V("X.509 and CMS with RSA, ECDSA"),
|
|
94
|
+
"org.bouncycastle:bcpkix-jdk15on": V("X.509 and CMS with RSA, ECDSA"),
|
|
95
|
+
"com.nimbusds:nimbus-jose-jwt": V("JOSE: RSA, ECDSA, EdDSA"),
|
|
96
|
+
"io.jsonwebtoken:jjwt": V("RS256, ES256 and other JWT signatures"),
|
|
97
|
+
"io.jsonwebtoken:jjwt-api": V("RS256, ES256 and other JWT signatures"),
|
|
98
|
+
"io.jsonwebtoken:jjwt-impl": V("RS256, ES256 and other JWT signatures"),
|
|
99
|
+
"com.auth0:java-jwt": V("RS256, ES256 and other JWT signatures"),
|
|
100
|
+
"org.web3j:core": V("secp256k1 ECDSA (Ethereum)"),
|
|
101
|
+
"org.web3j:crypto": V("secp256k1 ECDSA (Ethereum)"),
|
|
102
|
+
"com.google.crypto.tink:tink": M("AES, ECDSA, Ed25519 and more"),
|
|
103
|
+
"org.openquantumsafe:liboqs-java": S("liboqs post-quantum algorithms"),
|
|
104
|
+
},
|
|
105
|
+
cargo: {
|
|
106
|
+
rsa: V("RSA"),
|
|
107
|
+
p256: V("ECDSA, ECDH on P-256"),
|
|
108
|
+
p384: V("ECDSA, ECDH on P-384"),
|
|
109
|
+
k256: V("secp256k1 ECDSA"),
|
|
110
|
+
secp256k1: V("secp256k1 ECDSA"),
|
|
111
|
+
"ed25519-dalek": V("Ed25519"),
|
|
112
|
+
"x25519-dalek": V("X25519"),
|
|
113
|
+
"ballast-ecdh": V("ECDH on P-256 and X25519"),
|
|
114
|
+
jsonwebtoken: V("RS256, ES256 and other JWT signatures"),
|
|
115
|
+
ring: M("RSA, ECDSA, Ed25519, X25519, AES"),
|
|
116
|
+
openssl: M("OpenSSL: RSA, ECDSA and more"),
|
|
117
|
+
"aws-lc-rs": M("RSA, ECDSA and ML-KEM"),
|
|
118
|
+
rustls: C("TLS: check the key exchange groups it offers"),
|
|
119
|
+
"ml-kem": S("ML-KEM"),
|
|
120
|
+
"ml-dsa": S("ML-DSA"),
|
|
121
|
+
"slh-dsa": S("SLH-DSA"),
|
|
122
|
+
oqs: S("liboqs post-quantum algorithms"),
|
|
123
|
+
"pqcrypto": S("post-quantum KEMs and signatures"),
|
|
124
|
+
},
|
|
125
|
+
gem: {
|
|
126
|
+
jwt: V("RS256, ES256 and other JWT signatures"),
|
|
127
|
+
"json-jwt": V("JOSE: RSA, ECDSA"),
|
|
128
|
+
rbnacl: V("X25519, Ed25519"),
|
|
129
|
+
ed25519: V("Ed25519"),
|
|
130
|
+
"net-ssh": V("SSH RSA, ECDSA, Ed25519"),
|
|
131
|
+
eth: V("secp256k1 ECDSA (Ethereum)"),
|
|
132
|
+
openssl: M("OpenSSL: RSA, ECDSA and more"),
|
|
133
|
+
},
|
|
134
|
+
composer: {
|
|
135
|
+
"firebase/php-jwt": V("RS256, ES256 and other JWT signatures"),
|
|
136
|
+
"lcobucci/jwt": V("RS256, ES256 and other JWT signatures"),
|
|
137
|
+
"web-token/jwt-framework": V("JOSE: RSA, ECDSA, EdDSA"),
|
|
138
|
+
"phpseclib/phpseclib": V("RSA, ECDSA, SSH"),
|
|
139
|
+
"paragonie/sodium_compat": V("X25519, Ed25519"),
|
|
140
|
+
"kornrunner/ethereum-offline-raw-tx": V("secp256k1 ECDSA (Ethereum)"),
|
|
141
|
+
},
|
|
142
|
+
nuget: {
|
|
143
|
+
"bouncycastle.cryptography": M("RSA, ECDSA and post-quantum algorithms"),
|
|
144
|
+
"portable.bouncycastle": V("RSA, ECDSA; an older BouncyCastle"),
|
|
145
|
+
"system.identitymodel.tokens.jwt": V("RS256, ES256 and other JWT signatures"),
|
|
146
|
+
"microsoft.identitymodel.tokens": V("RS256, ES256 and other JWT signatures"),
|
|
147
|
+
"jose-jwt": V("JOSE: RSA, ECDSA"),
|
|
148
|
+
"nethereum.web3": V("secp256k1 ECDSA (Ethereum)"),
|
|
149
|
+
"nsec.cryptography": V("X25519, Ed25519"),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
const MANIFEST = /(^|\/)(package\.json|requirements[^/]*\.txt|pyproject\.toml|Pipfile|setup\.cfg|go\.mod|pom\.xml|build\.gradle(\.kts)?|Cargo\.toml|Gemfile|composer\.json|[^/]+\.csproj|packages\.config|Directory\.Packages\.props)$/i;
|
|
153
|
+
/** Whether a path is a package manifest this reads. */
|
|
154
|
+
export function isManifest(path) {
|
|
155
|
+
return MANIFEST.test(path);
|
|
156
|
+
}
|
|
157
|
+
function lineOf(lines, needle, from = 0) {
|
|
158
|
+
for (let i = from; i < lines.length; i++)
|
|
159
|
+
if (lines[i].includes(needle))
|
|
160
|
+
return i + 1;
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
function npm(lines, text) {
|
|
164
|
+
let doc;
|
|
165
|
+
try {
|
|
166
|
+
doc = JSON.parse(text);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
const out = [];
|
|
172
|
+
// Runtime dependencies only: build tools and test helpers don't ship.
|
|
173
|
+
for (const key of ["dependencies", "optionalDependencies", "peerDependencies"]) {
|
|
174
|
+
const deps = doc[key];
|
|
175
|
+
if (!deps || typeof deps !== "object")
|
|
176
|
+
continue;
|
|
177
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
178
|
+
out.push({ name, version: typeof version === "string" ? version : undefined, line: lineOf(lines, `"${name}"`) });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return out;
|
|
182
|
+
}
|
|
183
|
+
function composer(lines, text) {
|
|
184
|
+
try {
|
|
185
|
+
const doc = JSON.parse(text);
|
|
186
|
+
return Object.entries(doc.require ?? {}).map(([name, version]) => ({ name, version, line: lineOf(lines, `"${name}"`) }));
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function pythonReq(lines) {
|
|
193
|
+
const out = [];
|
|
194
|
+
lines.forEach((l, i) => {
|
|
195
|
+
const m = l.replace(/#.*/, "").trim().match(/^([A-Za-z0-9][A-Za-z0-9._-]*)(?:\[[^\]]*\])?\s*(?:(==|>=|~=|<=|>|<|!=)\s*([^\s,;]+))?/);
|
|
196
|
+
if (m && !l.trim().startsWith("-"))
|
|
197
|
+
out.push({ name: m[1], version: m[2] === "==" ? m[3] : undefined, line: i + 1 });
|
|
198
|
+
});
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
function pyproject(lines) {
|
|
202
|
+
const out = [];
|
|
203
|
+
let section = "";
|
|
204
|
+
let inArray = false;
|
|
205
|
+
lines.forEach((l, i) => {
|
|
206
|
+
const t = l.replace(/\s#.*$/, "").trim();
|
|
207
|
+
const sec = t.match(/^\[([^\]]+)\]$/);
|
|
208
|
+
if (sec) {
|
|
209
|
+
section = sec[1];
|
|
210
|
+
inArray = false;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// PEP 621: dependencies = ["cryptography>=42", ...], possibly over several lines.
|
|
214
|
+
if (section === "project" && /^dependencies\s*=/.test(t))
|
|
215
|
+
inArray = true;
|
|
216
|
+
if (inArray || section.startsWith("project.optional-dependencies")) {
|
|
217
|
+
for (const m of t.matchAll(/["']([A-Za-z0-9][A-Za-z0-9._-]*)(?:\[[^\]]*\])?\s*(?:==\s*([^"',;\s]+))?[^"']*["']/g))
|
|
218
|
+
out.push({ name: m[1], version: m[2], line: i + 1 });
|
|
219
|
+
if (/\]\s*,?$/.test(t))
|
|
220
|
+
inArray = false;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// Poetry and Pipfile: name = "^1.2" or name = { version = "..." }
|
|
224
|
+
if (/^(tool\.poetry\.(group\.[^.]+\.)?dependencies|packages)$/.test(section)) {
|
|
225
|
+
const m = t.match(/^["']?([A-Za-z0-9][A-Za-z0-9._-]*)["']?\s*=\s*(?:["']([^"']*)["']|\{)/);
|
|
226
|
+
if (m && m[1].toLowerCase() !== "python")
|
|
227
|
+
out.push({ name: m[1], version: m[2] && /^\d/.test(m[2]) ? m[2] : undefined, line: i + 1 });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
function gomod(lines) {
|
|
233
|
+
const out = [];
|
|
234
|
+
let block = false;
|
|
235
|
+
lines.forEach((l, i) => {
|
|
236
|
+
const t = l.replace(/\/\/.*$/, "").trim();
|
|
237
|
+
if (/^require\s*\($/.test(t))
|
|
238
|
+
return void (block = true);
|
|
239
|
+
if (block && t === ")")
|
|
240
|
+
return void (block = false);
|
|
241
|
+
const m = (block ? t : t.replace(/^require\s+/, "")).match(/^([a-z0-9.-]+\.[a-z]{2,}\/[^\s]+)\s+(v[^\s]+)$/i);
|
|
242
|
+
if (m && (block || /^require\s/.test(t)))
|
|
243
|
+
out.push({ name: m[1], version: m[2], line: i + 1 });
|
|
244
|
+
});
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
function cargo(lines) {
|
|
248
|
+
const out = [];
|
|
249
|
+
let deps = false;
|
|
250
|
+
lines.forEach((l, i) => {
|
|
251
|
+
const t = l.replace(/\s#.*$/, "").trim();
|
|
252
|
+
const sec = t.match(/^\[([^\]]+)\]$/);
|
|
253
|
+
if (sec) {
|
|
254
|
+
const s = sec[1];
|
|
255
|
+
deps = /(^|\.)dependencies$/.test(s) && !/dev-dependencies|build-dependencies/.test(s);
|
|
256
|
+
const one = s.match(/^dependencies\.([A-Za-z0-9_-]+)$/);
|
|
257
|
+
if (one)
|
|
258
|
+
out.push({ name: one[1], line: i + 1 });
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (!deps)
|
|
262
|
+
return;
|
|
263
|
+
const m = t.match(/^([A-Za-z0-9_-]+)\s*=\s*(?:"([^"]*)"|\{[^}]*?version\s*=\s*"([^"]*)")?/);
|
|
264
|
+
if (m)
|
|
265
|
+
out.push({ name: m[1], version: m[2] ?? m[3], line: i + 1 });
|
|
266
|
+
});
|
|
267
|
+
return out;
|
|
268
|
+
}
|
|
269
|
+
function gemfile(lines) {
|
|
270
|
+
const out = [];
|
|
271
|
+
lines.forEach((l, i) => {
|
|
272
|
+
const m = l.match(/^\s*gem\s+["']([^"']+)["'](?:\s*,\s*["']([^"']+)["'])?/);
|
|
273
|
+
if (m)
|
|
274
|
+
out.push({ name: m[1], version: m[2], line: i + 1 });
|
|
275
|
+
});
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
function maven(lines, text) {
|
|
279
|
+
const out = [];
|
|
280
|
+
// Only <dependency> blocks, so the project's own groupId and plugins don't count.
|
|
281
|
+
for (const m of text.matchAll(/<dependency>([\s\S]*?)<\/dependency>/g)) {
|
|
282
|
+
const g = m[1].match(/<groupId>\s*([^<\s]+)\s*<\/groupId>/)?.[1];
|
|
283
|
+
const a = m[1].match(/<artifactId>\s*([^<\s]+)\s*<\/artifactId>/)?.[1];
|
|
284
|
+
if (!g || !a)
|
|
285
|
+
continue;
|
|
286
|
+
const v = m[1].match(/<version>\s*([^<\s$]+)\s*<\/version>/)?.[1];
|
|
287
|
+
const scope = m[1].match(/<scope>\s*([^<\s]+)\s*<\/scope>/)?.[1];
|
|
288
|
+
if (scope === "test")
|
|
289
|
+
continue;
|
|
290
|
+
const at = text.slice(0, m.index + m[0].indexOf(a)).split("\n").length;
|
|
291
|
+
out.push({ name: `${g}:${a}`, version: v, line: at });
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
295
|
+
function gradle(lines) {
|
|
296
|
+
const out = [];
|
|
297
|
+
lines.forEach((l, i) => {
|
|
298
|
+
const m = l.match(/^\s*(implementation|api|compile|runtimeOnly|compileOnly)\s*\(?\s*["']([^:"'\s]+):([^:"'\s]+)(?::([^"'\s]+))?["']/);
|
|
299
|
+
if (m)
|
|
300
|
+
out.push({ name: `${m[2]}:${m[3]}`, version: m[4], line: i + 1 });
|
|
301
|
+
});
|
|
302
|
+
return out;
|
|
303
|
+
}
|
|
304
|
+
function nuget(lines) {
|
|
305
|
+
const out = [];
|
|
306
|
+
lines.forEach((l, i) => {
|
|
307
|
+
const m = l.match(/<(?:PackageReference|PackageVersion|package)\s[^>]*?(?:Include|id)\s*=\s*"([^"]+)"(?:[^>]*?[Vv]ersion\s*=\s*"([^"]+)")?/);
|
|
308
|
+
if (m)
|
|
309
|
+
out.push({ name: m[1], version: m[2], line: i + 1 });
|
|
310
|
+
});
|
|
311
|
+
return out;
|
|
312
|
+
}
|
|
313
|
+
/** What the library list says about a package, or undefined when it isn't an encryption library. */
|
|
314
|
+
export function knownLibrary(eco, name) {
|
|
315
|
+
const key = norm(eco, name);
|
|
316
|
+
const table = KNOWN[eco];
|
|
317
|
+
if (Object.hasOwn(table, key))
|
|
318
|
+
return table[key];
|
|
319
|
+
const maven = key.replace(/-jdk\d+(on)?$/, "-jdk18on");
|
|
320
|
+
return eco === "maven" && Object.hasOwn(KNOWN.maven, maven) ? KNOWN.maven[maven] : undefined;
|
|
321
|
+
}
|
|
322
|
+
function ecosystemOf(path) {
|
|
323
|
+
const f = path.split("/").pop().toLowerCase();
|
|
324
|
+
if (f === "package.json")
|
|
325
|
+
return "npm";
|
|
326
|
+
if (f === "composer.json")
|
|
327
|
+
return "composer";
|
|
328
|
+
if (/^requirements.*\.txt$|^pyproject\.toml$|^pipfile$|^setup\.cfg$/.test(f))
|
|
329
|
+
return "pypi";
|
|
330
|
+
if (f === "go.mod")
|
|
331
|
+
return "golang";
|
|
332
|
+
if (f === "pom.xml" || f.startsWith("build.gradle"))
|
|
333
|
+
return "maven";
|
|
334
|
+
if (f === "cargo.toml")
|
|
335
|
+
return "cargo";
|
|
336
|
+
if (f === "gemfile")
|
|
337
|
+
return "gem";
|
|
338
|
+
if (f.endsWith(".csproj") || f === "packages.config" || f === "directory.packages.props")
|
|
339
|
+
return "nuget";
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
/** Normalize a package name the way its registry compares names. */
|
|
343
|
+
function norm(eco, name) {
|
|
344
|
+
const n = name.toLowerCase();
|
|
345
|
+
return eco === "pypi" ? n.replace(/[-_.]+/g, "-") : n;
|
|
346
|
+
}
|
|
347
|
+
/** Encryption libraries named in one manifest. */
|
|
348
|
+
export function findLibraries(path, content) {
|
|
349
|
+
if (!isManifest(path) || content.includes("\u0000"))
|
|
350
|
+
return [];
|
|
351
|
+
const eco = ecosystemOf(path);
|
|
352
|
+
if (!eco)
|
|
353
|
+
return [];
|
|
354
|
+
const lines = content.split(/\r?\n/);
|
|
355
|
+
const f = path.split("/").pop().toLowerCase();
|
|
356
|
+
let hits;
|
|
357
|
+
if (eco === "npm")
|
|
358
|
+
hits = npm(lines, content);
|
|
359
|
+
else if (eco === "composer")
|
|
360
|
+
hits = composer(lines, content);
|
|
361
|
+
else if (eco === "pypi")
|
|
362
|
+
hits = f.endsWith(".txt") ? pythonReq(lines) : f === "setup.cfg" ? pythonReq(lines.map((l) => (/^\s+[A-Za-z]/.test(l) ? l.trim() : ""))) : pyproject(lines);
|
|
363
|
+
else if (eco === "golang")
|
|
364
|
+
hits = gomod(lines);
|
|
365
|
+
else if (eco === "maven")
|
|
366
|
+
hits = f === "pom.xml" ? maven(lines, content) : gradle(lines);
|
|
367
|
+
else if (eco === "cargo")
|
|
368
|
+
hits = cargo(lines);
|
|
369
|
+
else if (eco === "gem")
|
|
370
|
+
hits = gemfile(lines);
|
|
371
|
+
else
|
|
372
|
+
hits = nuget(lines);
|
|
373
|
+
const out = [];
|
|
374
|
+
const seen = new Set();
|
|
375
|
+
for (const h of hits) {
|
|
376
|
+
const key = norm(eco, h.name);
|
|
377
|
+
const k = knownLibrary(eco, h.name);
|
|
378
|
+
if (!k || seen.has(key))
|
|
379
|
+
continue;
|
|
380
|
+
seen.add(key);
|
|
381
|
+
out.push({ name: h.name, ...(h.version ? { version: h.version } : {}), ecosystem: eco, file: path, line: h.line, provides: k.provides, risk: k.risk });
|
|
382
|
+
}
|
|
383
|
+
return out;
|
|
384
|
+
}
|
|
385
|
+
/** A package URL (purl) for the CBOM, with the version only when the manifest pins one exactly. */
|
|
386
|
+
export function purlOf(l) {
|
|
387
|
+
// A system package's version is the one installed, so it always goes in.
|
|
388
|
+
if (l.ecosystem === "deb" || l.ecosystem === "apk")
|
|
389
|
+
return `pkg:${l.ecosystem}/${encodeURIComponent(l.namespace ?? (l.ecosystem === "apk" ? "alpine" : "debian"))}/${encodeURIComponent(l.name)}${l.version ? `@${encodeURIComponent(l.version)}` : ""}`;
|
|
390
|
+
const exact = l.version && /^v?\d+(\.\d+)*([-+][0-9A-Za-z.-]+)?$/.test(l.version) ? l.version : undefined;
|
|
391
|
+
let name;
|
|
392
|
+
if (l.ecosystem === "maven") {
|
|
393
|
+
const [g, a] = l.name.split(":");
|
|
394
|
+
name = `${encodeURIComponent(g)}/${encodeURIComponent(a)}`;
|
|
395
|
+
}
|
|
396
|
+
else if (l.ecosystem === "npm" && l.name.startsWith("@")) {
|
|
397
|
+
const [scope, pkg] = l.name.split("/");
|
|
398
|
+
name = `${encodeURIComponent(scope)}/${encodeURIComponent(pkg)}`;
|
|
399
|
+
}
|
|
400
|
+
else if (l.ecosystem === "golang" || l.ecosystem === "composer") {
|
|
401
|
+
name = l.name.split("/").map(encodeURIComponent).join("/");
|
|
402
|
+
}
|
|
403
|
+
else
|
|
404
|
+
name = encodeURIComponent(l.ecosystem === "pypi" ? norm("pypi", l.name) : l.name);
|
|
405
|
+
return `pkg:${l.ecosystem}/${name}${exact ? `@${encodeURIComponent(exact)}` : ""}`;
|
|
406
|
+
}
|