Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/target
.idea
.zed
*.iml
**/node_modules
go/csaf_ffi/lib/
Expand Down
4 changes: 4 additions & 0 deletions csaf-converter/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub struct ConverterArgs {
#[command(flatten, next_help_heading = "Publisher category options")]
pub(super) publisher_category_other: PublisherCategoryOtherArgs,

// Allow resolving the TLP label from the distribution text
#[arg(long)]
pub(super) allow_tlp_from_distribution_text: bool,

#[command(flatten, next_help_heading = "Publisher contact options")]
pub(super) publisher_contact: PublisherContactArgs,
}
Expand Down
1 change: 1 addition & 0 deletions csaf-converter/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn run_converter(args: ConverterArgs) -> Result<(), anyhow::Error> {
suppress_warning: args.publisher_category_other.suppress_warning,
convert_to_multiplier: args.publisher_category_other.convert_to_multiplier,
},
allow_tlp_from_distribution_text: args.allow_tlp_from_distribution_text,
publisher_contact: csaf_rs::converter::PublisherContactSettings {
details: args.publisher_contact.details,
email: args.publisher_contact.email,
Expand Down
21 changes: 16 additions & 5 deletions csaf-rs/src/converter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ pub enum Warning {
ValidationWarning(String),
CsafVersionIsMissing,
InvalidCsafVersion,
InvalidTlpLabel,
TlpIsMissingLabel,
PublisherCategoryOther,
InconsistentInitialReleaseDate { old: String, new: String },
DefaultTlpLabelSet,
TlpLabelFromDistributionText { converted: String, from_text: String },
PublisherContactOpenPgpKeyUrlRequiresEmail { url: String },
PublisherContactInvalidFormat { property: &'static str, value: String },
}
Expand All @@ -82,8 +82,14 @@ impl fmt::Display for Warning {
),
Warning::CsafVersionIsMissing => f.write_str("CSAF version node is missing"),
Warning::InvalidCsafVersion => f.write_str("CSAF version node contained an invalid value"),
Warning::InvalidTlpLabel => f.write_str("TLP label contained an invalid value"),
Warning::TlpIsMissingLabel => f.write_str("TLP node was present but did not contain the `label` property"),
Warning::DefaultTlpLabelSet => f.write_str("default TLP has been set to CLEAR"),
Warning::TlpLabelFromDistributionText { converted, from_text } => {
write!(
f,
"TLP label was taken from distribution text \
(converted value: {converted}, text value: {from_text})"
)
},
Warning::PublisherCategoryOther => f.write_str(
"Some publishers previously categorized as 'other' \
have been regrouped into the new 'multiplier' category in CSAF 2.1. \
Expand Down Expand Up @@ -176,7 +182,12 @@ mod tests {
fn end_to_end() {
let input = json!({
"document": {
"csaf_version": "2.0"
"csaf_version": "2.0",
"distribution": {
"tlp": {
"label": "WHITE"
}
}
},
"product_tree": {
"full_product_names": [
Expand Down
5 changes: 5 additions & 0 deletions csaf-rs/src/converter/set_initial_release_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@ mod tests {
"name": "Example Publisher",
"namespace": "https://example.com"
},
"distribution": {
"tlp": {
"label": "WHITE"
},
},
"title": "Example Advisory",
"tracking": {
"current_release_date": "2024-02-01T10:00:00.000Z",
Expand Down
3 changes: 3 additions & 0 deletions csaf-rs/src/converter/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use crate::schema::csaf2_1;
#[derive(Default)]
pub struct Settings {
pub publisher_category_other: PublisherCategoryOtherSettings,
/// Prefer the first valid TLP v2.0 label found in
/// document.distribution.text over the standard conversion.
pub allow_tlp_from_distribution_text: bool,
pub publisher_contact: PublisherContactSettings,
}

Expand Down
Loading
Loading