-
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 4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,78 @@ | ||
| use std::collections::BTreeSet; | ||
| use std::ops::Deref; | ||
| use std::str::FromStr; | ||
| use crate::csaf::csaf2_0::schema::{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 crate::csaf::helpers::resolve_product_groups; | ||
|
|
||
| impl RemediationTrait for Remediation { | ||
| fn get_category(&self) -> Remediation21 { | ||
| // Categories are identical, so this should never fail | ||
| Remediation21::from_str(self.category.to_string().as_str()).unwrap() | ||
| } | ||
|
|
||
| fn get_product_ids(&self) -> Option<Vec<&String>> { | ||
| self.product_ids.as_ref().map(|product_ids| product_ids.deref().iter().map(|x| x.deref()).collect()) | ||
| } | ||
|
|
||
| fn get_group_ids(&self) -> Option<Vec<&String>> { | ||
| self.group_ids.as_ref().map(|group_ids| group_ids.deref().iter().map(|x| x.deref()).collect()) | ||
| } | ||
|
|
||
| fn get_all_product_ids(&self, doc: &impl CsafTrait) -> Option<BTreeSet<String>> { | ||
| if self.get_product_ids().is_none() && self.get_group_ids().is_none() { | ||
| None | ||
| } else { | ||
| let mut product_set: BTreeSet<String> = match self.get_product_ids() { | ||
| Some(product_ids) => product_ids.iter().map(|p| p.to_string()).collect(), | ||
| None => BTreeSet::new() | ||
| }; | ||
| if let Some(product_groups) = self.get_group_ids() { | ||
| if let Some(product_ids) = resolve_product_groups(doc, product_groups) { | ||
| product_set.extend(product_ids.iter().map(|p| p.to_string())); | ||
| } | ||
| } | ||
| Some(product_set) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| 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; | ||
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.