1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
//! EU Cyber Resilience Act checks: Annex/Article gap analysis, hardware
//! (HBOM) components, Article 14 reporting readiness, product-class module
//! attestation / EUCC references, the Annex VIII conformity summary, and the
//! Article 24 open-source-steward profile.
use super::ssdf::{cdxa_note, standard_references_eucc};
use super::*;
use crate::model::{AttestationRuleFamily, EvidenceLevel};
impl ComplianceChecker {
/// Build the per-route evidence checklist (CRA-P4.3). Each route lists
/// the external references manufacturers are expected to attach to
/// satisfy Annex VIII; the `satisfied` flag is computed by scanning the
/// SBOM's `external_refs` and the attached sidecar — and, when the
/// document carries CDXA declarations, resolved fresh attestation
/// evidence targeting a CRA-classified standard satisfies the
/// attestation/DoC rows at Structural/SignaturePresent level while the
/// presence bits keep satisfying at SelfDeclared.
pub(crate) fn build_conformity_summary(
&self,
sbom: &NormalizedSbom,
) -> ConformityAssessmentSummary {
use crate::model::{ConformityRoute, ExternalRefType};
let class = self.effective_product_class();
let route = self.effective_route();
// CDXA attestation evidence classified into the CRA family, fresh
// and fully resolved at the injectable clock. Empty for documents
// without declarations, leaving every row exactly as before.
let ctx = ComplianceContext::new(self, sbom);
let cra_evidence = ctx.evidence_for(AttestationRuleFamily::Cra);
let cdxa_level = cra_evidence.iter().map(|s| s.evidence_level).max();
let cdxa_eucc_level = cra_evidence
.iter()
.filter(|s| standard_references_eucc(s.standard))
.map(|s| s.evidence_level)
.max();
// Strengthen a checklist row with CDXA evidence: the row becomes
// satisfied and the detail names the evidence level; without CDXA
// evidence the legacy (SelfDeclared) verdict passes through.
let cdxa = |satisfied: bool, level: Option<EvidenceLevel>, detail: &str| match level {
Some(level) => (
true,
format!(
"{detail} Satisfied by machine-readable CDXA attestation ({level} evidence); external-reference/sidecar presence remains the self-declared fallback."
),
),
None => (satisfied, detail.to_string()),
};
let any_ext = |needles: &[ExternalRefType]| -> bool {
sbom.components.values().any(|c| {
c.external_refs.iter().any(|r| {
needles
.iter()
.any(|n| std::mem::discriminant(&r.ref_type) == std::mem::discriminant(n))
})
})
};
let any_ext_url_contains = |types: &[ExternalRefType], substr: &str| -> bool {
sbom.components.values().any(|c| {
c.external_refs.iter().any(|r| {
types
.iter()
.any(|t| std::mem::discriminant(&r.ref_type) == std::mem::discriminant(t))
&& r.url.to_lowercase().contains(substr)
})
})
};
let doc_or_ce = any_ext(&[ExternalRefType::Attestation, ExternalRefType::Certification])
|| self
.sidecar
.as_ref()
.is_some_and(|s| s.ce_marking_reference.is_some());
let attestation_present =
any_ext(&[ExternalRefType::Attestation, ExternalRefType::Certification]);
let eucc_present = self
.sidecar
.as_ref()
.is_some_and(|s| s.has_live_eucc_evidence_at(self.now()))
|| any_ext_url_contains(
&[ExternalRefType::Certification, ExternalRefType::Attestation],
"eucc",
)
|| any_ext_url_contains(
&[ExternalRefType::Certification, ExternalRefType::Attestation],
"common-criteria",
);
let mut evidence: Vec<ConformityEvidence> = Vec::new();
let (satisfied, detail) = cdxa(
doc_or_ce,
cdxa_level,
"Annex V — manufacturer's signed declaration. Provide via Attestation/Certification external ref or sidecar ceMarkingReference.",
);
evidence.push(ConformityEvidence {
label: "EU Declaration of Conformity".to_string(),
detail,
satisfied,
});
match route {
ConformityRoute::ModuleA => {
evidence.push(ConformityEvidence {
label: "Internal-control technical file".to_string(),
detail: "Module A — manufacturer holds the technical file at their premises. No external attestation required.".to_string(),
satisfied: true,
});
}
ConformityRoute::ModuleBC => {
let (satisfied, detail) = cdxa(
attestation_present,
cdxa_level,
"Notified-body certificate of EU-type examination — Attestation/Certification external ref.",
);
evidence.push(ConformityEvidence {
label: "EU-type examination certificate (Module B)".to_string(),
detail,
satisfied,
});
let (satisfied, detail) = cdxa(
doc_or_ce,
cdxa_level,
"Manufacturer's declaration that production conforms to the type examined under Module B.",
);
evidence.push(ConformityEvidence {
label: "Production conformity statement (Module C)".to_string(),
detail,
satisfied,
});
}
ConformityRoute::ModuleH => {
let (satisfied, detail) = cdxa(
attestation_present,
cdxa_level,
"Notified-body QMS certification (typically ISO 9001 / ISO/IEC 27001 family) — Certification external ref.",
);
evidence.push(ConformityEvidence {
label: "Quality-management-system certification (Module H)".to_string(),
detail,
satisfied,
});
let (satisfied, detail) = cdxa(
attestation_present,
cdxa_level,
"Notified-body surveillance / re-assessment record — referenced via Attestation external ref.",
);
evidence.push(ConformityEvidence {
label: "QMS surveillance plan".to_string(),
detail,
satisfied,
});
}
ConformityRoute::Eucc => {
// EUCC rows require the stricter subset: CDXA standards
// that both classify as CRA and name EUCC/Common Criteria.
let (satisfied, detail) = cdxa(
eucc_present,
cdxa_eucc_level,
"Common Criteria certificate from an EUCC-accredited ITSEF — Certification external ref whose URL references EUCC or common-criteria.",
);
evidence.push(ConformityEvidence {
label: "EUCC / Common Criteria certificate".to_string(),
detail,
satisfied,
});
let (satisfied, detail) = cdxa(
eucc_present,
cdxa_eucc_level,
"Reference to the ToE (and Protection Profile, when applicable) that the EUCC certificate covers.",
);
evidence.push(ConformityEvidence {
label: "Target of Evaluation reference".to_string(),
detail,
satisfied,
});
}
}
// Article 14 channels are required at all conformity routes once the
// 2026-09-11 deadline applies; surface as evidence rows for
// notified-body checklists.
let psirt = self.sidecar.as_ref().is_some_and(|s| s.psirt_url.is_some());
evidence.push(ConformityEvidence {
label: "PSIRT contact (Art. 14)".to_string(),
detail: "Public PSIRT URL for receiving external vulnerability reports.".to_string(),
satisfied: psirt,
});
let _ = class; // already encoded into the route; keep on the summary
ConformityAssessmentSummary {
product_class: class,
route,
evidence,
}
}
/// CRA gap checks: SBOM freshness (Art. 13(7)), 13(5), 13(9), Annex I Part II supply chain, document integrity
pub(crate) fn check_cra_gaps(&self, sbom: &NormalizedSbom, violations: &mut Vec<Violation>) {
// B1: Art. 13(7) / Annex I Part II (1) — SBOM freshness. Keeping the
// documented component inventory current is the systematic-
// documentation duty applied to the SBOM element. A missing
// timestamp (epoch sentinel) is a freshness gap in its own right, but
// must be reported as "missing", not as a bogus ~20000-day age.
if !sbom.document.has_known_timestamp() {
violations.push(Violation {
severity: ViolationSeverity::Warning,
category: ViolationCategory::DocumentMetadata,
message: "[CRA Art. 13(7) / Annex I Part II (1)] SBOM has no creation timestamp; \
keep the documented component inventory current when components change"
.to_string(),
element: None,
requirement: "CRA Art. 13(7) / Annex I Part II (1): SBOM freshness".to_string(),
rule_id: "SBOM-CRA-SBOM-FRESHNESS",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
} else {
let age_days = (self.now() - sbom.document.created).num_days();
if age_days > 90 {
violations.push(Violation {
severity: ViolationSeverity::Warning,
category: ViolationCategory::DocumentMetadata,
message: format!(
"[CRA Art. 13(7) / Annex I Part II (1)] SBOM is {age_days} days old; keep the documented component inventory current when components change"
),
element: None,
requirement: "CRA Art. 13(7) / Annex I Part II (1): SBOM freshness".to_string(),
rule_id: "SBOM-CRA-SBOM-FRESHNESS",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
} else if age_days > 30 {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::DocumentMetadata,
message: format!(
"[CRA Art. 13(7) / Annex I Part II (1)] SBOM is {age_days} days old; consider regenerating after component changes"
),
element: None,
requirement: "CRA Art. 13(7) / Annex I Part II (1): SBOM freshness".to_string(),
rule_id: "SBOM-CRA-SBOM-FRESHNESS",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
// B2: Art. 13(5) — Third-party due diligence. The CRA does not list
// licences as an SBOM element; licence data is evidence that the
// manufacturer exercised due diligence on integrated third-party
// components.
let total = sbom.components.len();
let without_license = sbom
.components
.values()
.filter(|c| c.licenses.declared.is_empty() && c.licenses.concluded.is_none())
.count();
if without_license > 0 {
let pct = (without_license * 100) / total.max(1);
let severity = if pct > 50 {
ViolationSeverity::Warning
} else {
ViolationSeverity::Info
};
violations.push(Violation {
severity,
category: ViolationCategory::LicenseInfo,
message: format!(
"[CRA Art. 13(5)] {without_license}/{total} components ({pct}%) missing license information needed to evidence third-party due diligence"
),
element: None,
requirement: "CRA Art. 13(5): Third-party due diligence (license tracking)"
.to_string(),
rule_id: "SBOM-CRA-ART-13-5",
component_id: None,
counts: Some(ViolationCounts {
affected: without_license,
total,
}),
standard_refs: Vec::new(),
});
}
// B3: Annex I Part II (1) — documented vulnerability information.
// (Formerly cited Art. 13(9), which is actually the 10-year
// security-update availability obligation.)
// SBOM should either contain vulnerability data or explicitly indicate "none known"
let has_vuln_data = sbom
.components
.values()
.any(|c| !c.vulnerabilities.is_empty());
let has_vuln_assertion = sbom.components.values().any(|comp| {
comp.external_refs.iter().any(|r| {
matches!(
r.ref_type,
crate::model::ExternalRefType::VulnerabilityAssertion
| crate::model::ExternalRefType::ExploitabilityStatement
)
})
});
if !has_vuln_data && !has_vuln_assertion {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::SecurityInfo,
message:
"[CRA Annex I Part II (1)] No vulnerability data or vulnerability assertion found; \
include vulnerability information or a statement of no known vulnerabilities"
.to_string(),
element: None,
requirement: "CRA Annex I Part II (1): Documented vulnerability information"
.to_string(),
rule_id: "SBOM-CRA-VULN-STATEMENT",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// B4: Annex I Part II — Supply-chain transparency.
//
// prEN 40000-1-3 [PRE-7-RQ-03] makes direct dependencies *mandatory*
// and transitive dependencies *recommended*. We split the cohort
// accordingly:
// - direct (1 hop from the primary component) missing supplier:
// Error under CraPhase2, Warning otherwise.
// - transitive missing supplier: Warning under CraPhase2 if >30%,
// Info otherwise.
if !sbom.edges.is_empty() {
let direct_ids = sbom.direct_dependency_ids();
let mut direct_missing: Vec<String> = Vec::new();
let mut transitive_missing: Vec<String> = Vec::new();
for comp in sbom.components.values() {
if comp.supplier.is_some() || comp.author.is_some() {
continue;
}
if direct_ids.contains(&comp.canonical_id) {
direct_missing.push(comp.name.clone());
} else {
transitive_missing.push(comp.name.clone());
}
}
if !direct_missing.is_empty() {
let severity = if matches!(self.level, ComplianceLevel::CraPhase2) {
ViolationSeverity::Error
} else {
ViolationSeverity::Warning
};
let n = direct_missing.len();
violations.push(Violation {
severity,
category: ViolationCategory::SupplierInfo,
message: format!(
"[CRA Annex I Part II / [PRE-7-RQ-03]] {n} direct dependencies missing supplier (mandatory): {}",
truncate_list(&direct_missing, 5)
),
element: None,
requirement: "CRA Annex I Part II / prEN 40000-1-3 [PRE-7-RQ-03]: Direct dependency supplier (mandatory)"
.to_string(),
rule_id: "SBOM-CRA-ANNEX-I-SUPPLY-CHAIN",
component_id: None,
// The message prints only the affected count; the cohort
// is the set of direct dependencies.
counts: Some(ViolationCounts {
affected: n,
total: direct_ids.len(),
}),
standard_refs: Vec::new(),
});
}
let transitive_n = transitive_missing.len();
if transitive_n > 0 {
let denom = total.max(1);
let pct = (transitive_n * 100) / denom;
let severity = if matches!(self.level, ComplianceLevel::CraPhase2) && pct > 30 {
ViolationSeverity::Warning
} else {
ViolationSeverity::Info
};
violations.push(Violation {
severity,
category: ViolationCategory::SupplierInfo,
message: format!(
"[CRA Annex I Part II / [PRE-7-RQ-03]] {transitive_n}/{denom} transitive dependencies ({pct}%) missing supplier (recommended): {}",
truncate_list(&transitive_missing, 5)
),
element: None,
requirement: "CRA Annex I Part II / prEN 40000-1-3 [PRE-7-RQ-03]: Transitive dependency supplier (recommended)"
.to_string(),
rule_id: "SBOM-CRA-ANNEX-I-SUPPLY-CHAIN",
component_id: None,
counts: Some(ViolationCounts {
affected: transitive_n,
total: denom,
}),
standard_refs: Vec::new(),
});
}
}
// B4b: prEN 40000-1-3 [PRE-7-RQ-07-RE] — vendor hash carry-through
// Vendor-supplied components (those with supplier/author and a non-synthetic
// identifier) must carry the upstream-supplied cryptographic hash through
// into the SBOM. Synthetic / format-specific IDs are excluded because they
// typically aren't tied to an upstream artefact at all.
{
let metrics = crate::quality::HashQualityMetrics::from_sbom(sbom);
if let Some(coverage) = metrics.vendor_hash_coverage() {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
let pct = (coverage * 100.0).round() as usize;
// Phase-based thresholds are the floor; a pinned CRA product
// class can only escalate (tighter threshold or stronger
// severity), never weaken the phase gate — supplying MORE
// information must not relax enforcement.
let phase_gate = match self.level {
ComplianceLevel::CraPhase2 if coverage < 0.50 => {
Some((ViolationSeverity::Error, "below 50% threshold".to_string()))
}
ComplianceLevel::CraPhase2 if coverage < 0.80 => Some((
ViolationSeverity::Warning,
"below 80% threshold".to_string(),
)),
ComplianceLevel::CraPhase1 if coverage < 0.50 => Some((
ViolationSeverity::Warning,
"below 50% threshold".to_string(),
)),
_ => None,
};
let class_gate = if self.has_explicit_product_class()
&& coverage < self.vendor_hash_threshold()
{
let sev = self
.class_severity(ClassCheck::VendorHashCoverage)
.unwrap_or(ViolationSeverity::Warning);
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
let thr_pct = (self.vendor_hash_threshold() * 100.0).round() as usize;
Some((
sev,
format!(
"below {thr_pct}% threshold for product class {}",
self.effective_product_class().label()
),
))
} else {
None
};
const fn rank(s: ViolationSeverity) -> u8 {
match s {
ViolationSeverity::Error => 2,
ViolationSeverity::Warning => 1,
ViolationSeverity::Info => 0,
}
}
let (severity, threshold_msg) = match (phase_gate, class_gate) {
// Whichever gate produced the stronger severity also
// supplies the message, so the finding states the
// threshold that was actually breached at that severity.
(Some(p), Some(c)) => {
if rank(p.0) > rank(c.0) {
p
} else {
c
}
}
(Some(p), None) => p,
(None, Some(c)) => c,
(None, None) => (ViolationSeverity::Info, String::new()),
};
if !threshold_msg.is_empty() {
violations.push(Violation {
severity,
category: ViolationCategory::IntegrityInfo,
message: format!(
"[CRA Annex I, Part II / [PRE-7-RQ-07-RE]] Only {}/{} vendor-supplied components ({pct}%) carry an upstream hash — {threshold_msg}",
metrics.vendor_components_with_hash, metrics.vendor_components_total
),
element: None,
requirement: "CRA Annex I Part II / prEN 40000-1-3 [PRE-7-RQ-07-RE]: Vendor hash carry-through".to_string(),
rule_id: "SBOM-CRA-PRE-7-RQ-07-RE",
component_id: None,
// Coverage finding: mirrors the "X/Y carry an
// upstream hash" numbers printed in the message.
counts: Some(ViolationCounts {
affected: metrics.vendor_components_with_hash,
total: metrics.vendor_components_total,
}),
standard_refs: Vec::new(),
});
}
}
}
// B5: Annex I Part I (2)(f) — Document signature/integrity. The
// clause protects the integrity of data, commands, programs and
// configuration (it does not mention authenticity).
// Check for document-level hash, signature, or attestation
let has_doc_integrity = sbom.document.serial_number.is_some()
|| sbom.components.values().any(|comp| {
comp.external_refs.iter().any(|r| {
matches!(
r.ref_type,
crate::model::ExternalRefType::Attestation
| crate::model::ExternalRefType::Certification
) && !r.hashes.is_empty()
})
});
if !has_doc_integrity {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::IntegrityInfo,
message: "[CRA Annex I Part I (2)(f)] Consider adding document-level integrity \
metadata (serial number, digital signature, or attestation with hash)"
.to_string(),
element: None,
requirement: "CRA Annex I Part I (2)(f): Document signature/integrity".to_string(),
rule_id: "SBOM-CRA-DOC-INTEGRITY",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// B5b: Art. 13(2) — Documented risk-assessment reference
// The CRA requires manufacturers to perform and document a risk
// assessment. The SBOM (or sidecar) must reference it; absence is a
// soft Warning under CraPhase2 (Annex V technical-doc requirement).
if matches!(self.level, ComplianceLevel::CraPhase2) {
let has_ref_in_sbom = sbom.components.values().any(|comp| {
comp.external_refs
.iter()
.any(|r| matches!(r.ref_type, crate::model::ExternalRefType::RiskAssessment))
}) || sbom.document.creators.iter().any(|c| {
// Some SBOMs encode the methodology in the creator comment
c.name.to_lowercase().contains("risk assessment")
});
let sidecar_has_ref = self
.sidecar
.as_ref()
.is_some_and(|s| s.risk_assessment_url.is_some());
if !has_ref_in_sbom && !sidecar_has_ref {
violations.push(Violation {
severity: ViolationSeverity::Warning,
category: ViolationCategory::DocumentMetadata,
message: "[CRA Art. 13(2)] No documented risk assessment referenced — add an externalReference of type 'risk-assessment' or supply riskAssessmentUrl in the CRA sidecar".to_string(),
element: None,
requirement: "CRA Art. 13(2): Documented risk assessment".to_string(),
rule_id: "SBOM-CRA-ART-13-2",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
// B5c: Art. 14 reporting-readiness
// Manufacturers must operate channels to:
// - 24-hour early-warn ENISA / CSIRT for actively-exploited vulnerabilities (14(1))
// - 72-hour incident report (14(2))
// - Route through the ENISA single reporting platform (14(7))
// Obligations apply from 11 September 2026; before that, missing
// channels surface as Info ("prepare ahead"); after that, Warning.
if self.level.is_cra() {
self.check_article_14_readiness_at(self.now(), violations);
}
// B6: Art. 13(8) / Annex II (7) — Component lifecycle / EOL detection
// If EOL enrichment data is present, warn about EOL components
let eol_count = sbom
.components
.values()
.filter(|c| {
c.eol
.as_ref()
.is_some_and(|e| e.status == crate::model::EolStatus::EndOfLife)
})
.count();
if eol_count > 0 {
let severity = if self.has_explicit_product_class() {
self.class_severity(ClassCheck::EolComponents)
.unwrap_or(ViolationSeverity::Warning)
} else {
ViolationSeverity::Warning
};
violations.push(Violation {
severity,
category: ViolationCategory::SecurityInfo,
message: format!(
"[CRA Art. 13(8)] {eol_count} component(s) have reached end-of-life and no longer receive security updates"
),
element: None,
requirement: "CRA Art. 13(8): Support period / lifecycle management".to_string(),
rule_id: "SBOM-CRA-ART-13-8",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
let approaching_eol_count = sbom
.components
.values()
.filter(|c| {
c.eol
.as_ref()
.is_some_and(|e| e.status == crate::model::EolStatus::ApproachingEol)
})
.count();
if approaching_eol_count > 0 {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::SecurityInfo,
message: format!(
"[CRA Art. 13(8) / Annex II (7)] {approaching_eol_count} component(s) are approaching end-of-life within 6 months"
),
element: None,
requirement: "CRA Annex II (7): Component lifecycle monitoring".to_string(),
rule_id: "SBOM-CRA-LIFECYCLE",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// SPDX 3.0 profile conformance checks (Phase 6)
if sbom.document.format == crate::model::SbomFormat::Spdx
&& sbom.document.spec_version.starts_with("3.")
{
// Check if Security profile is declared when vulnerabilities are present
let has_vulns = sbom
.components
.values()
.any(|c| !c.vulnerabilities.is_empty());
let has_security_profile = sbom
.document
.distribution_classification
.as_ref()
.is_some_and(|p| p.to_lowercase().contains("security"));
if has_vulns && !has_security_profile {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::DocumentMetadata,
message:
"[CRA Annex I Part II (4)] SPDX 3.0 document contains vulnerabilities but does not declare Security profile conformance; declare profileConformance: [\"security\"] so vulnerability information is conveyed completely"
.to_string(),
element: None,
requirement: "CRA Annex I Part II (4): SPDX 3.0 Security profile conformance"
.to_string(),
rule_id: "SBOM-CRA-VULN-METADATA",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// Check if SimpleLicensing profile is declared when licenses are tracked
let has_licenses = sbom
.components
.values()
.any(|c| !c.licenses.declared.is_empty() || c.licenses.concluded.is_some());
let has_licensing_profile = sbom
.document
.distribution_classification
.as_ref()
.is_some_and(|p| {
p.to_lowercase().contains("simplelicensing")
|| p.to_lowercase().contains("licensing")
});
if has_licenses && !has_licensing_profile {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::LicenseInfo,
message:
"[CRA Art. 13(5)] SPDX 3.0 document tracks licenses but does not declare SimpleLicensing profile conformance; declare profileConformance: [\"simpleLicensing\"] to support third-party due diligence"
.to_string(),
element: None,
requirement: "CRA Art. 13(5): SPDX 3.0 SimpleLicensing profile conformance"
.to_string(),
rule_id: "SBOM-CRA-ART-13-5",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
// CRA-P3.2: Class-conditional EUCC and Module-attestation references
// (only fire when the operator pinned a product class — preserves
// pre-P3.2 behavior for callers that didn't opt in).
if self.has_explicit_product_class() {
self.check_class_eucc_reference(sbom, violations);
self.check_class_module_attestation(sbom, violations);
}
// CRA-P5.5: prEN 40000-1-2/1-4 controls-assertion sanity checks.
// Only fires when the sidecar provides an annex_i_part_i_controls
// block; otherwise the section is silently skipped.
self.check_controls_assertion(violations);
}
/// Cross-check the sidecar `annex_i_part_i_controls` block. A control
/// claimed `satisfied = true` without an `evidence_url` produces a
/// Warning (un-evidenced claim); claimed `satisfied = false` is fine
/// (manufacturer is being honest about a gap).
pub(crate) fn check_controls_assertion(&self, violations: &mut Vec<Violation>) {
let Some(sidecar) = self.sidecar.as_ref() else {
return;
};
if sidecar.annex_i_part_i_controls.is_empty() {
return;
}
for (id, claim) in &sidecar.annex_i_part_i_controls {
if claim.satisfied && claim.evidence_url.is_none() {
violations.push(Violation {
severity: ViolationSeverity::Warning,
category: ViolationCategory::DocumentMetadata,
message: format!(
"[CRA Annex I Part I {id}] Sidecar claims control satisfied but provides no `evidence_url` — un-evidenced claims should be reviewed before submission"
),
element: None,
requirement: format!(
"CRA Annex I Part I {id}: controls-assertion evidence (prEN 40000-1-2)"
),
rule_id: "SBOM-CRA-ANNEX-I-CONTROLS",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
}
/// EUCC (Common Criteria) certificate / Target-of-Evaluation reference.
///
/// `ImportantClass2` → Info if missing (recommended); `Critical` → Error
/// if missing (Annex IV mandates EUCC). Lower classes: skipped.
pub(crate) fn check_class_eucc_reference(
&self,
sbom: &NormalizedSbom,
violations: &mut Vec<Violation>,
) {
let Some(severity) = self.class_severity(ClassCheck::EuccReference) else {
return;
};
// The sidecar's dedicated EUCC evidence fields are authoritative;
// the URL-substring scan over external refs is only a fallback.
// Empty strings and expired validity dates do not count.
let sidecar_has_eucc = self
.sidecar
.as_ref()
.is_some_and(|s| s.has_live_eucc_evidence_at(self.now()));
// Fresh, fully-resolved CDXA attestation of a CRA-classified
// standard naming EUCC/Common Criteria satisfies at Structural/
// SignaturePresent level; sidecar fields and URL-substring refs
// remain valid SelfDeclared fallbacks.
let ctx = ComplianceContext::new(self, sbom);
let cdxa_eucc_attested = ctx
.evidence_for(AttestationRuleFamily::Cra)
.iter()
.any(|s| standard_references_eucc(s.standard));
let has_eucc_ref = sidecar_has_eucc
|| cdxa_eucc_attested
|| sbom.components.values().any(|comp| {
comp.external_refs.iter().any(|r| {
let url_lower = r.url.to_lowercase();
matches!(
r.ref_type,
crate::model::ExternalRefType::Certification
| crate::model::ExternalRefType::Attestation
) && (url_lower.contains("eucc")
|| url_lower.contains("common-criteria")
|| url_lower.contains("commoncriteria"))
})
});
if !has_eucc_ref {
let mut message = format!(
"[CRA Annex IV / EUCC] Product class {} requires (or strongly recommends) a reference to a Common Criteria / EUCC certificate or Target of Evaluation",
self.effective_product_class().label()
);
if let Some(note) = cdxa_note(
ctx.attestation_declarations(),
AttestationRuleFamily::Cra,
&|s, _| standard_references_eucc(s),
self.now(),
"an EUCC / Common Criteria certification",
) {
message.push_str(¬e);
}
violations.push(Violation {
severity,
category: ViolationCategory::DocumentMetadata,
message,
element: None,
requirement: "CRA Annex IV: EUCC reference (Common Criteria certificate)"
.to_string(),
rule_id: "SBOM-CRA-ANNEX-IV",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
/// Conformity-assessment-module attestation reference.
///
/// Module B+C / H / EUCC routes require an attestation external reference
/// (notified-body certificate, QA-system certification, EUCC certificate).
/// Module A (self-assessment) is skipped. Severity scales with class.
pub(crate) fn check_class_module_attestation(
&self,
sbom: &NormalizedSbom,
violations: &mut Vec<Violation>,
) {
use crate::model::ConformityRoute as R;
let Some(severity) = self.class_severity(ClassCheck::ModuleAttestation) else {
return;
};
let route = self.effective_route();
if matches!(route, R::ModuleA) {
return; // Module A self-assessment doesn't require external attestation
}
let has_attestation = sbom.components.values().any(|comp| {
comp.external_refs.iter().any(|r| {
matches!(
r.ref_type,
crate::model::ExternalRefType::Attestation
| crate::model::ExternalRefType::Certification
)
})
});
if !has_attestation {
violations.push(Violation {
severity,
category: ViolationCategory::DocumentMetadata,
message: format!(
"[CRA Annex VIII / {}] No attestation or certification external reference found — required for the {} conformity route",
route.label(),
route.label()
),
element: None,
requirement: format!(
"CRA Annex VIII: {} attestation reference",
route.label()
),
rule_id: "SBOM-CRA-ANNEX-VIII",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
/// CRA Article 14 reporting-readiness check.
///
/// Verifies the manufacturer has documented channels for the obligations
/// that apply from 11 September 2026:
/// - 14(1) 24-hour early warning to ENISA/CSIRTs on actively-exploited vulns
/// - 14(2) 72-hour incident report
/// - 14(7) routing through the ENISA single reporting platform
///
/// Pre-deadline: missing channels surface as Info (preparation guidance).
/// Post-deadline: missing channels become Warning. The CRA never demands
/// the channel reside *inside* the SBOM — most manufacturers will set
/// these via `CraSidecarMetadata`.
/// Internal entry point taking an explicit `now` so tests can pin it.
pub(crate) fn check_article_14_readiness_at(
&self,
now: chrono::DateTime<chrono::Utc>,
violations: &mut Vec<Violation>,
) {
// Article 14 reporting-obligation deadline.
// CRA enters into force 2024-12-10; reporting obligations apply
// 21 months later on 2026-09-11.
let deadline: chrono::DateTime<chrono::Utc> =
chrono::DateTime::parse_from_rfc3339("2026-09-11T00:00:00Z")
.expect("hard-coded deadline literal is RFC-3339")
.into();
let art_14_active = now >= deadline;
// Severity escalation by product class: when class is explicitly set
// and ≥ ImportantClass2, post-deadline missing channels become Errors
// rather than Warnings ([CRA-P3.2 calibration]).
let post_deadline_severity = if art_14_active {
if self.has_explicit_product_class() {
self.class_severity(ClassCheck::Psirt)
.unwrap_or(ViolationSeverity::Warning)
} else {
ViolationSeverity::Warning
}
} else {
ViolationSeverity::Info
};
let sidecar = self.sidecar.as_ref();
let psirt_present = sidecar.is_some_and(|s| s.psirt_url.is_some());
if !psirt_present {
let prefix = if art_14_active {
"[CRA Art. 14] PSIRT URL missing — required to handle external vulnerability reports"
} else {
"[CRA Art. 14] PSIRT URL missing — Article 14 obligations begin 2026-09-11; document the PSIRT channel ahead of the deadline"
};
violations.push(Violation {
severity: post_deadline_severity,
category: ViolationCategory::SecurityInfo,
message: prefix.to_string(),
element: None,
requirement: "CRA Art. 14: PSIRT contact for external vulnerability reports"
.to_string(),
rule_id: "SBOM-CRA-ART-14",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
let ew_present = sidecar.is_some_and(|s| s.early_warning_contact.is_some());
if !ew_present {
let msg = if art_14_active {
"[CRA Art. 14(2)(a)] 24-hour early-warning channel missing — required when an actively-exploited vulnerability is identified"
} else {
"[CRA Art. 14(2)(a)] 24-hour early-warning channel missing — document the ENISA/CSIRT contact before 2026-09-11"
};
violations.push(Violation {
severity: post_deadline_severity,
category: ViolationCategory::SecurityInfo,
message: msg.to_string(),
element: None,
requirement: "CRA Art. 14(2)(a): 24-hour early-warning channel".to_string(),
rule_id: "SBOM-CRA-ART-14",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
let ir_present = sidecar.is_some_and(|s| s.incident_report_contact.is_some());
if !ir_present {
let msg = if art_14_active {
"[CRA Art. 14(2)(b) / 14(4)(b)] 72-hour notification channel missing — required for actively exploited vulnerabilities and severe incidents"
} else {
"[CRA Art. 14(2)(b) / 14(4)(b)] 72-hour notification channel missing — document this contact before 2026-09-11"
};
violations.push(Violation {
severity: post_deadline_severity,
category: ViolationCategory::SecurityInfo,
message: msg.to_string(),
element: None,
requirement: "CRA Art. 14(2)(b): 72-hour notification channel".to_string(),
rule_id: "SBOM-CRA-ART-14",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// ENISA single reporting platform (Art. 14(7)) — the official URL is
// not yet published. We accept any sidecar identifier as a forward-
// compatible placeholder and only surface as Info regardless of date.
let enisa_present = sidecar.is_some_and(|s| s.enisa_reporting_platform_id.is_some());
if !enisa_present {
violations.push(Violation {
severity: ViolationSeverity::Info,
category: ViolationCategory::SecurityInfo,
message: "[CRA Art. 14(7)] No ENISA single reporting platform identifier — track ENISA publication and add `enisaReportingPlatformId` to the CRA sidecar when available"
.to_string(),
element: None,
requirement: "CRA Art. 14(7): ENISA single reporting platform".to_string(),
rule_id: "SBOM-CRA-ART-14",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
}
/// Hardware-SBOM (HBOM) compliance check.
///
/// Implements CRA prEN 40000-1-3 `[PRE-8-RQ-02]`: hardware components must
/// carry producer, component name, unique identifier, and firmware version
/// where applicable. Operates on components classified as
/// `Device`, `Firmware`, or `DeviceDriver`. The check is silent when the
/// SBOM contains no hardware components, so software-only SBOMs are
/// unaffected.
pub(crate) fn check_hardware_components(
&self,
sbom: &NormalizedSbom,
violations: &mut Vec<Violation>,
) {
use crate::model::{ComponentType, IdSource};
let is_hardware_kind = |t: &ComponentType| {
matches!(
t,
ComponentType::Device | ComponentType::Firmware | ComponentType::DeviceDriver
)
};
let hardware_components: Vec<_> = sbom
.components
.values()
.filter(|c| is_hardware_kind(&c.component_type))
.collect();
if hardware_components.is_empty() {
return;
}
for comp in hardware_components {
// 1) Producer (supplier or author) must be set
if comp.supplier.is_none() && comp.author.is_none() {
violations.push(Violation {
severity: ViolationSeverity::Error,
category: ViolationCategory::SupplierInfo,
message: format!(
"[CRA prEN 40000-1-3 [PRE-8-RQ-02]] Hardware component '{}' missing producer (supplier or author)",
comp.name
),
element: Some(comp.name.clone()),
requirement: "CRA prEN 40000-1-3 [PRE-8-RQ-02]: Hardware producer".to_string(),
rule_id: "SBOM-CRA-PRE-8-RQ-02",
component_id: Some(comp.canonical_id.value().to_string()),
counts: None,
standard_refs: Vec::new(),
});
}
// 2) Identifier must be a real (non-synthetic / non-format-specific) one
if matches!(
comp.canonical_id.source(),
IdSource::Synthetic | IdSource::FormatSpecific
) {
violations.push(Violation {
severity: ViolationSeverity::Error,
category: ViolationCategory::ComponentIdentification,
message: format!(
"[CRA prEN 40000-1-3 [PRE-8-RQ-02]] Hardware component '{}' missing unique identifier (PURL/CPE/SWHID/SWID)",
comp.name
),
element: Some(comp.name.clone()),
requirement: "CRA prEN 40000-1-3 [PRE-8-RQ-02]: Hardware identifier".to_string(),
rule_id: "SBOM-CRA-PRE-8-RQ-02",
component_id: Some(comp.canonical_id.value().to_string()),
counts: None,
standard_refs: Vec::new(),
});
}
// 3) Firmware components must carry a version (the firmware version itself).
if matches!(comp.component_type, ComponentType::Firmware) && comp.version.is_none() {
violations.push(Violation {
severity: ViolationSeverity::Error,
category: ViolationCategory::ComponentIdentification,
message: format!(
"[CRA prEN 40000-1-3 [PRE-8-RQ-02]] Firmware component '{}' missing firmware version",
comp.name
),
element: Some(comp.name.clone()),
requirement: "CRA prEN 40000-1-3 [PRE-8-RQ-02]: Firmware version".to_string(),
rule_id: "SBOM-CRA-PRE-8-RQ-02",
component_id: Some(comp.canonical_id.value().to_string()),
counts: None,
standard_refs: Vec::new(),
});
}
// 4) Devices: should declare a version, OR depend on a Firmware component.
if matches!(comp.component_type, ComponentType::Device) && comp.version.is_none() {
let has_firmware_dep = sbom.edges.iter().any(|e| {
e.from == comp.canonical_id
&& sbom.components.get(&e.to).is_some_and(|child| {
matches!(child.component_type, ComponentType::Firmware)
})
});
if !has_firmware_dep {
violations.push(Violation {
severity: ViolationSeverity::Warning,
category: ViolationCategory::ComponentIdentification,
message: format!(
"[CRA prEN 40000-1-3 [PRE-8-RQ-02]] Device component '{}' has no version and no associated firmware component",
comp.name
),
element: Some(comp.name.clone()),
requirement: "CRA prEN 40000-1-3 [PRE-8-RQ-02]: Device firmware association".to_string(),
rule_id: "SBOM-CRA-PRE-8-RQ-02",
component_id: Some(comp.canonical_id.value().to_string()),
counts: None,
standard_refs: Vec::new(),
});
}
}
}
}
// ════════════════════════════════════════════════════════════════════
// CRA Article 24 — Open-source software steward profile
// ════════════════════════════════════════════════════════════════════
//
// Stewards (e.g., Eclipse Foundation, Apache, Linux Foundation) supply
// software under the CRA but with reduced obligations:
//
// | Obligation | Manufacturer (Phase1/2) | Steward (Art. 24) |
// |-----------------------------------|-------------------------|-------------------|
// | SBOM | Required | Required |
// | Vulnerability handling process | Required (Annex I II) | Required |
// | Coordinated disclosure policy | Required (Annex I II (5)) | Required |
// | Manufacturer email contact | Required (Art. 13(16)) | NOT required |
// | EU Declaration of Conformity | Required | NOT required |
// | Conformity-assessment module | Required | NOT applied |
// | Article 14 reporting channels | Required | NOT applied |
// | Vendor-hash carry-through | Required (Phase 2) | Recommended only |
//
// The check below runs the must-have subset and skips the rest.
pub(crate) fn check_cra_oss_steward(
&self,
sbom: &NormalizedSbom,
violations: &mut Vec<Violation>,
) {
// -- Must-haves (Article 24 floor) ----------------------------------
// SBOM completeness — basic structural requirements (re-uses the
// standard component check; manufacturer-only sub-checks are gated
// off because we don't run check_cra_gaps for stewards).
self.check_components(sbom, violations);
self.check_dependencies(sbom, violations);
// Vulnerability-handling process (Annex I Part II): require either
// a vulnerability-disclosure URL on the document or a SecurityContact
// / Advisories external reference on at least one component, OR
// sidecar-supplied PSIRT URL.
let has_vuln_handling = sbom.document.vulnerability_disclosure_url.is_some()
|| sbom.document.security_contact.is_some()
|| manufacturer_scope_components(sbom).iter().any(|c| {
c.external_refs.iter().any(|r| {
matches!(
r.ref_type,
crate::model::ExternalRefType::SecurityContact
| crate::model::ExternalRefType::Advisories
| crate::model::ExternalRefType::VulnerabilityAssertion
)
})
})
|| self
.sidecar
.as_ref()
.is_some_and(|s| s.psirt_url.is_some() || s.vulnerability_disclosure_url.is_some());
if !has_vuln_handling {
violations.push(Violation {
severity: ViolationSeverity::Error,
category: ViolationCategory::SecurityInfo,
message: "[CRA Art. 24 / Annex I Part II] OSS steward must operate a vulnerability-handling process — set a document-level security contact or vulnerability-disclosure URL, declare a SecurityContact / Advisories external reference, or set psirt_url / vulnerability_disclosure_url in the sidecar".to_string(),
element: None,
requirement: "CRA Art. 24: Vulnerability-handling process (steward floor)"
.to_string(),
rule_id: "SBOM-CRA-ART-24",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// Coordinated vulnerability disclosure policy (Annex I Part II (5)):
// require either an Advisories reference or sidecar-supplied
// coordinated_disclosure_policy_url.
let has_cvd_policy = manufacturer_scope_components(sbom).iter().any(|c| {
c.external_refs
.iter()
.any(|r| matches!(r.ref_type, crate::model::ExternalRefType::Advisories))
}) || self
.sidecar
.as_ref()
.is_some_and(|s| s.coordinated_disclosure_policy_url.is_some());
if !has_cvd_policy {
violations.push(Violation {
severity: ViolationSeverity::Warning,
category: ViolationCategory::SecurityInfo,
message: "[CRA Annex I Part II (5)] OSS steward should publish a coordinated vulnerability disclosure (CVD) policy — add an Advisories external reference or set coordinated_disclosure_policy_url in the sidecar".to_string(),
element: None,
requirement: "CRA Annex I Part II (5): Coordinated vulnerability disclosure policy"
.to_string(),
rule_id: "SBOM-CRA-CVD-POLICY",
component_id: None,
counts: None,
standard_refs: Vec::new(),
});
}
// Format-specific (CycloneDX/SPDX integrity, e.g., bomFormat field)
self.check_format_specific(sbom, violations);
// -- Explicitly NOT enforced ----------------------------------------
// - Manufacturer email contact (Art. 13(16))
// - EU Declaration of Conformity reference (Annex V)
// - Conformity-assessment module attestation
// - Article 14 reporting channels (24h / 72h / ENISA)
// - Hardware component requirements
// - Vendor-hash carry-through threshold
}
}