Skip to content

Commit

Permalink
Record the target platform into the SBOM, in a way that compliant wit…
Browse files Browse the repository at this point in the history
…h officially documented schema

Signed-off-by: Sergey "Shnatsel" Davidoff <shnatsel@gmail.com>
  • Loading branch information
Shnatsel committed Aug 20, 2024
1 parent 7596551 commit 84a2461
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cargo-cyclonedx/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use cyclonedx_bom::models::license::{License, LicenseChoice, Licenses};
use cyclonedx_bom::models::metadata::Metadata;
use cyclonedx_bom::models::metadata::MetadataError;
use cyclonedx_bom::models::organization::OrganizationalContact;
use cyclonedx_bom::models::property::{Properties, Property};
use cyclonedx_bom::models::tool::{Tool, Tools};
use cyclonedx_bom::validation::Validate;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -516,6 +517,13 @@ impl SbomGenerator {

metadata.tools = Some(Tools::List(vec![tool]));

use crate::config::Target::*;
let properties = match self.config.target.as_ref().unwrap() {
SingleTarget(target) => vec![Property::new("cdx:rustc:sbom:target:triple", target)],
AllTargets => vec![Property::new("cdx:rustc:sbom:target:all_targets", "true")],
};
metadata.properties = Some(Properties(properties));

Ok((metadata, target_kinds))
}

Expand Down

0 comments on commit 84a2461

Please sign in to comment.