Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions csaf-rs/src/csaf2_0/csaf_implementations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ use crate::csaf_traits::{
};
use crate::csaf2_1::ssvc_dp_selection_list::SelectionList;
use crate::schema::csaf2_0::schema::{
Branch, CategoryOfPublisher, CategoryOfReference, CategoryOfTheRemediation, CategoryOfTheThreat,
CommonSecurityAdvisoryFramework, CryptographicHashes, CsafVersion as CsafVersion20, DocumentGenerator,
DocumentLevelMetaData, DocumentStatus, FileHash, Flag, FullProductNameT, HelperToIdentifyTheProduct, Id,
Involvement, LabelOfTheFlag, LabelOfTlp, Note, NoteCategory, PartyCategory, ProductGroup, ProductStatus,
ProductTree, Publisher, Reference, Relationship, Remediation, Revision, RulesForSharingDocument, Score, Threat,
Tracking, TrafficLightProtocolTlp, Vulnerability,
Branch, CategoryOfPublisher, CategoryOfReference, CategoryOfTheBranch, CategoryOfTheRemediation,
CategoryOfTheThreat, CommonSecurityAdvisoryFramework, CryptographicHashes, CsafVersion as CsafVersion20,
DocumentGenerator, DocumentLevelMetaData, DocumentStatus, FileHash, Flag, FullProductNameT,
HelperToIdentifyTheProduct, Id, Involvement, LabelOfTheFlag, LabelOfTlp, Note, NoteCategory, PartyCategory,
ProductGroup, ProductStatus, ProductTree, Publisher, Reference, Relationship, Remediation, Revision,
RulesForSharingDocument, Score, Threat, Tracking, TrafficLightProtocolTlp, Vulnerability,
};
use crate::schema::csaf2_1::schema::{
CategoryOfPublisher as CategoryOfPublisher21, CategoryOfReference as CategoryOfReference21,
CategoryOfTheRemediation as Remediation21, CategoryOfTheThreat as CategoryOfTheThreat21,
DocumentStatus as Status21, Epss, LabelOfTheFlag as LabelOfTheFlag21, LabelOfTlp as Tlp21,
NoteCategory as NoteCategory21, PartyCategory as PartyCategory21,
CategoryOfTheBranch as CategoryOfTheBranch21, CategoryOfTheRemediation as Remediation21,
CategoryOfTheThreat as CategoryOfTheThreat21, DocumentStatus as Status21, Epss, LabelOfTheFlag as LabelOfTheFlag21,
LabelOfTlp as Tlp21, NoteCategory as NoteCategory21, PartyCategory as PartyCategory21,
};
use crate::validation::ValidationError;
use serde::de::Error;
Expand Down Expand Up @@ -592,6 +592,27 @@ impl BranchTrait<FullProductNameT> for Branch {
self.branches.as_deref()
}

fn get_category(&self) -> &CategoryOfTheBranch21 {
match self.category {
CategoryOfTheBranch::Architecture => &CategoryOfTheBranch21::Architecture,
CategoryOfTheBranch::HostName => &CategoryOfTheBranch21::HostName,
CategoryOfTheBranch::Language => &CategoryOfTheBranch21::Language,
CategoryOfTheBranch::Legacy => &CategoryOfTheBranch21::Legacy,
CategoryOfTheBranch::PatchLevel => &CategoryOfTheBranch21::PatchLevel,
CategoryOfTheBranch::ProductFamily => &CategoryOfTheBranch21::ProductFamily,
CategoryOfTheBranch::ProductName => &CategoryOfTheBranch21::ProductName,
CategoryOfTheBranch::ProductVersion => &CategoryOfTheBranch21::ProductVersion,
CategoryOfTheBranch::ProductVersionRange => &CategoryOfTheBranch21::ProductVersionRange,
CategoryOfTheBranch::ServicePack => &CategoryOfTheBranch21::ServicePack,
CategoryOfTheBranch::Specification => &CategoryOfTheBranch21::Specification,
CategoryOfTheBranch::Vendor => &CategoryOfTheBranch21::Vendor,
}
}

fn get_name(&self) -> &str {
self.name.deref()
}

fn get_product(&self) -> &Option<FullProductNameT> {
&self.product
}
Expand Down Expand Up @@ -627,6 +648,10 @@ impl ProductTrait for FullProductNameT {
self.product_id.deref()
}

fn get_name(&self) -> &str {
self.name.deref()
}

