@hardkeel/quantum-scan 0.2.0 → 0.3.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/cbom.js CHANGED
@@ -1,59 +1,59 @@
1
- // CycloneDX 1.6 Cryptographic Bill of Materials (CBOM) from crypto findings.
2
- const CDX_PRIMITIVE = {
3
- "key-agreement": "key-agree",
4
- "public-key-encryption": "pke",
5
- signature: "signature",
6
- hash: "hash",
7
- "block-cipher": "block-cipher",
8
- "stream-cipher": "stream-cipher",
9
- protocol: "other",
10
- credential: "other",
11
- setting: "other",
12
- };
13
- export function buildCbom(findings, opts) {
14
- const crypto = findings.filter((f) => f.kind === "crypto");
15
- const byAlg = new Map();
16
- for (const f of crypto) {
17
- const key = f.keySize ? `${f.algorithm}-${f.keySize}` : f.algorithm;
18
- byAlg.set(key, [...(byAlg.get(key) ?? []), f]);
19
- }
20
- const components = [...byAlg.entries()].map(([name, fs]) => {
21
- const first = fs[0];
22
- const isProtocol = first.primitive === "protocol";
23
- const cryptoProperties = isProtocol
24
- ? { assetType: "protocol", protocolProperties: { type: "tls", version: "1.0/1.1" } }
25
- : {
26
- assetType: "algorithm",
27
- algorithmProperties: {
28
- primitive: CDX_PRIMITIVE[first.primitive],
29
- // 0 = no security against a quantum attacker (NIST category scale).
30
- nistQuantumSecurityLevel: 0,
31
- ...(first.keySize ? { parameterSetIdentifier: String(first.keySize) } : {}),
32
- },
33
- };
34
- return {
35
- type: "cryptographic-asset",
36
- "bom-ref": `crypto:${name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`,
37
- name,
38
- cryptoProperties,
39
- properties: [
40
- { name: "hardkeel:risk", value: first.risk },
41
- { name: "hardkeel:occurrences", value: String(fs.length) },
42
- ],
43
- evidence: {
44
- occurrences: fs.map((f) => ({ location: f.file, line: f.line })),
45
- },
46
- };
47
- });
48
- return {
49
- bomFormat: "CycloneDX",
50
- specVersion: "1.6",
51
- version: 1,
52
- metadata: {
53
- timestamp: opts.timestamp ?? new Date().toISOString(),
54
- tools: { components: [{ type: "application", name: "Hard Keel Quantum Scan", version: opts.toolVersion }] },
55
- component: { type: "application", name: opts.repo, ...(opts.ref ? { version: opts.ref } : {}) },
56
- },
57
- components,
58
- };
59
- }
1
+ // CycloneDX 1.6 Cryptographic Bill of Materials (CBOM) from crypto findings.
2
+ const CDX_PRIMITIVE = {
3
+ "key-agreement": "key-agree",
4
+ "public-key-encryption": "pke",
5
+ signature: "signature",
6
+ hash: "hash",
7
+ "block-cipher": "block-cipher",
8
+ "stream-cipher": "stream-cipher",
9
+ protocol: "other",
10
+ credential: "other",
11
+ setting: "other",
12
+ };
13
+ export function buildCbom(findings, opts) {
14
+ const crypto = findings.filter((f) => f.kind === "crypto");
15
+ const byAlg = new Map();
16
+ for (const f of crypto) {
17
+ const key = f.keySize ? `${f.algorithm}-${f.keySize}` : f.algorithm;
18
+ byAlg.set(key, [...(byAlg.get(key) ?? []), f]);
19
+ }
20
+ const components = [...byAlg.entries()].map(([name, fs]) => {
21
+ const first = fs[0];
22
+ const isProtocol = first.primitive === "protocol";
23
+ const cryptoProperties = isProtocol
24
+ ? { assetType: "protocol", protocolProperties: { type: "tls", version: "1.0/1.1" } }
25
+ : {
26
+ assetType: "algorithm",
27
+ algorithmProperties: {
28
+ primitive: CDX_PRIMITIVE[first.primitive],
29
+ // 0 = no security against a quantum attacker (NIST category scale).
30
+ nistQuantumSecurityLevel: 0,
31
+ ...(first.keySize ? { parameterSetIdentifier: String(first.keySize) } : {}),
32
+ },
33
+ };
34
+ return {
35
+ type: "cryptographic-asset",
36
+ "bom-ref": `crypto:${name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`,
37
+ name,
38
+ cryptoProperties,
39
+ properties: [
40
+ { name: "hardkeel:risk", value: first.risk },
41
+ { name: "hardkeel:occurrences", value: String(fs.length) },
42
+ ],
43
+ evidence: {
44
+ occurrences: fs.map((f) => ({ location: f.file, line: f.line })),
45
+ },
46
+ };
47
+ });
48
+ return {
49
+ bomFormat: "CycloneDX",
50
+ specVersion: "1.6",
51
+ version: 1,
52
+ metadata: {
53
+ timestamp: opts.timestamp ?? new Date().toISOString(),
54
+ tools: { components: [{ type: "application", name: "Hard Keel Quantum Scan", version: opts.toolVersion }] },
55
+ component: { type: "application", name: opts.repo, ...(opts.ref ? { version: opts.ref } : {}) },
56
+ },
57
+ components,
58
+ };
59
+ }