Skip to content

Commit

Permalink
fix: add empty default for versionInfo
Browse files Browse the repository at this point in the history
We need this because running syft against a host directory with the
output format `spdx-json` adds one informational entry to the package
array, which does not contain a versionInfo field and can simply be
ignored
  • Loading branch information
CherryKitten committed Dec 11, 2023
1 parent 5618b22 commit 9517db7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub fn export_metrics(
let sbom: Sbom = serde_json::from_value(sbom)?;
for entry in sbom.packages {
let source = source.clone().into();
if entry.versionInfo.is_empty() { continue };
syft_metrics
.get_or_create(&SbomLabels {
software: entry.name,
Expand Down
1 change: 1 addition & 0 deletions src/sbom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::config::{Config, Source};
#[derive(Clone, Debug, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct SbomEntry {
pub name: String,
#[serde(default)]
pub versionInfo: String,
}

Expand Down

0 comments on commit 9517db7

Please sign in to comment.