Skip to content

Commit

Permalink
refactor: start population the component fields
Browse files Browse the repository at this point in the history
  • Loading branch information
louib committed Aug 19, 2023
1 parent 4d7fe88 commit 6eca48c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/cyclone_dx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub fn dump(derivations: &crate::nix::Derivations) -> String {
.unwrap()]);

let mut components: Vec<Component> = vec![];
for derivation in derivations.values() {
components.push(dump_derivation(derivation));
for (derivation_path, derivation) in derivations.iter() {
components.push(dump_derivation(derivation_path, derivation));
}

let cyclonedx = CycloneDxBuilder::default()
Expand All @@ -37,11 +37,19 @@ pub fn dump(derivations: &crate::nix::Derivations) -> String {
"".to_string()
}

pub fn dump_derivation(derivation: &crate::nix::Derivation) -> Component {
pub fn dump_derivation(derivation_path: &str, derivation: &crate::nix::Derivation) -> Component {
ComponentBuilder::default()
.bom_ref(derivation_path.to_string())
.name("TODO".to_string())
.description("TODO".to_string())
.cpe("TODO".to_string())
// TODO application is the generic type, but we should also use file and library
// also, populate the mime_type in case of a file type.
.type_("application".to_string())
// I'm assuming here that if a package has been installed by Nix, it was required.
.scope("required".to_string())
.purl("TODO".to_string())
.publisher("TODO".to_string())
.version("TODO".to_string())
.build()
.unwrap()
Expand Down

0 comments on commit 6eca48c

Please sign in to comment.