Crates.io | cyclonedx-bom |
lib.rs | cyclonedx-bom |
version | 0.8.0 |
source | src |
created_at | 2020-04-11 07:23:19.668813 |
updated_at | 2024-11-07 14:18:55.897634 |
description | CycloneDX Software Bill of Materials Library |
homepage | https://cyclonedx.org/ |
repository | https://github.com/CycloneDX/cyclonedx-rust-cargo |
max_upload_size | |
id | 228548 |
size | 1,427,193 |
cyclonedx-bom
The CycloneDX library provides JSON and XML serialization and deserialization of Software Bill-of-Materials (SBOM) files.
CycloneDX is a full-stack SBOM/xBOM standard designed for use in application security contexts and supply chain component analysis.
The library is intended to enable developers to:
This library currently supports CycloneDX 1.3, 1.4 and 1.5.
use cyclonedx_bom::prelude::*;
let bom_json = r#"{
"bomFormat": "CycloneDX",
"specVersion": "1.5",
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
"version": 1
}"#;
let bom = Bom::parse_from_json_v1_5(bom_json.as_bytes()).expect("Failed to parse BOM");
let validation_result = bom.validate();
assert!(validation_result.passed());
use cyclonedx_bom::prelude::*;
use cyclonedx_bom::models::{
tool::{Tool, Tools},
};
let bom = Bom {
serial_number: Some(
UrnUuid::new("urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79".to_string())
.expect("Failed to create UrnUuid"),
),
metadata: Some(Metadata {
tools: Some(Tools::List(vec![Tool {
name: Some(NormalizedString::new("my_tool")),
..Tool::default()
}])),
..Metadata::default()
}),
..Bom::default()
};
let mut output = Vec::<u8>::new();
bom.output_as_json_v1_5(&mut output)
.expect("Failed to write BOM");
let output = String::from_utf8(output).expect("Failed to read output as a string");
assert_eq!(
output,
r#"{
"bomFormat": "CycloneDX",
"specVersion": "1.5",
"version": 1,
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
"metadata": {
"tools": [
{
"name": "my_tool"
}
]
}
}"#
);
See README for details.
See CONTRIBUTING for details.
We are running a Bug Bounty program financed by the Bug Resilience Program of the Sovereign Tech Fund. Thank you very much!
CycloneDX Rust Cargo is Copyright (c) OWASP Foundation. All Rights Reserved.
Permission to modify and redistribute is granted under the terms of the Apache 2.0 license. See the LICENSE file for the full license.