Skip to content

Commit

Permalink
Merge pull request #709 from justahero/add-external-references-tool-type
Browse files Browse the repository at this point in the history
Add 'external_references' to Tool
  • Loading branch information
Shnatsel committed May 16, 2024
2 parents 7487eb7 + acb5dc2 commit 3d50ddd
Show file tree
Hide file tree
Showing 16 changed files with 315 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cyclonedx-bom/src/models/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ mod test {
name: None,
version: None,
hashes: None,
external_references: None,
}])),
authors: Some(vec![OrganizationalContact {
bom_ref: None,
Expand Down Expand Up @@ -195,6 +196,7 @@ mod test {
name: None,
version: None,
hashes: None,
external_references: None,
}])),
authors: Some(vec![OrganizationalContact {
bom_ref: None,
Expand Down
14 changes: 14 additions & 0 deletions cyclonedx-bom/src/models/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::validation::{Validate, ValidationContext, ValidationResult};

use super::bom::SpecVersion;
use super::component::Components;
use super::external_reference::ExternalReferences;
use super::service::Services;

/// Defines the creation tool(s)
Expand Down Expand Up @@ -80,6 +81,8 @@ pub struct Tool {
pub name: Option<NormalizedString>,
pub version: Option<NormalizedString>,
pub hashes: Option<Hashes>,
/// Added in spec version 1.4
pub external_references: Option<ExternalReferences>,
}

impl Tool {
Expand All @@ -95,6 +98,7 @@ impl Tool {
name: Some(NormalizedString::new(name)),
version: Some(NormalizedString::new(version)),
hashes: None,
external_references: None,
}
}
}
Expand All @@ -108,6 +112,11 @@ impl Validate for Tool {
.add_list("hashes", &self.hashes, |hashes| {
hashes.validate_version(version)
})
.add_struct_option(
"external_references",
self.external_references.as_ref(),
version,
)
.into()
}
}
Expand All @@ -134,6 +143,7 @@ mod test {
name: None,
version: None,
hashes: None,
external_references: None,
}])
.validate();

Expand All @@ -147,6 +157,7 @@ mod test {
name: None,
version: None,
hashes: None,
external_references: None,
}])
.validate();

Expand All @@ -173,18 +184,21 @@ mod test {
name: None,
version: None,
hashes: None,
external_references: None,
},
Tool {
vendor: Some(NormalizedString("spaces and\ttabs".to_string())),
name: None,
version: None,
hashes: None,
external_references: None,
},
Tool {
vendor: None,
name: Some(NormalizedString("spaces and\ttabs".to_string())),
version: None,
hashes: None,
external_references: None,
},
])
.validate();
Expand Down
36 changes: 36 additions & 0 deletions cyclonedx-bom/src/specs/common/bom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,15 @@ pub(crate) mod base {
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down Expand Up @@ -1414,6 +1423,15 @@ pub(crate) mod base {
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<analysis>
Expand Down Expand Up @@ -1467,6 +1485,15 @@ pub(crate) mod base {
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down Expand Up @@ -2091,6 +2118,15 @@ pub(crate) mod base {
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<analysis>
Expand Down
18 changes: 18 additions & 0 deletions cyclonedx-bom/src/specs/common/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,15 @@ pub(crate) mod base {
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down Expand Up @@ -695,6 +704,15 @@ pub(crate) mod base {
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: cyclonedx-bom/src/specs/common/bom.rs
assertion_line: 606
assertion_line: 654
expression: actual
---
{
Expand All @@ -20,6 +20,19 @@ expression: actual
"alg": "algorithm",
"content": "hash value"
}
],
"externalReferences": [
{
"type": "external reference type",
"url": "url",
"comment": "comment",
"hashes": [
{
"alg": "algorithm",
"content": "hash value"
}
]
}
]
}
],
Expand Down Expand Up @@ -529,6 +542,19 @@ expression: actual
"alg": "algorithm",
"content": "hash value"
}
],
"externalReferences": [
{
"type": "external reference type",
"url": "url",
"comment": "comment",
"hashes": [
{
"alg": "algorithm",
"content": "hash value"
}
]
}
]
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: cyclonedx-bom/src/specs/common/bom.rs
assertion_line: 598
assertion_line: 660
expression: xml_output
---
<?xml version="1.0" encoding="utf-8"?>
Expand All @@ -15,6 +15,15 @@ expression: xml_output
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down Expand Up @@ -403,6 +412,15 @@ expression: xml_output
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<analysis>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: cyclonedx-bom/src/specs/common/bom.rs
assertion_line: 654
expression: actual
---
{
Expand All @@ -19,6 +20,19 @@ expression: actual
"alg": "algorithm",
"content": "hash value"
}
],
"externalReferences": [
{
"type": "external reference type",
"url": "url",
"comment": "comment",
"hashes": [
{
"alg": "algorithm",
"content": "hash value"
}
]
}
]
}
],
Expand Down Expand Up @@ -782,6 +796,19 @@ expression: actual
"alg": "algorithm",
"content": "hash value"
}
],
"externalReferences": [
{
"type": "external reference type",
"url": "url",
"comment": "comment",
"hashes": [
{
"alg": "algorithm",
"content": "hash value"
}
]
}
]
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: cyclonedx-bom/src/specs/common/bom.rs
assertion_line: 660
expression: xml_output
---
<?xml version="1.0" encoding="utf-8"?>
Expand All @@ -14,6 +15,15 @@ expression: xml_output
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down Expand Up @@ -568,6 +578,15 @@ expression: xml_output
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<analysis>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: cyclonedx-bom/src/specs/common/metadata.rs
assertion_line: 387
expression: xml_output
---
<?xml version="1.0" encoding="utf-8"?>
Expand All @@ -13,6 +14,15 @@ expression: xml_output
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
<externalReferences>
<reference type="external reference type">
<url>url</url>
<comment>comment</comment>
<hashes>
<hash alg="algorithm">hash value</hash>
</hashes>
</reference>
</externalReferences>
</tool>
</tools>
<authors>
Expand Down
Loading

0 comments on commit 3d50ddd

Please sign in to comment.