Skip to content
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

Record the target platform into the SBOM, #762

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading