@annexseal/core 0.0.0-stage → 1.1.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/README.md +11 -2
- package/dist/cra/classifier.d.ts +8 -0
- package/dist/cra/classifier.d.ts.map +1 -0
- package/dist/cra/classifier.js +135 -0
- package/dist/cra/classifier.js.map +1 -0
- package/dist/diff/diff.d.ts +3 -0
- package/dist/diff/diff.d.ts.map +1 -0
- package/dist/diff/diff.js +151 -0
- package/dist/diff/diff.js.map +1 -0
- package/dist/healer/convert.d.ts +5 -0
- package/dist/healer/convert.d.ts.map +1 -0
- package/dist/healer/convert.js +286 -0
- package/dist/healer/convert.js.map +1 -0
- package/dist/healer/heal.d.ts +4 -0
- package/dist/healer/heal.d.ts.map +1 -0
- package/dist/healer/heal.js +624 -0
- package/dist/healer/heal.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/licensing/crypto.d.ts +12 -0
- package/dist/licensing/crypto.d.ts.map +1 -0
- package/dist/licensing/crypto.js +61 -0
- package/dist/licensing/crypto.js.map +1 -0
- package/dist/licensing/ed25519-license.d.ts +17 -0
- package/dist/licensing/ed25519-license.d.ts.map +1 -0
- package/dist/licensing/ed25519-license.js +76 -0
- package/dist/licensing/ed25519-license.js.map +1 -0
- package/dist/merge/merge.d.ts +8 -0
- package/dist/merge/merge.d.ts.map +1 -0
- package/dist/merge/merge.js +168 -0
- package/dist/merge/merge.js.map +1 -0
- package/dist/packager/annex-vii.d.ts +4 -0
- package/dist/packager/annex-vii.d.ts.map +1 -0
- package/dist/packager/annex-vii.js +311 -0
- package/dist/packager/annex-vii.js.map +1 -0
- package/dist/packager/enisa-srp.d.ts +4 -0
- package/dist/packager/enisa-srp.d.ts.map +1 -0
- package/dist/packager/enisa-srp.js +229 -0
- package/dist/packager/enisa-srp.js.map +1 -0
- package/dist/packager/zip.d.ts +16 -0
- package/dist/packager/zip.d.ts.map +1 -0
- package/dist/packager/zip.js +157 -0
- package/dist/packager/zip.js.map +1 -0
- package/dist/parsers/cyclonedx-xml.d.ts +3 -0
- package/dist/parsers/cyclonedx-xml.d.ts.map +1 -0
- package/dist/parsers/cyclonedx-xml.js +231 -0
- package/dist/parsers/cyclonedx-xml.js.map +1 -0
- package/dist/parsers/cyclonedx.d.ts +89 -0
- package/dist/parsers/cyclonedx.d.ts.map +1 -0
- package/dist/parsers/cyclonedx.js +167 -0
- package/dist/parsers/cyclonedx.js.map +1 -0
- package/dist/parsers/detect.d.ts +4 -0
- package/dist/parsers/detect.d.ts.map +1 -0
- package/dist/parsers/detect.js +45 -0
- package/dist/parsers/detect.js.map +1 -0
- package/dist/parsers/lockfiles.d.ts +5 -0
- package/dist/parsers/lockfiles.d.ts.map +1 -0
- package/dist/parsers/lockfiles.js +457 -0
- package/dist/parsers/lockfiles.js.map +1 -0
- package/dist/parsers/spdx-tv.d.ts +7 -0
- package/dist/parsers/spdx-tv.d.ts.map +1 -0
- package/dist/parsers/spdx-tv.js +196 -0
- package/dist/parsers/spdx-tv.js.map +1 -0
- package/dist/parsers/spdx.d.ts +93 -0
- package/dist/parsers/spdx.d.ts.map +1 -0
- package/dist/parsers/spdx.js +309 -0
- package/dist/parsers/spdx.js.map +1 -0
- package/dist/rules/bsi-tr03183-2.d.ts +4 -0
- package/dist/rules/bsi-tr03183-2.d.ts.map +1 -0
- package/dist/rules/bsi-tr03183-2.js +342 -0
- package/dist/rules/bsi-tr03183-2.js.map +1 -0
- package/dist/types.d.ts +386 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validator/license-policy.d.ts +5 -0
- package/dist/validator/license-policy.d.ts.map +1 -0
- package/dist/validator/license-policy.js +95 -0
- package/dist/validator/license-policy.js.map +1 -0
- package/dist/validator/validate.d.ts +10 -0
- package/dist/validator/validate.d.ts.map +1 -0
- package/dist/validator/validate.js +375 -0
- package/dist/validator/validate.js.map +1 -0
- package/dist/vex/cisa-kev-catalog.d.ts +7 -0
- package/dist/vex/cisa-kev-catalog.d.ts.map +1 -0
- package/dist/vex/cisa-kev-catalog.js +7 -0
- package/dist/vex/cisa-kev-catalog.js.map +1 -0
- package/dist/vex/kev-index.d.ts +11 -0
- package/dist/vex/kev-index.d.ts.map +1 -0
- package/dist/vex/kev-index.js +437 -0
- package/dist/vex/kev-index.js.map +1 -0
- package/dist/vex/vex-engine.d.ts +33 -0
- package/dist/vex/vex-engine.d.ts.map +1 -0
- package/dist/vex/vex-engine.js +286 -0
- package/dist/vex/vex-engine.js.map +1 -0
- package/package.json +35 -4
package/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @annexseal/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pure TypeScript, zero-egress EU Cyber Resilience Act (CRA) & BSI TR-03183-2 v2.1.0 SBOM engine powering the [`annexseal`](https://www.npmjs.com/package/annexseal) CLI, GitHub Action, and browser-local workbench (https://annexseal.pages.dev/).
|
|
4
|
+
|
|
5
|
+
Runs identically in Node.js, Browser Web Workers, and Cloudflare Workers:
|
|
6
|
+
- Parses CycloneDX `1.4–1.6` JSON, SPDX `2.3` JSON, and SPDX `3.0.1` JSON-LD
|
|
7
|
+
- Decodes real SRI `SHA-512` hashes from `package-lock.json` + parses `Cargo.lock`, `go.sum`, `requirements.txt`, `pom.xml`
|
|
8
|
+
- Validates 26 BSI TR-03183-2 v2.1.0 & EU CRA rules + emits `SARIF 2.1.0`
|
|
9
|
+
- Deterministically auto-heals & converts losslessly `CycloneDX 1.6 <-> SPDX 3.0.1`
|
|
10
|
+
- Offline CISA KEV matching + `OpenVEX v0.2.0` / `CSAF 2.0` VEX generation
|
|
11
|
+
- Zero-dependency deterministic ZIP + `Ed25519`-signed 10-year CRA Annex VII bundler & tamper verifier
|
|
12
|
+
- ENISA SRP `24h` / `72h` / `14d` manual portal dossier generator
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CraClassificationResult, CraProductCategoryDef } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Complete statutory EU Cyber Resilience Act (Regulation (EU) 2024/2847)
|
|
4
|
+
* Annex III (Important Class I & II) & Annex IV (Critical) Product Risk Catalog.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CRA_PRODUCT_CATEGORIES: readonly CraProductCategoryDef[];
|
|
7
|
+
export declare function classifyCraProduct(categoryId: string): CraClassificationResult;
|
|
8
|
+
//# sourceMappingURL=classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/cra/classifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAElF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,qBAAqB,EAyGlE,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,CA+B9E"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complete statutory EU Cyber Resilience Act (Regulation (EU) 2024/2847)
|
|
3
|
+
* Annex III (Important Class I & II) & Annex IV (Critical) Product Risk Catalog.
|
|
4
|
+
*/
|
|
5
|
+
export const CRA_PRODUCT_CATEGORIES = [
|
|
6
|
+
{
|
|
7
|
+
id: 'default-software-hardware',
|
|
8
|
+
annex: 'default',
|
|
9
|
+
productCategory: 'default',
|
|
10
|
+
title: 'Default Product with Digital Elements (Not Listed in Annex III or IV)',
|
|
11
|
+
examples: 'Standard B2B SaaS clients, mobile apps, consumer smart sensors, desktop utilities, non-security embedded devices (~90% of products)',
|
|
12
|
+
conformityModules: 'Module A (Internal Control — Manufacturer Self-Assessment)',
|
|
13
|
+
notifiedBodyRequired: 'no',
|
|
14
|
+
summary: 'Eligible for self-assessment (Module A) with full Annex I essential cybersecurity requirements, BSI TR-03183-2 SBOM, Annex VII technical documentation, and 24h/72h/14d ENISA SRP vulnerability reporting.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'annex-iii-c1-iam',
|
|
18
|
+
annex: 'annex-iii-class-i',
|
|
19
|
+
productCategory: 'important-class-i',
|
|
20
|
+
title: 'Class I — Identity Management Systems & Privileged Access Management (IAM / PAM)',
|
|
21
|
+
examples: 'SSO/OIDC identity providers, PAM vaults, authentication & access control software/hardware, biometric readers',
|
|
22
|
+
conformityModules: 'Module A (if harmonised standards applied in full) OR Module B+C / Module H (Notified Body)',
|
|
23
|
+
notifiedBodyRequired: 'conditional',
|
|
24
|
+
summary: 'Important Product Class I (Annex III). Self-assessment is permitted ONLY when applicable EU harmonised standards or common specifications are fully applied; otherwise a Notified Body assessment is required.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'annex-iii-c1-browsers-pw',
|
|
28
|
+
annex: 'annex-iii-class-i',
|
|
29
|
+
productCategory: 'important-class-i',
|
|
30
|
+
title: 'Class I — Standalone & Embedded Browsers, Password Managers',
|
|
31
|
+
examples: 'Web browsers, embedded Chromium/WebKit runtimes, enterprise password managers',
|
|
32
|
+
conformityModules: 'Module A (with harmonised standards) OR Module B+C / Module H',
|
|
33
|
+
notifiedBodyRequired: 'conditional',
|
|
34
|
+
summary: 'Important Product Class I under Annex III requiring harmonised standards for self-assessment.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'annex-iii-c1-antivirus-siem',
|
|
38
|
+
annex: 'annex-iii-class-i',
|
|
39
|
+
productCategory: 'important-class-i',
|
|
40
|
+
title: 'Class I — Antivirus / EDR, SIEM, Network Management & VPN Software',
|
|
41
|
+
examples: 'Endpoint detection, malware scanners, SIEM log platforms, VPN clients/gateways, boot managers, PKI / CA software',
|
|
42
|
+
conformityModules: 'Module A (with harmonised standards) OR Module B+C / Module H',
|
|
43
|
+
notifiedBodyRequired: 'conditional',
|
|
44
|
+
summary: 'Security-critical Class I software under Annex III.',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'annex-iii-c1-routers-os',
|
|
48
|
+
annex: 'annex-iii-class-i',
|
|
49
|
+
productCategory: 'important-class-i',
|
|
50
|
+
title: 'Class I — Operating Systems, Routers, Modems & Network Switches',
|
|
51
|
+
examples: 'Embedded Linux/RTOS distributions, consumer/SOHO routers, switches, cellular/fiber modems, microcontrollers with security features',
|
|
52
|
+
conformityModules: 'Module A (with harmonised standards) OR Module B+C / Module H',
|
|
53
|
+
notifiedBodyRequired: 'conditional',
|
|
54
|
+
summary: 'Core networking & OS infrastructure listed under CRA Annex III Class I.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'annex-iii-c1-iot-industrial',
|
|
58
|
+
annex: 'annex-iii-class-i',
|
|
59
|
+
productCategory: 'important-class-i',
|
|
60
|
+
title: 'Class I — Smart Home Security, Wearables & Industrial Automation / PLC Controllers',
|
|
61
|
+
examples: 'Smart locks, security cameras, baby monitors, connected health wearables, industrial controllers not in Class II',
|
|
62
|
+
conformityModules: 'Module A (with harmonised standards) OR Module B+C / Module H',
|
|
63
|
+
notifiedBodyRequired: 'conditional',
|
|
64
|
+
summary: 'Connected physical/industrial controllers classified as Important Class I under Annex III.',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'annex-iii-c2-hypervisors',
|
|
68
|
+
annex: 'annex-iii-class-ii',
|
|
69
|
+
productCategory: 'important-class-ii',
|
|
70
|
+
title: 'Class II — Hypervisors & Container Runtime Systems',
|
|
71
|
+
examples: 'Type-1/Type-2 hypervisors, containerd/CRI-O runtimes, hardware virtualization engines',
|
|
72
|
+
conformityModules: 'Mandatory Third-Party Assessment: Module B+C (EU-Type Exam) OR Module H (Full QA) OR EUCC Certification',
|
|
73
|
+
notifiedBodyRequired: 'yes',
|
|
74
|
+
summary: 'Important Product Class II (Annex III). Manufacturer self-assessment (Module A) is NOT permitted — mandatory third-party Notified Body conformity assessment or European Cybersecurity Certification Scheme is required.',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'annex-iii-c2-firewalls-ids',
|
|
78
|
+
annex: 'annex-iii-class-ii',
|
|
79
|
+
productCategory: 'important-class-ii',
|
|
80
|
+
title: 'Class II — Firewalls, Intrusion Detection & Prevention Systems (IDS / IPS)',
|
|
81
|
+
examples: 'Next-gen enterprise firewalls, OT/ICS network intrusion prevention appliances, WAF hardware/software',
|
|
82
|
+
conformityModules: 'Mandatory Third-Party Assessment: Module B+C OR Module H OR EUCC',
|
|
83
|
+
notifiedBodyRequired: 'yes',
|
|
84
|
+
summary: 'Mandatory third-party conformity assessment under CRA Art. 32(3).',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'annex-iii-c2-tamper-mcu',
|
|
88
|
+
annex: 'annex-iii-class-ii',
|
|
89
|
+
productCategory: 'important-class-ii',
|
|
90
|
+
title: 'Class II — Tamper-Resistant Microprocessors & Microcontrollers',
|
|
91
|
+
examples: 'Secure elements, hardware-isolated cryptographic MCUs, TPM modules',
|
|
92
|
+
conformityModules: 'Mandatory Third-Party Assessment: Module B+C OR Module H OR EUCC',
|
|
93
|
+
notifiedBodyRequired: 'yes',
|
|
94
|
+
summary: 'Tamper-resistant silicon classified as Annex III Class II requiring Notified Body review.',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'annex-iv-hsm-smartcards',
|
|
98
|
+
annex: 'annex-iv-critical',
|
|
99
|
+
productCategory: 'critical',
|
|
100
|
+
title: 'Critical (Annex IV) — Hardware Security Modules (HSMs), Smartcards & Secure Gateways',
|
|
101
|
+
examples: 'Hardware devices with security boxes (HSMs), smart meter gateways, smartcards / eIDAS secure signature creation devices',
|
|
102
|
+
conformityModules: 'European Cybersecurity Certification Scheme (EUCC / CSA — Substantial or High Assurance Level)',
|
|
103
|
+
notifiedBodyRequired: 'yes',
|
|
104
|
+
summary: 'Critical Product with Digital Elements (Annex IV). Subject to mandatory European Cybersecurity Certification under the EU Cybersecurity Act (or Class II third-party conformity where delegated act is pending).',
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
export function classifyCraProduct(categoryId) {
|
|
108
|
+
const selected = CRA_PRODUCT_CATEGORIES.find((c) => c.id === categoryId) ?? CRA_PRODUCT_CATEGORIES[0];
|
|
109
|
+
const notifiedBodyGuidance = selected.notifiedBodyRequired === 'no'
|
|
110
|
+
? 'Not required — Manufacturer Self-Assessment (Module A) is sufficient.'
|
|
111
|
+
: selected.notifiedBodyRequired === 'conditional'
|
|
112
|
+
? 'Avoidable if you apply EU harmonised standards in full; otherwise Notified Body (Module B+C or H) is required.'
|
|
113
|
+
: 'MANDATORY — Third-party Notified Body conformity assessment (Module B+C / H) or EUCC certification is legally required before CE marking.';
|
|
114
|
+
return {
|
|
115
|
+
selected,
|
|
116
|
+
productCategory: selected.productCategory,
|
|
117
|
+
notifiedBodyGuidance,
|
|
118
|
+
minimumSupportMonths: 60,
|
|
119
|
+
mandatoryDeadlines: {
|
|
120
|
+
enisaArt14Reporting: 'September 11, 2026 (ALREADY IN FORCE — 24h / 72h / 14d ENISA SRP)',
|
|
121
|
+
fullCeMarkAndAnnexVii: 'December 11, 2027 (Full CE Mark, SBOM & 10-Year Annex VII Archive)',
|
|
122
|
+
},
|
|
123
|
+
requiredArtifacts: [
|
|
124
|
+
'Machine-readable SBOM (CycloneDX 1.6+ or SPDX 3.0.1+ per BSI TR-03183-2 v2.1.0)',
|
|
125
|
+
'Vulnerability Handling & Coordinated Vulnerability Disclosure (CVD) Policy',
|
|
126
|
+
'Cybersecurity Risk Assessment mapped to CRA Annex I Part I',
|
|
127
|
+
'Minimum 5-Year (60-Month) Support Period Rationale (Art. 13(8))',
|
|
128
|
+
'EU Declaration of Conformity (Annex V) + 10-Year Ed25519-Signed Annex VII Technical File',
|
|
129
|
+
...(selected.notifiedBodyRequired !== 'no'
|
|
130
|
+
? ['Harmonised Standards Compliance Matrix or Notified Body EU-Type Examination Certificate']
|
|
131
|
+
: []),
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/cra/classifier.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqC;IACtE;QACE,EAAE,EAAE,2BAA2B;QAC/B,KAAK,EAAE,SAAS;QAChB,eAAe,EAAE,SAAS;QAC1B,KAAK,EAAE,uEAAuE;QAC9E,QAAQ,EAAE,qIAAqI;QAC/I,iBAAiB,EAAE,4DAA4D;QAC/E,oBAAoB,EAAE,IAAI;QAC1B,OAAO,EACL,4MAA4M;KAC/M;IACD;QACE,EAAE,EAAE,kBAAkB;QACtB,KAAK,EAAE,mBAAmB;QAC1B,eAAe,EAAE,mBAAmB;QACpC,KAAK,EAAE,kFAAkF;QACzF,QAAQ,EAAE,+GAA+G;QACzH,iBAAiB,EAAE,6FAA6F;QAChH,oBAAoB,EAAE,aAAa;QACnC,OAAO,EACL,gNAAgN;KACnN;IACD;QACE,EAAE,EAAE,0BAA0B;QAC9B,KAAK,EAAE,mBAAmB;QAC1B,eAAe,EAAE,mBAAmB;QACpC,KAAK,EAAE,6DAA6D;QACpE,QAAQ,EAAE,+EAA+E;QACzF,iBAAiB,EAAE,+DAA+D;QAClF,oBAAoB,EAAE,aAAa;QACnC,OAAO,EAAE,+FAA+F;KACzG;IACD;QACE,EAAE,EAAE,6BAA6B;QACjC,KAAK,EAAE,mBAAmB;QAC1B,eAAe,EAAE,mBAAmB;QACpC,KAAK,EAAE,oEAAoE;QAC3E,QAAQ,EAAE,kHAAkH;QAC5H,iBAAiB,EAAE,+DAA+D;QAClF,oBAAoB,EAAE,aAAa;QACnC,OAAO,EAAE,qDAAqD;KAC/D;IACD;QACE,EAAE,EAAE,yBAAyB;QAC7B,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G,cAAc,CAyJhB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { classifyLicenseExpression, isCopyleftEscalation } from '../validator/license-policy.js';
|
|
2
|
+
import { validateSbom } from '../validator/validate.js';
|
|
3
|
+
import { compareVersions } from '../vex/kev-index.js';
|
|
4
|
+
function componentIdentityKey(comp) {
|
|
5
|
+
if (comp.purl) {
|
|
6
|
+
// Strip @version and qualifiers so version bumps match the same package
|
|
7
|
+
return comp.purl.split('@')[0].split('?')[0].toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
const groupPrefix = comp.group ? `${comp.group.toLowerCase()}/` : '';
|
|
10
|
+
return `${groupPrefix}${comp.name.toLowerCase()}`;
|
|
11
|
+
}
|
|
12
|
+
function componentNameKey(comp) {
|
|
13
|
+
const groupPrefix = comp.group ? `${comp.group.toLowerCase()}/` : '';
|
|
14
|
+
return `${groupPrefix}${comp.name.toLowerCase()}`;
|
|
15
|
+
}
|
|
16
|
+
export function diffSboms(before, after, beforeLabel = before.rootComponent ? `${before.rootComponent.name}@${before.rootComponent.version}` : 'baseline', afterLabel = after.rootComponent ? `${after.rootComponent.name}@${after.rootComponent.version}` : 'candidate') {
|
|
17
|
+
const beforeReport = validateSbom(before);
|
|
18
|
+
const afterReport = validateSbom(after);
|
|
19
|
+
const beforeMap = new Map();
|
|
20
|
+
const beforeByName = new Map();
|
|
21
|
+
for (const c of before.components) {
|
|
22
|
+
const k = componentIdentityKey(c);
|
|
23
|
+
beforeMap.set(k, c);
|
|
24
|
+
beforeByName.set(componentNameKey(c), { key: k, comp: c });
|
|
25
|
+
}
|
|
26
|
+
const matchedBeforeKeys = new Set();
|
|
27
|
+
const added = [];
|
|
28
|
+
const removed = [];
|
|
29
|
+
const versionChanges = [];
|
|
30
|
+
const licenseChanges = [];
|
|
31
|
+
let unchangedCount = 0;
|
|
32
|
+
const afterEntries = new Map();
|
|
33
|
+
for (const c of after.components)
|
|
34
|
+
afterEntries.set(componentIdentityKey(c), c);
|
|
35
|
+
for (const [key, afterComp] of afterEntries.entries()) {
|
|
36
|
+
let beforeComp = beforeMap.get(key);
|
|
37
|
+
let matchedKey = key;
|
|
38
|
+
if (!beforeComp) {
|
|
39
|
+
const byName = beforeByName.get(componentNameKey(afterComp));
|
|
40
|
+
if (byName && !matchedBeforeKeys.has(byName.key)) {
|
|
41
|
+
beforeComp = byName.comp;
|
|
42
|
+
matchedKey = byName.key;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!beforeComp) {
|
|
46
|
+
added.push(afterComp);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
matchedBeforeKeys.add(matchedKey);
|
|
50
|
+
if (beforeComp.version !== afterComp.version) {
|
|
51
|
+
const cmp = compareVersions(beforeComp.version, afterComp.version);
|
|
52
|
+
versionChanges.push({
|
|
53
|
+
name: afterComp.name || key,
|
|
54
|
+
key,
|
|
55
|
+
beforeVersion: beforeComp.version || 'unknown',
|
|
56
|
+
afterVersion: afterComp.version || 'unknown',
|
|
57
|
+
direction: cmp < 0 ? 'upgraded' : cmp > 0 ? 'downgraded' : 'changed',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
unchangedCount++;
|
|
62
|
+
}
|
|
63
|
+
const beforeLicKey = [...beforeComp.licenses].sort().join(' | ');
|
|
64
|
+
const afterLicKey = [...afterComp.licenses].sort().join(' | ');
|
|
65
|
+
if (beforeLicKey !== afterLicKey) {
|
|
66
|
+
const beforeRisk = classifyLicenseExpression(beforeComp.licenses);
|
|
67
|
+
const afterRisk = classifyLicenseExpression(afterComp.licenses);
|
|
68
|
+
licenseChanges.push({
|
|
69
|
+
name: afterComp.name || key,
|
|
70
|
+
key,
|
|
71
|
+
beforeLicenses: beforeComp.licenses.length > 0 ? beforeComp.licenses : ['NOASSERTION'],
|
|
72
|
+
afterLicenses: afterComp.licenses.length > 0 ? afterComp.licenses : ['NOASSERTION'],
|
|
73
|
+
beforeRisk,
|
|
74
|
+
afterRisk,
|
|
75
|
+
copyleftEscalation: isCopyleftEscalation(beforeRisk, afterRisk),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const [key, beforeComp] of beforeMap.entries()) {
|
|
80
|
+
if (!matchedBeforeKeys.has(key)) {
|
|
81
|
+
removed.push(beforeComp);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const beforeKevSet = new Set(beforeReport.kevMatches.map((m) => `${m.entry.cveId}::${m.componentName.toLowerCase()}`));
|
|
85
|
+
const afterKevSet = new Set(afterReport.kevMatches.map((m) => `${m.entry.cveId}::${m.componentName.toLowerCase()}`));
|
|
86
|
+
const newKevs = afterReport.kevMatches.filter((m) => !beforeKevSet.has(`${m.entry.cveId}::${m.componentName.toLowerCase()}`));
|
|
87
|
+
const resolvedKevs = beforeReport.kevMatches.filter((m) => !afterKevSet.has(`${m.entry.cveId}::${m.componentName.toLowerCase()}`));
|
|
88
|
+
const copyleftEscalations = licenseChanges.filter((l) => l.copyleftEscalation);
|
|
89
|
+
const scoreDelta = afterReport.score - beforeReport.score;
|
|
90
|
+
const mdLines = [
|
|
91
|
+
`## AnnexSeal SBOM Release Diff: \`${beforeLabel}\` → \`${afterLabel}\``,
|
|
92
|
+
'',
|
|
93
|
+
`- **BSI v2.1.0 Score:** ${beforeReport.score}/100 → **${afterReport.score}/100** (${scoreDelta >= 0 ? '+' : ''}${scoreDelta} pts)`,
|
|
94
|
+
`- **Components:** +${added.length} added • -${removed.length} removed • ${versionChanges.length} version change(s) • ${unchangedCount} unchanged`,
|
|
95
|
+
`- **Vulnerability Drift:** ${newKevs.length} new KEV/CVE(s) • ${resolvedKevs.length} resolved KEV/CVE(s)`,
|
|
96
|
+
`- **License Drift:** ${licenseChanges.length} change(s) • **${copyleftEscalations.length} copyleft escalation(s)**`,
|
|
97
|
+
'',
|
|
98
|
+
];
|
|
99
|
+
if (newKevs.length > 0) {
|
|
100
|
+
mdLines.push('### New Vulnerabilities Introduced', '');
|
|
101
|
+
for (const k of newKevs) {
|
|
102
|
+
mdLines.push(`- **${k.entry.cveId}** (CVSS ${k.entry.cvss}) on \`${k.componentName}@${k.componentVersion}\` — ${k.entry.recommendedAction}`);
|
|
103
|
+
}
|
|
104
|
+
mdLines.push('');
|
|
105
|
+
}
|
|
106
|
+
if (copyleftEscalations.length > 0) {
|
|
107
|
+
mdLines.push('### Copyleft License Escalations', '');
|
|
108
|
+
for (const l of copyleftEscalations) {
|
|
109
|
+
mdLines.push(`- **${l.name}**: \`${l.beforeLicenses.join(', ')}\` (${l.beforeRisk}) → \`${l.afterLicenses.join(', ')}\` (**${l.afterRisk}**)`);
|
|
110
|
+
}
|
|
111
|
+
mdLines.push('');
|
|
112
|
+
}
|
|
113
|
+
if (added.length > 0) {
|
|
114
|
+
mdLines.push('### Added Components', '');
|
|
115
|
+
for (const c of added.slice(0, 50)) {
|
|
116
|
+
mdLines.push(`- \`${c.name}@${c.version || 'unknown'}\` (${c.licenses.join(', ') || 'NOASSERTION'})`);
|
|
117
|
+
}
|
|
118
|
+
mdLines.push('');
|
|
119
|
+
}
|
|
120
|
+
if (versionChanges.length > 0) {
|
|
121
|
+
mdLines.push('### Version Changes', '');
|
|
122
|
+
for (const v of versionChanges.slice(0, 50)) {
|
|
123
|
+
mdLines.push(`- **${v.name}**: \`${v.beforeVersion}\` → \`${v.afterVersion}\` (${v.direction})`);
|
|
124
|
+
}
|
|
125
|
+
mdLines.push('');
|
|
126
|
+
}
|
|
127
|
+
if (removed.length > 0) {
|
|
128
|
+
mdLines.push('### Removed Components', '');
|
|
129
|
+
for (const c of removed.slice(0, 50)) {
|
|
130
|
+
mdLines.push(`- \`${c.name}@${c.version || 'unknown'}\``);
|
|
131
|
+
}
|
|
132
|
+
mdLines.push('');
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
beforeLabel,
|
|
136
|
+
afterLabel,
|
|
137
|
+
beforeScore: beforeReport.score,
|
|
138
|
+
afterScore: afterReport.score,
|
|
139
|
+
scoreDelta,
|
|
140
|
+
added,
|
|
141
|
+
removed,
|
|
142
|
+
versionChanges,
|
|
143
|
+
unchangedCount,
|
|
144
|
+
licenseChanges,
|
|
145
|
+
copyleftEscalations,
|
|
146
|
+
newKevs,
|
|
147
|
+
resolvedKevs,
|
|
148
|
+
markdown: mdLines.join('\n'),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/diff/diff.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,SAAS,oBAAoB,CAAC,IAAwB;IACpD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,wEAAwE;QACxE,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAwB;IAChD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC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C;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IAED,OAAO;QACL,WAAW;QACX,UAAU;QACV,WAAW,EAAE,YAAY,CAAC,KAAK;QAC/B,UAAU,EAAE,WAAW,CAAC,KAAK;QAC7B,UAAU;QACV,KAAK;QACL,OAAO;QACP,cAAc;QACd,cAAc;QACd,cAAc;QACd,mBAAmB;QACnB,OAAO;QACP,YAAY;QACZ,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CanonicalSbom } from '../types.js';
|
|
2
|
+
export declare function serializeCycloneDx16(sbom: CanonicalSbom): Record<string, unknown>;
|
|
3
|
+
export declare function serializeSpdx301(sbom: CanonicalSbom): Record<string, unknown>;
|
|
4
|
+
export declare function deterministicUuid(seed: string): string;
|
|
5
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/healer/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwC,aAAa,EAAE,MAAM,aAAa,CAAC;AAoDvF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuCjF;AAiBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsL7E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAetD"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
function serializeCdxOrg(contact) {
|
|
2
|
+
if (!contact || (!contact.name && !contact.email && !contact.url))
|
|
3
|
+
return undefined;
|
|
4
|
+
return {
|
|
5
|
+
...(contact.name ? { name: contact.name } : {}),
|
|
6
|
+
...(contact.url ? { url: [contact.url] } : {}),
|
|
7
|
+
...(contact.email ? { contact: [{ email: contact.email }] } : {}),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function serializeCdxComponent(comp) {
|
|
11
|
+
const supplier = serializeCdxOrg(comp.supplier);
|
|
12
|
+
return {
|
|
13
|
+
type: comp.type || 'library',
|
|
14
|
+
'bom-ref': comp.bomRef,
|
|
15
|
+
...(comp.group ? { group: comp.group } : {}),
|
|
16
|
+
name: comp.name,
|
|
17
|
+
version: comp.version,
|
|
18
|
+
...(comp.description ? { description: comp.description } : {}),
|
|
19
|
+
...(comp.scope ? { scope: comp.scope } : {}),
|
|
20
|
+
...(supplier ? { supplier } : {}),
|
|
21
|
+
...(comp.author ? { author: comp.author } : {}),
|
|
22
|
+
...(comp.purl ? { purl: comp.purl } : {}),
|
|
23
|
+
...(comp.cpe ? { cpe: comp.cpe } : {}),
|
|
24
|
+
...(comp.hashes.length > 0
|
|
25
|
+
? { hashes: comp.hashes.map((h) => ({ alg: h.alg, content: h.content })) }
|
|
26
|
+
: {}),
|
|
27
|
+
...(comp.licenses.length > 0
|
|
28
|
+
? {
|
|
29
|
+
licenses: comp.licenses.map((lic) => /\s+(?:AND|OR|WITH)\s+/.test(lic)
|
|
30
|
+
? { expression: lic }
|
|
31
|
+
: { license: { id: lic } }),
|
|
32
|
+
}
|
|
33
|
+
: {}),
|
|
34
|
+
...(comp.externalReferences.length > 0
|
|
35
|
+
? {
|
|
36
|
+
externalReferences: comp.externalReferences.map((r) => ({
|
|
37
|
+
type: r.type,
|
|
38
|
+
url: r.url,
|
|
39
|
+
...(r.comment ? { comment: r.comment } : {}),
|
|
40
|
+
})),
|
|
41
|
+
}
|
|
42
|
+
: {}),
|
|
43
|
+
...(comp.properties.length > 0
|
|
44
|
+
? { properties: comp.properties.map((p) => ({ name: p.name, value: p.value })) }
|
|
45
|
+
: {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function serializeCycloneDx16(sbom) {
|
|
49
|
+
const supplier = serializeCdxOrg(sbom.creator);
|
|
50
|
+
const metadataProps = [];
|
|
51
|
+
if (sbom.supportPeriodEnd) {
|
|
52
|
+
metadataProps.push({ name: 'cra:support-period-end', value: sbom.supportPeriodEnd });
|
|
53
|
+
}
|
|
54
|
+
metadataProps.push({ name: 'bsi:tr-03183-2:version', value: '2.1.0' });
|
|
55
|
+
const rootComp = sbom.rootComponent ? serializeCdxComponent(sbom.rootComponent) : undefined;
|
|
56
|
+
return {
|
|
57
|
+
$schema: 'http://cyclonedx.org/schema/bom-1.6.schema.json',
|
|
58
|
+
bomFormat: 'CycloneDX',
|
|
59
|
+
specVersion: '1.6',
|
|
60
|
+
serialNumber: sbom.serialNumber ?? `urn:uuid:${deterministicUuid(sbom.rootComponent?.name ?? 'annexseal')}`,
|
|
61
|
+
version: sbom.version ?? 1,
|
|
62
|
+
metadata: {
|
|
63
|
+
timestamp: sbom.timestamp ?? new Date().toISOString().replace(/\.\d{3}Z$/, 'Z'),
|
|
64
|
+
tools: {
|
|
65
|
+
components: (sbom.tools.length > 0
|
|
66
|
+
? sbom.tools
|
|
67
|
+
: [{ vendor: 'AnnexSeal', name: 'AnnexSeal', version: '1.0.0' }]).map((t) => ({
|
|
68
|
+
type: 'application',
|
|
69
|
+
name: t.name,
|
|
70
|
+
...(t.version ? { version: t.version } : {}),
|
|
71
|
+
...(t.vendor ? { publisher: t.vendor } : {}),
|
|
72
|
+
})),
|
|
73
|
+
},
|
|
74
|
+
...(supplier ? { supplier } : {}),
|
|
75
|
+
...(rootComp ? { component: rootComp } : {}),
|
|
76
|
+
properties: metadataProps,
|
|
77
|
+
},
|
|
78
|
+
components: sbom.components.map(serializeCdxComponent),
|
|
79
|
+
dependencies: sbom.dependencies.map((d) => ({
|
|
80
|
+
ref: d.ref,
|
|
81
|
+
dependsOn: d.dependsOn,
|
|
82
|
+
})),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function spdxSafeId(prefix, seed) {
|
|
86
|
+
const clean = seed.replace(/[^A-Za-z0-9._-]/g, '-').replace(/-+/g, '-').slice(0, 80);
|
|
87
|
+
return `https://annexseal.dev/spdx3/${prefix}/${clean || 'item'}`;
|
|
88
|
+
}
|
|
89
|
+
function toSpdx3Alg(alg) {
|
|
90
|
+
const upper = alg.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
|
91
|
+
if (upper === 'SHA512')
|
|
92
|
+
return 'sha512';
|
|
93
|
+
if (upper === 'SHA384')
|
|
94
|
+
return 'sha384';
|
|
95
|
+
if (upper === 'SHA256')
|
|
96
|
+
return 'sha256';
|
|
97
|
+
if (upper === 'SHA1')
|
|
98
|
+
return 'sha1';
|
|
99
|
+
if (upper === 'MD5')
|
|
100
|
+
return 'md5';
|
|
101
|
+
return alg.toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
export function serializeSpdx301(sbom) {
|
|
104
|
+
const timestamp = sbom.timestamp ?? new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
105
|
+
const docUri = sbom.serialNumber?.startsWith('http')
|
|
106
|
+
? sbom.serialNumber
|
|
107
|
+
: `https://annexseal.dev/spdx3/doc/${(sbom.serialNumber ?? 'bom').replace(/^urn:uuid:/, '')}`;
|
|
108
|
+
const creationInfoId = '_:creationInfo_1';
|
|
109
|
+
const creatorAgentId = spdxSafeId('agent', sbom.creator?.name ?? 'manufacturer');
|
|
110
|
+
const toolIds = [];
|
|
111
|
+
const graph = [];
|
|
112
|
+
const tools = sbom.tools.length > 0 ? sbom.tools : [{ name: 'AnnexSeal', version: '1.0.0' }];
|
|
113
|
+
tools.forEach((t, idx) => {
|
|
114
|
+
const tid = spdxSafeId('tool', `${t.name}-${t.version ?? idx}`);
|
|
115
|
+
toolIds.push(tid);
|
|
116
|
+
graph.push({
|
|
117
|
+
type: 'Tool',
|
|
118
|
+
spdxId: tid,
|
|
119
|
+
creationInfo: creationInfoId,
|
|
120
|
+
name: t.name,
|
|
121
|
+
...(t.version ? { comment: `version ${t.version}` } : {}),
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
graph.push({
|
|
125
|
+
type: 'CreationInfo',
|
|
126
|
+
'@id': creationInfoId,
|
|
127
|
+
specVersion: '3.0.1',
|
|
128
|
+
created: timestamp,
|
|
129
|
+
createdBy: [creatorAgentId],
|
|
130
|
+
createdUsing: toolIds,
|
|
131
|
+
});
|
|
132
|
+
const creatorExtIds = [];
|
|
133
|
+
if (sbom.creator?.email) {
|
|
134
|
+
creatorExtIds.push({ externalIdentifierType: 'email', identifier: sbom.creator.email });
|
|
135
|
+
}
|
|
136
|
+
if (sbom.creator?.url) {
|
|
137
|
+
creatorExtIds.push({ externalIdentifierType: 'urlScheme', identifier: sbom.creator.url });
|
|
138
|
+
}
|
|
139
|
+
graph.push({
|
|
140
|
+
type: 'Organization',
|
|
141
|
+
spdxId: creatorAgentId,
|
|
142
|
+
creationInfo: creationInfoId,
|
|
143
|
+
name: sbom.creator?.name ?? 'Manufacturer',
|
|
144
|
+
...(creatorExtIds.length > 0 ? { externalIdentifier: creatorExtIds } : {}),
|
|
145
|
+
});
|
|
146
|
+
const refToSpdxId = new Map();
|
|
147
|
+
const addedAgents = new Set([creatorAgentId]);
|
|
148
|
+
const addedLicenses = new Map();
|
|
149
|
+
const emitPackage = (comp, isRoot) => {
|
|
150
|
+
const pkgId = spdxSafeId(isRoot ? 'root' : 'pkg', comp.bomRef);
|
|
151
|
+
refToSpdxId.set(comp.bomRef, pkgId);
|
|
152
|
+
let supplierId;
|
|
153
|
+
if (comp.supplier?.name || comp.supplier?.email || comp.supplier?.url) {
|
|
154
|
+
supplierId = spdxSafeId('supplier', comp.supplier.name ?? comp.supplier.url ?? comp.bomRef);
|
|
155
|
+
if (!addedAgents.has(supplierId)) {
|
|
156
|
+
addedAgents.add(supplierId);
|
|
157
|
+
const extIds = [];
|
|
158
|
+
if (comp.supplier.email)
|
|
159
|
+
extIds.push({ externalIdentifierType: 'email', identifier: comp.supplier.email });
|
|
160
|
+
if (comp.supplier.url)
|
|
161
|
+
extIds.push({ externalIdentifierType: 'urlScheme', identifier: comp.supplier.url });
|
|
162
|
+
graph.push({
|
|
163
|
+
type: 'Organization',
|
|
164
|
+
spdxId: supplierId,
|
|
165
|
+
creationInfo: creationInfoId,
|
|
166
|
+
name: comp.supplier.name ?? 'Upstream Supplier',
|
|
167
|
+
...(extIds.length > 0 ? { externalIdentifier: extIds } : {}),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const distUrl = comp.externalReferences.find((r) => r.type === 'distribution')?.url;
|
|
172
|
+
const vcsUrl = comp.externalReferences.find((r) => r.type === 'vcs' || r.type === 'website')?.url;
|
|
173
|
+
const secUrl = comp.externalReferences.find((r) => r.type === 'security-contact')?.url;
|
|
174
|
+
const extRefs = [];
|
|
175
|
+
if (vcsUrl)
|
|
176
|
+
extRefs.push({ type: 'ExternalRef', externalRefType: 'vcs', locator: [vcsUrl] });
|
|
177
|
+
if (secUrl)
|
|
178
|
+
extRefs.push({ type: 'ExternalRef', externalRefType: 'securityOther', locator: [secUrl] });
|
|
179
|
+
const bsiExt = { type: 'extension_Extension' };
|
|
180
|
+
let hasBsiExt = false;
|
|
181
|
+
for (const p of comp.properties) {
|
|
182
|
+
if (p.name.startsWith('bsi:')) {
|
|
183
|
+
bsiExt[p.name] = p.value;
|
|
184
|
+
hasBsiExt = true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
graph.push({
|
|
188
|
+
type: 'software_Package',
|
|
189
|
+
spdxId: pkgId,
|
|
190
|
+
creationInfo: creationInfoId,
|
|
191
|
+
name: comp.name,
|
|
192
|
+
software_packageVersion: comp.version,
|
|
193
|
+
software_primaryPurpose: comp.type || 'library',
|
|
194
|
+
...(comp.purl ? { software_packageUrl: comp.purl } : {}),
|
|
195
|
+
...(distUrl ? { software_downloadLocation: distUrl } : {}),
|
|
196
|
+
...(vcsUrl ? { software_homePage: vcsUrl } : {}),
|
|
197
|
+
...(supplierId ? { suppliedBy: supplierId } : {}),
|
|
198
|
+
...(isRoot && sbom.supportPeriodEnd ? { validUntilTime: sbom.supportPeriodEnd } : {}),
|
|
199
|
+
...(comp.cpe
|
|
200
|
+
? {
|
|
201
|
+
externalIdentifier: [{ type: 'ExternalIdentifier', externalIdentifierType: 'cpe23', identifier: comp.cpe }],
|
|
202
|
+
}
|
|
203
|
+
: {}),
|
|
204
|
+
...(comp.hashes.length > 0
|
|
205
|
+
? {
|
|
206
|
+
verifiedUsing: comp.hashes.map((h) => ({
|
|
207
|
+
type: 'Hash',
|
|
208
|
+
algorithm: toSpdx3Alg(h.alg),
|
|
209
|
+
hashValue: h.content,
|
|
210
|
+
})),
|
|
211
|
+
}
|
|
212
|
+
: {}),
|
|
213
|
+
...(extRefs.length > 0 ? { externalRef: extRefs } : {}),
|
|
214
|
+
...(hasBsiExt ? { extension: [bsiExt] } : {}),
|
|
215
|
+
});
|
|
216
|
+
for (const lic of comp.licenses) {
|
|
217
|
+
let licId = addedLicenses.get(lic);
|
|
218
|
+
if (!licId) {
|
|
219
|
+
licId = spdxSafeId('license', lic);
|
|
220
|
+
addedLicenses.set(lic, licId);
|
|
221
|
+
graph.push({
|
|
222
|
+
type: 'simplelicensing_LicenseExpression',
|
|
223
|
+
spdxId: licId,
|
|
224
|
+
creationInfo: creationInfoId,
|
|
225
|
+
simplelicensing_licenseExpression: lic,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
graph.push({
|
|
229
|
+
type: 'Relationship',
|
|
230
|
+
spdxId: spdxSafeId('rel-lic', `${comp.bomRef}-${lic}`),
|
|
231
|
+
creationInfo: creationInfoId,
|
|
232
|
+
relationshipType: 'hasDeclaredLicense',
|
|
233
|
+
from: pkgId,
|
|
234
|
+
to: [licId],
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return pkgId;
|
|
238
|
+
};
|
|
239
|
+
const rootSpdxId = sbom.rootComponent ? emitPackage(sbom.rootComponent, true) : undefined;
|
|
240
|
+
const compSpdxIds = sbom.components.map((c) => emitPackage(c, false));
|
|
241
|
+
sbom.dependencies.forEach((dep, idx) => {
|
|
242
|
+
const fromId = refToSpdxId.get(dep.ref);
|
|
243
|
+
const toIds = dep.dependsOn
|
|
244
|
+
.map((t) => refToSpdxId.get(t))
|
|
245
|
+
.filter((x) => Boolean(x));
|
|
246
|
+
if (fromId && toIds.length > 0) {
|
|
247
|
+
graph.push({
|
|
248
|
+
type: 'Relationship',
|
|
249
|
+
spdxId: spdxSafeId('rel-dep', `${idx}-${dep.ref}`),
|
|
250
|
+
creationInfo: creationInfoId,
|
|
251
|
+
relationshipType: 'dependsOn',
|
|
252
|
+
from: fromId,
|
|
253
|
+
to: toIds,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
graph.unshift({
|
|
258
|
+
type: 'SpdxDocument',
|
|
259
|
+
spdxId: docUri,
|
|
260
|
+
creationInfo: creationInfoId,
|
|
261
|
+
name: sbom.rootComponent ? `${sbom.rootComponent.name}-${sbom.rootComponent.version}-SBOM` : 'AnnexSeal-SBOM',
|
|
262
|
+
profileConformance: ['core', 'software', 'simpleLicensing'],
|
|
263
|
+
...(rootSpdxId ? { rootElement: [rootSpdxId] } : {}),
|
|
264
|
+
element: [...(rootSpdxId ? [rootSpdxId] : []), ...compSpdxIds],
|
|
265
|
+
});
|
|
266
|
+
return {
|
|
267
|
+
'@context': 'https://spdx.org/rdf/3.0.1/spdx-context.jsonld',
|
|
268
|
+
'@graph': graph,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
export function deterministicUuid(seed) {
|
|
272
|
+
// Deterministic RFC-4122 v5-like hex layout from seed (reproducible across runs)
|
|
273
|
+
let h1 = 0x811c9dc5;
|
|
274
|
+
let h2 = 0x9e3779b9;
|
|
275
|
+
for (let i = 0; i < seed.length; i++) {
|
|
276
|
+
const ch = seed.charCodeAt(i);
|
|
277
|
+
h1 = Math.imul(h1 ^ ch, 0x01000193) >>> 0;
|
|
278
|
+
h2 = Math.imul(h2 ^ (ch + i), 0x85ebca6b) >>> 0;
|
|
279
|
+
}
|
|
280
|
+
const hex = h1.toString(16).padStart(8, '0') +
|
|
281
|
+
h2.toString(16).padStart(8, '0') +
|
|
282
|
+
((h1 ^ 0xa5a5a5a5) >>> 0).toString(16).padStart(8, '0') +
|
|
283
|
+
((h2 ^ 0x5a5a5a5a) >>> 0).toString(16).padStart(8, '0');
|
|
284
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=convert.js.map
|