fn get_product_identification_helper(&self) -> &Option<Self::ProductIdentificationHelperType> {
&self.product_identification_helper
}
Expand Down
25 changes: 19 additions & 6 deletions csaf-rs/src/csaf2_1/csaf_implementations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use crate::csaf_traits::{
};
use crate::csaf2_1::ssvc_dp_selection_list::SelectionList;
use crate::schema::csaf2_1::schema::{
Branch, CategoryOfPublisher, CategoryOfReference, CategoryOfTheRemediation, CategoryOfTheThreat,
CommonSecurityAdvisoryFramework, Content, CryptographicHashes, CsafVersion as CsafVersion21, DocumentGenerator,
DocumentLevelMetaData, DocumentStatus, Epss, FileHash, FirstKnownExploitationDate, Flag, FullProductNameT,
HelperToIdentifyTheProduct, Id, Involvement, LabelOfTheFlag, LabelOfTlp, Metric, Note, NoteCategory, PartyCategory,
ProductGroup, ProductStatus, ProductTree, Publisher, Reference, Relationship, Remediation, Revision,
RulesForDocumentSharing, SharingGroup, Threat, Tracking, TrafficLightProtocolTlp, Vulnerability,
Branch, CategoryOfPublisher, CategoryOfReference, CategoryOfTheBranch, CategoryOfTheRemediation,
CategoryOfTheThreat, CommonSecurityAdvisoryFramework, Content, CryptographicHashes, CsafVersion as CsafVersion21,
DocumentGenerator, DocumentLevelMetaData, DocumentStatus, Epss, FileHash, FirstKnownExploitationDate, Flag,
FullProductNameT, HelperToIdentifyTheProduct, Id, Involvement, LabelOfTheFlag, LabelOfTlp, Metric, Note,
NoteCategory, PartyCategory, ProductGroup, ProductStatus, ProductTree, Publisher, Reference, Relationship,
Remediation, Revision, RulesForDocumentSharing, SharingGroup, Threat, Tracking, TrafficLightProtocolTlp,
Vulnerability,
};
use crate::validation::ValidationError;
use serde_json::{Map, Value};
Expand Down Expand Up @@ -502,6 +503,14 @@ impl BranchTrait<FullProductNameT> for Branch {
self.branches.as_deref()
}

fn get_category(&self) -> &CategoryOfTheBranch {
&self.category
}

fn get_name(&self) -> &str {
self.name.deref()
}

fn get_product(&self) -> &Option<FullProductNameT> {
&self.product
}
Expand Down Expand Up @@ -538,6 +547,10 @@ impl ProductTrait for FullProductNameT {
self.product_id.deref()
}

fn get_name(&self) -> &str {
self.name.deref()
}

fn get_product_identification_helper(&self) -> &Option<Self::ProductIdentificationHelperType> {
&self.product_identification_helper
}
Expand Down
11 changes: 9 additions & 2 deletions csaf-rs/src/csaf_traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::schema::csaf2_1::schema::{
CategoryOfPublisher, CategoryOfReference, CategoryOfTheRemediation, CategoryOfTheThreat, DocumentStatus, Epss,
LabelOfTheFlag, LabelOfTlp, NoteCategory, PartyCategory,
CategoryOfPublisher, CategoryOfReference, CategoryOfTheBranch, CategoryOfTheRemediation, CategoryOfTheThreat,
DocumentStatus, Epss, LabelOfTheFlag, LabelOfTlp, NoteCategory, PartyCategory,
};

use crate::csaf2_1::ssvc_dp_selection_list::SelectionList;
Expand Down Expand Up @@ -1062,6 +1062,10 @@ pub trait BranchTrait<FPN: ProductTrait>: Sized {
/// Returns an optional reference to the child branches of this branch.
fn get_branches(&self) -> Option<&Vec<Self>>;

fn get_category(&self) -> &CategoryOfTheBranch;

fn get_name(&self) -> &str;

/// Retrieves the full product name associated with this branch, if available.
fn get_product(&self) -> &Option<FPN>;

Expand Down Expand Up @@ -1150,6 +1154,9 @@ pub trait ProductTrait {
/// Returns the product ID from the full product name.
fn get_product_id(&self) -> &String;

/// Returns the textual description of the product
fn get_name(&self) -> &str;

/// Returns the product identification helper associated with the full product name.
fn get_product_identification_helper(&self) -> &Option<Self::ProductIdentificationHelperType>;
}
Expand Down
2 changes: 1 addition & 1 deletion csaf-rs/src/validations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub mod test_6_1_27_11;
pub mod test_6_1_28;
pub mod test_6_1_29;
pub mod test_6_1_30;
// pub mod test_6_1_31;
pub mod test_6_1_31;
pub mod test_6_1_32;
pub mod test_6_1_33;
pub mod test_6_1_34;
Expand Down
Loading