fix(gitlab-cyclonedx): emit minimal empty SBOM when no components found#343
Merged
Conversation
When ASH is run against a repository with no recognizable packages (e.g., infrastructure-only repos), Syft produces no components. The GitLab CycloneDX reporter previously returned None and wrote no file, which broke GitLab pipelines that require gl-dependency-scanning-report.cdx.json to exist for policy validation. The reporter now emits a minimal but valid CycloneDX document containing the bomFormat/specVersion/version envelope and the gitlab:meta:schema_version metadata property when no components are present, matching the behavior of the generic CycloneDX reporter. Fixes #342
Contributor
ASH Security Scan Report
Scan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies:
Report generated by Automated Security Helper (ASH) at 2026-05-13T12:29:31+00:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #342
When ASH is run against a repository with no recognizable packages (e.g., infrastructure-only repos), Syft produces no components. The GitLab CycloneDX reporter previously returned
Noneand wrote no file, which broke GitLab pipelines that requiregl-dependency-scanning-report.cdx.jsonto exist for policy validation.Changes
gitlab_cyclonedx_reporter.py: Added_build_minimal_empty_sbom()helper that returns a minimal valid CycloneDX document containing the envelope (bomFormat,specVersion,version), an emptycomponentslist, and the requiredgitlab:meta:schema_versionmetadata property. Both early-return paths (nomodel.cyclonedxand emptycomponents) now emit this document instead of returningNone. This matches the behavior of the generic CycloneDX reporter, which already emits a minimal valid document in this case.test_gitlab_cyclonedx_reporter.py: Replacedtest_returns_none_when_no_componentswith two new tests covering both empty paths (no CycloneDX model and empty components list), asserting the minimal SBOM structure and required schema version property.Testing
Impact
GitLab pipelines that require the
gl-dependency-scanning-report.cdx.jsonartifact for policy validation will no longer fail on repos with no software dependencies (e.g., infrastructure-only repos).