-
Notifications
You must be signed in to change notification settings - Fork 2
Test 6.1.35: Add validation for contradicting remediations in CSAF documents #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7735f81
Add validation for contradicting remediations in CSAF documents
milux 0019112
Update dependencies and CSAF 2.1 schema, extend 6.1.35 test
milux 4fa1774
Refactor remediations validation to handle product groups.
milux 65ce4a4
Switch from HashSet to BTreeSet for consistent ordering
milux 5a7f9c7
Reverted deps update
milux cd62f28
Refactor remediation trait to streamline product ID handling.
milux 57107ae
Add detailed documentation for CSAF-related traits and methods
milux 767a3de
Refactor remediation category mapping for CSAF 2.0 to 2.1.
milux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule csaf
updated
8 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| use crate::csaf::csaf2_0::schema::{CategoryOfTheRemediation, CommonSecurityAdvisoryFramework, ProductGroup, ProductTree, Remediation, Vulnerability}; | ||
| use crate::csaf::csaf2_1::schema::CategoryOfTheRemediation as Remediation21; | ||
| use crate::csaf::getter_traits::{CsafTrait, ProductGroupTrait, ProductTreeTrait, RemediationTrait, VulnerabilityTrait}; | ||
| use std::ops::Deref; | ||
|
|
||
| impl RemediationTrait for Remediation { | ||
|
|
||
| /// Normalizes the remediation categories from CSAF 2.0 to those of CSAF 2.1. | ||
| /// | ||
| /// # Explanation | ||
| /// In CSAF 2.1, the list of remediation categories was expanded, making it a superset of those | ||
| /// in CSAF 2.0. This function ensures that the remediation category from a CSAF 2.0 remediation | ||
| /// object is converted into the corresponding category defined in CSAF 2.1. | ||
| /// | ||
| /// # Returns | ||
| /// A CSAF 2.1 `CategoryOfTheRemediation` that corresponds to the remediation category of the | ||
| /// current object. | ||
| fn get_category(&self) -> Remediation21 { | ||
| match self.category { | ||
| CategoryOfTheRemediation::Workaround => Remediation21::Workaround, | ||
| CategoryOfTheRemediation::Mitigation => Remediation21::Mitigation, | ||
| CategoryOfTheRemediation::VendorFix => Remediation21::VendorFix, | ||
| CategoryOfTheRemediation::NoFixPlanned => Remediation21::NoFixPlanned, | ||
| CategoryOfTheRemediation::NoneAvailable => Remediation21::NoneAvailable, | ||
| } | ||
| } | ||
|
|
||
| fn get_product_ids(&self) -> Option<Vec<&String>> { | ||
| self.product_ids.as_ref().map(|p| (*p).iter().map(|x| x.deref()).collect()) | ||
| } | ||
|
|
||
| fn get_group_ids(&self) -> Option<Vec<&String>> { | ||
| self.group_ids.as_ref().map(|g| (*g).iter().map(|x| x.deref()).collect()) | ||
| } | ||
| } | ||
|
|
||
| impl VulnerabilityTrait for Vulnerability { | ||
milux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type RemediationType = Remediation; | ||
|
|
||
| fn get_remediations(&self) -> Vec<Self::RemediationType> { | ||
| self.remediations.clone() | ||
| } | ||
| } | ||
|
|
||
| impl CsafTrait for CommonSecurityAdvisoryFramework { | ||
| type VulnerabilityType = Vulnerability; | ||
| type ProductTreeType = ProductTree; | ||
|
|
||
| fn get_product_tree(&self) -> Option<Self::ProductTreeType> { | ||
| self.product_tree.clone() | ||
| } | ||
|
|
||
| fn get_vulnerabilities(&self) -> Vec<Self::VulnerabilityType> { | ||
| self.vulnerabilities.clone() | ||
| } | ||
| } | ||
|
|
||
| impl ProductTreeTrait for ProductTree { | ||
| type ProductGroupType = ProductGroup; | ||
|
|
||
| fn get_product_groups(&self) -> Vec<Self::ProductGroupType> { | ||
| self.product_groups.clone() | ||
| } | ||
| } | ||
|
|
||
| impl ProductGroupTrait for ProductGroup { | ||
| fn get_group_id(&self) -> &String { | ||
| self.group_id.deref() | ||
| } | ||
|
|
||
| fn get_product_ids(&self) -> Vec<&String> { | ||
| self.product_ids.iter().map(|x| x.deref()).collect() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ pub mod loader; | |
| mod product_helper; | ||
| pub mod schema; | ||
| pub mod validation; | ||
| pub mod getter_implementations; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| use crate::csaf::csaf2_1::schema::ProductTree; | ||
| use crate::csaf::csaf2_1::schema::{CategoryOfTheRemediation, CommonSecurityAdvisoryFramework, ProductGroup, Remediation, Vulnerability}; | ||
| use crate::csaf::getter_traits::{CsafTrait, ProductGroupTrait, ProductTreeTrait, RemediationTrait, VulnerabilityTrait}; | ||
| use std::ops::Deref; | ||
|
|
||
| impl RemediationTrait for Remediation { | ||
| fn get_category(&self) -> CategoryOfTheRemediation { | ||
| self.category.clone() | ||
| } | ||
|
|
||
| fn get_product_ids(&self) -> Option<Vec<&String>> { | ||
| self.product_ids.as_ref().map(|p| (*p).iter().map(|x| x.deref()).collect()) | ||
| } | ||
|
|
||
| fn get_group_ids(&self) -> Option<Vec<&String>> { | ||
| self.group_ids.as_ref().map(|g| (*g).iter().map(|x| x.deref()).collect()) | ||
| } | ||
| } | ||
|
|
||
| impl VulnerabilityTrait for Vulnerability { | ||
| type RemediationType = Remediation; | ||
|
|
||
| fn get_remediations(&self) -> Vec<Self::RemediationType> { | ||
| self.remediations.clone() | ||
| } | ||
| } | ||
|
|
||
| impl CsafTrait for CommonSecurityAdvisoryFramework { | ||
| type VulnerabilityType = Vulnerability; | ||
| type ProductTreeType = ProductTree; | ||
|
|
||
| fn get_product_tree(&self) -> Option<Self::ProductTreeType> { | ||
| self.product_tree.clone() | ||
| } | ||
|
|
||
| fn get_vulnerabilities(&self) -> Vec<Self::VulnerabilityType> { | ||
| self.vulnerabilities.clone() | ||
| } | ||
| } | ||
|
|
||
| impl ProductTreeTrait for ProductTree { | ||
| type ProductGroupType = ProductGroup; | ||
|
|
||
| fn get_product_groups(&self) -> Vec<Self::ProductGroupType> { | ||
| self.product_groups.clone() | ||
| } | ||
| } | ||
|
|
||
| impl ProductGroupTrait for ProductGroup { | ||
| fn get_group_id(&self) -> &String { | ||
| self.group_id.deref() | ||
| } | ||
|
|
||
| fn get_product_ids(&self) -> Vec<&String> { | ||
| self.product_ids.iter().map(|x| x.deref()).collect() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ pub mod loader; | |
| mod product_helper; | ||
| pub mod schema; | ||
| pub mod validation; | ||
| pub mod getter_implementations; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.