Skip to content

fix: store headers of SPDX YAML SBOMs in sboms_headers #2362 - #2364

Open
Jean-Regis-M wants to merge 1 commit into
aboutcode-org:mainfrom
Jean-Regis-M:fix-spdx-yaml-sbom-headers
Open

Jean-Regis-M wants to merge 1 commit into
aboutcode-org:mainfrom
Jean-Regis-M:fix-spdx-yaml-sbom-headers

Conversation

@Jean-Regis-M

Copy link
Copy Markdown

Issues

Changes

load_sbom has accepted SPDX documents in YAML since #1865, but extract_headers() in scanpipe/pipes/resolve.py only parsed .json files. For a .spdx.yml / .yaml SBOM, get_manifest_headers() therefore returned {}, and get_data_from_manifests() never wrote that SBOM's entry to project.extra_data["sboms_headers"]. The packages loaded fine, so nothing pointed to the missing headers.

  • Parse .yml / .yaml with saneyaml, the same loader get_spdx_document_from_file() uses for these files.
  • Return {} when the document isn't a mapping, so a top-level list doesn't raise AttributeError here.
  • Rename the local cyclonedx_document variable to document, since the function serves both SPDX and CycloneDX.
  • Add test_scanpipe_resolve_get_manifest_headers_spdx_yaml using the existing curl-7.70.0-v2.2.spdx.yml fixture.

CycloneDX XML is still not handled by extract_headers(). Its header fields aren't top-level keys, so I've left that out of this PR.

Checklist

  • I have read the contributing guidelines
  • I have linked an existing issue above
  • I have added unit tests covering the new code
  • I have reviewed and understood every line of this PR

…2362

extract_headers() only parsed .json files, so SPDX documents loaded
from .yml/.yaml (supported by load_sbom since aboutcode-org#1865) never had their
headers saved to project.extra_data["sboms_headers"].

Parse YAML with saneyaml, as get_spdx_document_from_file() already
does, and ignore documents that are not a mapping.

Signed-off-by: JEAN REGIS <190766850+Jean-Regis-M@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPDX YAML SBOMs: document headers are not stored in sboms_headers

1 participant