1- use crate :: csaf:: csaf2_0:: schema:: { Branch , CategoryOfTheRemediation , CommonSecurityAdvisoryFramework , DocumentGenerator , DocumentLevelMetaData , DocumentStatus , Flag , FullProductNameT , HelperToIdentifyTheProduct , Id , Involvement , LabelOfTlp , Note , ProductGroup , ProductStatus , ProductTree , Relationship , Remediation , Revision , RulesForSharingDocument , Score , Threat , Tracking , TrafficLightProtocolTlp , Vulnerability } ;
2- use crate :: csaf:: csaf2_1:: schema:: { CategoryOfTheRemediation as Remediation21 , DocumentStatus as Status21 , Epss , LabelOfTlp as Tlp21 } ;
3- use crate :: csaf:: getter_traits:: { BranchTrait , CsafTrait , DistributionTrait , DocumentTrait , FlagTrait , ProductTrait , GeneratorTrait , InvolvementTrait , MetricTrait , ProductGroupTrait , ProductIdentificationHelperTrait , ProductStatusTrait , ProductTreeTrait , RelationshipTrait , RemediationTrait , RevisionTrait , SharingGroupTrait , ThreatTrait , TlpTrait , TrackingTrait , VulnerabilityTrait , ContentTrait , VulnerabilityIdTrait , NoteTrait , WithGroupIds } ;
4- use std:: ops:: Deref ;
5- use serde:: de:: Error ;
6- use serde_json:: { Map , Value } ;
1+ use crate :: csaf:: csaf2_0:: schema:: {
2+ Branch , CategoryOfTheRemediation , CommonSecurityAdvisoryFramework , DocumentGenerator ,
3+ DocumentLevelMetaData , DocumentStatus , Flag , FullProductNameT , HelperToIdentifyTheProduct , Id ,
4+ Involvement , LabelOfTlp , Note , ProductGroup , ProductStatus , ProductTree , Relationship ,
5+ Remediation , Revision , RulesForSharingDocument , Score , Threat , Tracking ,
6+ TrafficLightProtocolTlp , Vulnerability ,
7+ } ;
8+ use crate :: csaf:: csaf2_1:: schema:: {
9+ CategoryOfTheRemediation as Remediation21 , DocumentStatus as Status21 , Epss ,
10+ LabelOfTlp as Tlp21 ,
11+ } ;
712use crate :: csaf:: csaf2_1:: ssvc_schema:: SsvcV1 ;
13+ use crate :: csaf:: getter_traits:: {
14+ BranchTrait , ContentTrait , CsafTrait , DistributionTrait , DocumentTrait , FlagTrait ,
15+ GeneratorTrait , InvolvementTrait , MetricTrait , NoteTrait , ProductGroupTrait ,
16+ ProductIdentificationHelperTrait , ProductStatusTrait , ProductTrait , ProductTreeTrait ,
17+ RelationshipTrait , RemediationTrait , RevisionTrait , SharingGroupTrait , ThreatTrait , TlpTrait ,
18+ TrackingTrait , VulnerabilityIdTrait , VulnerabilityTrait , WithGroupIds ,
19+ } ;
820use crate :: csaf:: validation:: ValidationError ;
21+ use serde:: de:: Error ;
22+ use serde_json:: { Map , Value } ;
23+ use std:: ops:: Deref ;
924
1025impl WithGroupIds for Remediation {
11- fn get_group_ids ( & self ) -> Option < impl Iterator < Item =& String > + ' _ > {
12- self . group_ids . as_ref ( ) . map ( |g| ( * g) . iter ( ) . map ( |x| x. deref ( ) ) )
26+ fn get_group_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
27+ self . group_ids
28+ . as_ref ( )
29+ . map ( |g| ( * g) . iter ( ) . map ( |x| x. deref ( ) ) )
1330 }
1431}
1532
@@ -35,7 +52,9 @@ impl RemediationTrait for Remediation {
3552 }
3653
3754 fn get_product_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
38- self . product_ids . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
55+ self . product_ids
56+ . as_ref ( )
57+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
3958 }
4059
4160 fn get_date ( & self ) -> & Option < String > {
@@ -45,39 +64,53 @@ impl RemediationTrait for Remediation {
4564
4665impl ProductStatusTrait for ProductStatus {
4766 fn get_first_affected ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
48- self . first_affected . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
67+ self . first_affected
68+ . as_ref ( )
69+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
4970 }
5071
5172 fn get_first_fixed ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
52- self . first_fixed . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
73+ self . first_fixed
74+ . as_ref ( )
75+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
5376 }
5477
5578 fn get_fixed ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
5679 self . fixed . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
5780 }
5881
5982 fn get_known_affected ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
60- self . known_affected . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
83+ self . known_affected
84+ . as_ref ( )
85+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
6186 }
6287
6388 fn get_known_not_affected ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
64- self . known_not_affected . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
89+ self . known_not_affected
90+ . as_ref ( )
91+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
6592 }
6693
6794 fn get_last_affected ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
68- self . last_affected . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
95+ self . last_affected
96+ . as_ref ( )
97+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
6998 }
7099
71100 fn get_recommended ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
72- self . recommended . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
101+ self . recommended
102+ . as_ref ( )
103+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
73104 }
74105
75106 fn get_under_investigation ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
76- self . under_investigation . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
107+ self . under_investigation
108+ . as_ref ( )
109+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
77110 }
78111
79112 /// Not specified for CSAF 2.0, so `None`
80- fn get_unknown ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
113+ fn get_unknown ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
81114 None :: < std:: iter:: Empty < & String > >
82115 }
83116}
@@ -104,7 +137,9 @@ impl ContentTrait for Score {
104137 }
105138
106139 fn get_ssvc_v1 ( & self ) -> Result < SsvcV1 , serde_json:: Error > {
107- Err ( serde_json:: Error :: custom ( "SSVC metrics are not implemented in CSAF 2.0" ) )
140+ Err ( serde_json:: Error :: custom (
141+ "SSVC metrics are not implemented in CSAF 2.0" ,
142+ ) )
108143 }
109144
110145 fn get_cvss_v2 ( & self ) -> Option < & Map < String , Value > > {
@@ -141,13 +176,17 @@ impl ContentTrait for Score {
141176
142177impl WithGroupIds for Threat {
143178 fn get_group_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
144- self . group_ids . as_ref ( ) . map ( |g| ( * g) . iter ( ) . map ( |x| x. deref ( ) ) )
179+ self . group_ids
180+ . as_ref ( )
181+ . map ( |g| ( * g) . iter ( ) . map ( |x| x. deref ( ) ) )
145182 }
146183}
147184
148185impl ThreatTrait for Threat {
149186 fn get_product_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
150- self . product_ids . as_ref ( ) . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
187+ self . product_ids
188+ . as_ref ( )
189+ . map ( |p| ( * p) . iter ( ) . map ( |x| x. deref ( ) ) )
151190 }
152191
153192 fn get_date ( & self ) -> & Option < String > {
@@ -199,15 +238,15 @@ impl VulnerabilityTrait for Vulnerability {
199238 }
200239
201240 fn get_cve ( & self ) -> Option < & String > {
202- self . cve . as_ref ( ) . map ( |x| x . deref ( ) )
241+ self . cve . as_deref ( )
203242 }
204-
243+
205244 fn get_ids ( & self ) -> & Option < Vec < Self :: VulnerabilityIdType > > {
206245 & self . ids
207246 }
208247
209248 fn get_notes ( & self ) -> Option < & Vec < Self :: NoteType > > {
210- self . notes . as_ref ( ) . map ( |x| x . deref ( ) )
249+ self . notes . as_deref ( )
211250 }
212251}
213252
@@ -222,8 +261,10 @@ impl VulnerabilityIdTrait for Id {
222261}
223262
224263impl WithGroupIds for Flag {
225- fn get_group_ids ( & self ) -> Option < impl Iterator < Item =& String > + ' _ > {
226- self . group_ids . as_ref ( ) . map ( |g| ( * g) . iter ( ) . map ( |x| x. deref ( ) ) )
264+ fn get_group_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
265+ self . group_ids
266+ . as_ref ( )
267+ . map ( |g| ( * g) . iter ( ) . map ( |x| x. deref ( ) ) )
227268 }
228269}
229270
@@ -275,15 +316,16 @@ impl DocumentTrait for DocumentLevelMetaData {
275316 fn get_distribution_21 ( & self ) -> Result < & Self :: DistributionType , ValidationError > {
276317 match self . distribution . as_ref ( ) {
277318 None => Err ( ValidationError {
278- message : "CSAF 2.1 requires the distribution property, but it is not set." . to_string ( ) ,
279- instance_path : "/document/distribution" . to_string ( )
319+ message : "CSAF 2.1 requires the distribution property, but it is not set."
320+ . to_string ( ) ,
321+ instance_path : "/document/distribution" . to_string ( ) ,
280322 } ) ,
281- Some ( distribution) => Ok ( distribution)
323+ Some ( distribution) => Ok ( distribution) ,
282324 }
283325 }
284326
285327 fn get_notes ( & self ) -> Option < & Vec < Self :: NoteType > > {
286- self . notes . as_ref ( ) . map ( |x| x . deref ( ) )
328+ self . notes . as_deref ( )
287329 }
288330}
289331
@@ -305,15 +347,15 @@ impl DistributionTrait for RulesForSharingDocument {
305347 match self . tlp . as_ref ( ) {
306348 None => Err ( ValidationError {
307349 message : "CSAF 2.1 requires the TLP property, but it is not set." . to_string ( ) ,
308- instance_path : "/document/distribution/sharing_group/tlp" . to_string ( )
350+ instance_path : "/document/distribution/sharing_group/tlp" . to_string ( ) ,
309351 } ) ,
310- Some ( tlp) => Ok ( tlp)
352+ Some ( tlp) => Ok ( tlp) ,
311353 }
312354 }
313355}
314356
315357impl WithGroupIds for Note {
316- fn get_group_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
358+ fn get_group_ids ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
317359 None :: < std:: iter:: Empty < & String > >
318360 }
319361}
@@ -408,7 +450,7 @@ impl ProductTreeTrait for ProductTree {
408450 type FullProductNameType = FullProductNameT ;
409451
410452 fn get_branches ( & self ) -> Option < & Vec < Self :: BranchType > > {
411- self . branches . as_ref ( ) . map ( |branches| branches . deref ( ) )
453+ self . branches . as_deref ( )
412454 }
413455
414456 fn get_product_groups ( & self ) -> & Vec < Self :: ProductGroupType > {
@@ -423,14 +465,17 @@ impl ProductTreeTrait for ProductTree {
423465 & self . full_product_names
424466 }
425467
426- fn visit_all_products ( & self , callback : & mut impl FnMut ( & Self :: FullProductNameType , & str ) -> Result < ( ) , ValidationError > ) -> Result < ( ) , ValidationError > {
468+ fn visit_all_products (
469+ & self ,
470+ callback : & mut impl FnMut ( & Self :: FullProductNameType , & str ) -> Result < ( ) , ValidationError > ,
471+ ) -> Result < ( ) , ValidationError > {
427472 self . visit_all_products_generic ( callback)
428473 }
429474}
430475
431476impl BranchTrait < FullProductNameT > for Branch {
432477 fn get_branches ( & self ) -> Option < & Vec < Self > > {
433- self . branches . as_ref ( ) . map ( |branches| branches . deref ( ) )
478+ self . branches . as_deref ( )
434479 }
435480
436481 fn get_product ( & self ) -> & Option < FullProductNameT > {
@@ -476,14 +521,18 @@ impl ProductTrait for FullProductNameT {
476521
477522impl ProductIdentificationHelperTrait for HelperToIdentifyTheProduct {
478523 fn get_purls ( & self ) -> Option < & [ String ] > {
479- self . purl . as_ref ( ) . map ( |purl| std:: slice:: from_ref ( purl ) )
524+ self . purl . as_ref ( ) . map ( std:: slice:: from_ref)
480525 }
481526
482527 fn get_model_numbers ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
483- self . model_numbers . as_ref ( ) . map ( |v| v. iter ( ) . map ( |x| x. deref ( ) ) )
528+ self . model_numbers
529+ . as_ref ( )
530+ . map ( |v| v. iter ( ) . map ( |x| x. deref ( ) ) )
484531 }
485532
486533 fn get_serial_numbers ( & self ) -> Option < impl Iterator < Item = & String > + ' _ > {
487- self . serial_numbers . as_ref ( ) . map ( |v| v. iter ( ) . map ( |x| x. deref ( ) ) )
534+ self . serial_numbers
535+ . as_ref ( )
536+ . map ( |v| v. iter ( ) . map ( |x| x. deref ( ) ) )
488537 }
489- }
538+ }
0 commit comments