Skip to content

Commit

Permalink
feat: support author field
Browse files Browse the repository at this point in the history
  • Loading branch information
louib committed Aug 20, 2023
1 parent ef7c0e4 commit ef466a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cyclone_dx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,29 @@ pub fn dump_derivation(
component_builder
.bom_ref(derivation_path.to_string())
.name(package.name.to_string())
.cpe("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(package.get_purl())
.publisher("TODO".to_string())
.version(package.version.to_string());

if let Some(description) = &package.meta.description {
component_builder.description(description.to_string());
}

if let Some(maintainers) = &package.meta.maintainers {
let author = maintainers
.iter()
.map(|m| format!("{} ({})", m.name, m.email))
.collect::<Vec<String>>()
.join(" ");
if author.len() != 0 {
component_builder.author(author);
}
}

Some(component_builder.build().unwrap())
}
5 changes: 5 additions & 0 deletions src/nix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ pub struct PackageMeta {

pub license: Option<License>,
}
impl PackageMeta {
pub fn get_licenses(&self) -> Vec<LicenseDetails> {
vec![]
}
}

pub fn get_package_for_derivation(derivation_name: &str, packages: &Packages) -> Option<Package> {
if let Some(package) = packages.get(derivation_name) {
Expand Down

0 comments on commit ef466a4

Please sign in to comment.