diff options
Diffstat (limited to 'vendor/spdx-rs/src/models')
-rw-r--r-- | vendor/spdx-rs/src/models/checksum.rs | 14 | ||||
-rw-r--r-- | vendor/spdx-rs/src/models/file_information.rs | 35 | ||||
-rw-r--r-- | vendor/spdx-rs/src/models/package_information.rs | 94 | ||||
-rw-r--r-- | vendor/spdx-rs/src/models/relationship.rs | 2 | ||||
-rw-r--r-- | vendor/spdx-rs/src/models/snippet.rs | 28 | ||||
-rw-r--r-- | vendor/spdx-rs/src/models/spdx_document.rs | 10 |
6 files changed, 152 insertions, 31 deletions
diff --git a/vendor/spdx-rs/src/models/checksum.rs b/vendor/spdx-rs/src/models/checksum.rs index f8e2bc258..d66bd3612 100644 --- a/vendor/spdx-rs/src/models/checksum.rs +++ b/vendor/spdx-rs/src/models/checksum.rs @@ -43,4 +43,18 @@ pub enum Algorithm { MD4, MD5, MD6, + #[serde(rename = "SHA3-256")] + SHA3256, + #[serde(rename = "SHA3-384")] + SHA3384, + #[serde(rename = "SHA3-512")] + SHA3512, + #[serde(rename = "BLAKE2b-256")] + BLAKE2B256, + #[serde(rename = "BLAKE2b-384")] + BLAKE2B384, + #[serde(rename = "BLAKE2b-512")] + BLAKE2B512, + BLAKE3, + ADLER32, } diff --git a/vendor/spdx-rs/src/models/file_information.rs b/vendor/spdx-rs/src/models/file_information.rs index aba2defe7..a6d03bef4 100644 --- a/vendor/spdx-rs/src/models/file_information.rs +++ b/vendor/spdx-rs/src/models/file_information.rs @@ -29,11 +29,19 @@ pub struct FileInformation { pub file_checksum: Vec<Checksum>, /// <https://spdx.github.io/spdx-spec/4-file-information/#45-concluded-license> - #[serde(rename = "licenseConcluded")] - pub concluded_license: SpdxExpression, + #[serde( + rename = "licenseConcluded", + skip_serializing_if = "Option::is_none", + default + )] + pub concluded_license: Option<SpdxExpression>, /// <https://spdx.github.io/spdx-spec/4-file-information/#46-license-information-in-file> - #[serde(rename = "licenseInfoInFiles")] + #[serde( + rename = "licenseInfoInFiles", + skip_serializing_if = "Vec::is_empty", + default + )] pub license_information_in_file: Vec<SimpleExpression>, /// <https://spdx.github.io/spdx-spec/4-file-information/#47-comments-on-license> @@ -45,7 +53,12 @@ pub struct FileInformation { pub comments_on_license: Option<String>, /// <https://spdx.github.io/spdx-spec/4-file-information/#48-copyright-text> - pub copyright_text: String, + #[serde( + rename = "copyrightText", + skip_serializing_if = "Option::is_none", + default + )] + pub copyright_text: Option<String>, /// <https://spdx.github.io/spdx-spec/4-file-information/#412-file-comment> #[serde(rename = "comment", skip_serializing_if = "Option::is_none", default)] @@ -80,10 +93,10 @@ impl Default for FileInformation { file_spdx_identifier: "NOASSERTION".to_string(), file_type: Vec::new(), file_checksum: Vec::new(), - concluded_license: SpdxExpression::parse("NOASSERTION").expect("will always succeed"), + concluded_license: None, license_information_in_file: Vec::new(), comments_on_license: None, - copyright_text: "NOASSERTION".to_string(), + copyright_text: None, file_comment: None, file_notice: None, file_contributor: Vec::new(), @@ -98,7 +111,7 @@ impl FileInformation { *id += 1; Self { file_name: name.to_string(), - file_spdx_identifier: format!("SPDXRef-{}", id), + file_spdx_identifier: format!("SPDXRef-{id}"), ..Self::default() } } @@ -241,7 +254,7 @@ mod test { .unwrap(); assert_eq!( spdx.file_information[0].concluded_license, - SpdxExpression::parse("Apache-2.0").unwrap() + Some(SpdxExpression::parse("Apache-2.0").unwrap()) ); } #[test] @@ -273,7 +286,11 @@ mod test { ) .unwrap(); assert_eq!( - spdx.file_information[0].copyright_text, + spdx.file_information[0] + .copyright_text + .as_ref() + .unwrap() + .clone(), "Copyright 2010, 2011 Source Auditor Inc.".to_string() ); } diff --git a/vendor/spdx-rs/src/models/package_information.rs b/vendor/spdx-rs/src/models/package_information.rs index c5d73fb3f..dde62f1de 100644 --- a/vendor/spdx-rs/src/models/package_information.rs +++ b/vendor/spdx-rs/src/models/package_information.rs @@ -76,8 +76,12 @@ pub struct PackageInformation { pub source_information: Option<String>, /// <https://spdx.github.io/spdx-spec/3-package-information/#313-concluded-license> - #[serde(rename = "licenseConcluded")] - pub concluded_license: SpdxExpression, + #[serde( + rename = "licenseConcluded", + skip_serializing_if = "Option::is_none", + default + )] + pub concluded_license: Option<SpdxExpression>, /// <https://spdx.github.io/spdx-spec/3-package-information/#314-all-licenses-information-from-files> #[serde( @@ -88,8 +92,12 @@ pub struct PackageInformation { pub all_licenses_information_from_files: Vec<String>, /// <https://spdx.github.io/spdx-spec/3-package-information/#315-declared-license> - #[serde(rename = "licenseDeclared")] - pub declared_license: SpdxExpression, + #[serde( + rename = "licenseDeclared", + skip_serializing_if = "Option::is_none", + default + )] + pub declared_license: Option<SpdxExpression>, /// <https://spdx.github.io/spdx-spec/3-package-information/#316-comments-on-license> #[serde( @@ -100,7 +108,12 @@ pub struct PackageInformation { pub comments_on_license: Option<String>, /// <https://spdx.github.io/spdx-spec/3-package-information/#317-copyright-text> - pub copyright_text: String, + #[serde( + rename = "copyrightText", + skip_serializing_if = "Option::is_none", + default + )] + pub copyright_text: Option<String>, /// <https://spdx.github.io/spdx-spec/3-package-information/#318-package-summary-description> #[serde(rename = "summary", skip_serializing_if = "Option::is_none", default)] @@ -142,6 +155,30 @@ pub struct PackageInformation { #[serde(skip_serializing_if = "Vec::is_empty", default)] pub annotations: Vec<Annotation>, + + #[serde(rename = "builtDate", skip_serializing_if = "Option::is_none", default)] + pub built_date: Option<String>, + + #[serde( + rename = "releaseDate", + skip_serializing_if = "Option::is_none", + default + )] + pub release_date: Option<String>, + + #[serde( + rename = "validUntilDate", + skip_serializing_if = "Option::is_none", + default + )] + pub valid_until_date: Option<String>, + + #[serde( + rename = "primaryPackagePurpose", + skip_serializing_if = "Option::is_none", + default + )] + pub primary_package_purpose: Option<PrimaryPackagePurpose>, } impl Default for PackageInformation { @@ -159,11 +196,11 @@ impl Default for PackageInformation { package_checksum: Vec::new(), package_home_page: None, source_information: None, - concluded_license: SpdxExpression::parse("NONE").expect("will always succeed"), + concluded_license: None, all_licenses_information_from_files: Vec::new(), - declared_license: SpdxExpression::parse("NONE").expect("will always succeed"), + declared_license: None, comments_on_license: None, - copyright_text: "NOASSERTION".to_string(), + copyright_text: None, package_summary_description: None, package_detailed_description: None, package_comment: None, @@ -171,6 +208,10 @@ impl Default for PackageInformation { package_attribution_text: Vec::new(), files: Vec::new(), annotations: Vec::new(), + built_date: None, + release_date: None, + valid_until_date: None, + primary_package_purpose: None, } } } @@ -181,7 +222,7 @@ impl PackageInformation { *id += 1; Self { package_name: name.to_string(), - package_spdx_identifier: format!("SPDXRef-{}", id), + package_spdx_identifier: format!("SPDXRef-{id}"), ..Self::default() } } @@ -263,6 +304,23 @@ pub enum ExternalPackageReferenceCategory { Other, } +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Copy)] +#[serde(rename_all = "SCREAMING-KEBAB-CASE")] +pub enum PrimaryPackagePurpose { + Application, + Framework, + Library, + Container, + OperatingSystem, + Device, + Firmware, + Source, + Archive, + File, + Install, + Other, +} + #[cfg(test)] mod test { use std::fs::read_to_string; @@ -432,7 +490,11 @@ mod test { ) .unwrap(); assert_eq!( - spdx.package_information[0].concluded_license, + spdx.package_information[0] + .concluded_license + .as_ref() + .unwrap() + .clone(), SpdxExpression::parse("(LGPL-2.0-only OR LicenseRef-3)").unwrap() ); } @@ -459,7 +521,11 @@ mod test { ) .unwrap(); assert_eq!( - spdx.package_information[0].declared_license, + spdx.package_information[0] + .declared_license + .as_ref() + .unwrap() + .clone(), SpdxExpression::parse("(LGPL-2.0-only AND LicenseRef-3)").unwrap() ); } @@ -481,7 +547,11 @@ mod test { ) .unwrap(); assert_eq!( - spdx.package_information[0].copyright_text, + spdx.package_information[0] + .copyright_text + .as_ref() + .unwrap() + .clone(), "Copyright 2008-2010 John Smith".to_string() ); } diff --git a/vendor/spdx-rs/src/models/relationship.rs b/vendor/spdx-rs/src/models/relationship.rs index 6430a796f..7d074eaab 100644 --- a/vendor/spdx-rs/src/models/relationship.rs +++ b/vendor/spdx-rs/src/models/relationship.rs @@ -87,6 +87,8 @@ pub enum RelationshipType { Amends, PrerequisiteFor, HasPrerequisite, + RequirementDescriptionFor, + SpecificationFor, Other, } diff --git a/vendor/spdx-rs/src/models/snippet.rs b/vendor/spdx-rs/src/models/snippet.rs index 7585a0087..1de31f94b 100644 --- a/vendor/spdx-rs/src/models/snippet.rs +++ b/vendor/spdx-rs/src/models/snippet.rs @@ -20,8 +20,12 @@ pub struct Snippet { pub ranges: Vec<Range>, /// <https://spdx.github.io/spdx-spec/5-snippet-information/#55-snippet-concluded-license> - #[serde(rename = "licenseConcluded")] - pub snippet_concluded_license: SpdxExpression, + #[serde( + rename = "licenseConcluded", + skip_serializing_if = "Option::is_none", + default + )] + pub snippet_concluded_license: Option<SpdxExpression>, /// <https://spdx.github.io/spdx-spec/5-snippet-information/#56-license-information-in-snippet> #[serde( @@ -40,8 +44,12 @@ pub struct Snippet { pub snippet_comments_on_license: Option<String>, /// <https://spdx.github.io/spdx-spec/5-snippet-information/#58-snippet-copyright-text> - #[serde(rename = "copyrightText")] - pub snippet_copyright_text: String, + #[serde( + rename = "copyrightText", + skip_serializing_if = "Option::is_none", + default + )] + pub snippet_copyright_text: Option<String>, /// <https://spdx.github.io/spdx-spec/5-snippet-information/#59-snippet-comment> #[serde(rename = "comment", skip_serializing_if = "Option::is_none", default)] @@ -175,7 +183,11 @@ mod test { ) .unwrap(); assert_eq!( - spdx.snippet_information[0].snippet_concluded_license, + spdx.snippet_information[0] + .snippet_concluded_license + .as_ref() + .unwrap() + .clone(), SpdxExpression::parse("GPL-2.0-only").unwrap() ); } @@ -208,7 +220,11 @@ mod test { ) .unwrap(); assert_eq!( - spdx.snippet_information[0].snippet_copyright_text, + spdx.snippet_information[0] + .snippet_copyright_text + .as_ref() + .unwrap() + .clone(), "Copyright 2008-2010 John Smith".to_string() ); } diff --git a/vendor/spdx-rs/src/models/spdx_document.rs b/vendor/spdx-rs/src/models/spdx_document.rs index df619e5dc..385685086 100644 --- a/vendor/spdx-rs/src/models/spdx_document.rs +++ b/vendor/spdx-rs/src/models/spdx_document.rs @@ -155,9 +155,11 @@ impl SPDX { let mut license_ids = HashSet::new(); for file in &self.file_information { - for license in &file.concluded_license.identifiers() { - if license != "NOASSERTION" && license != "NONE" { - license_ids.insert(license.clone()); + if let Some(concluded_license) = &file.concluded_license { + for license in concluded_license.identifiers() { + if license != "NOASSERTION" && license != "NONE" { + license_ids.insert(license.clone()); + } } } } @@ -228,7 +230,7 @@ mod test { assert_eq!( file.0.concluded_license, - SpdxExpression::parse("LicenseRef-1").unwrap() + Some(SpdxExpression::parse("LicenseRef-1").unwrap()) ); } |