Repository navigation
feat(scan): add --include-sbom-files to scan repo (PPSC-1711) - #370
Open
kamleshsolanki-armis wants to merge 2 commits into
Open
kamleshsolanki-armis wants to merge 2 commits into
kamleshsolanki-armis wants to merge 2 commits into
Conversation
`scan repo --include-sbom-files N` asks the backend to scan up to N CycloneDX/SPDX files kept in the repository for vulnerabilities, alongside the code. N is required and must be at least 1; the backend may apply a lower per-tenant limit. - Sent as `include_sbom_files` on POST /api/v1/ingest/scan, omitted without the flag. - When the results report `sbom_scan_status` PARTIAL or FAILED, the CLI prints a warning with the reasons and up to five skipped paths. The exit code is unchanged.
Test Coverage Reporttotal: (statements) 75.4% Coverage by function |
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.
Related Issue
Type of Change
Problem
Repositories sometimes keep SBOM documents, such as one per product release. A
scan repohad no way to ask Armis to scan those files for vulnerabilities, and nothing told the user when only some of them were scanned.Solution
Flag on
scan repo:--include-sbom-files Nasks the backend to scan up toNCycloneDX/SPDX files kept in the repository, alongside the code.Nis required, so--include-sbom-files 20is a limit of 20, never a path. A value below 1 exits 1 before auth and upload.Request field on
POST /api/v1/ingest/scan:include_sbom_files: N, sent only with the flag. The request body is unchanged for every other scan.Results and warning:
/api/v1/ingest/resultscarriessbom_scan_status,sbom_scan_reasons,sbom_skipped_filesandsbom_skipped_countwhen SBOM files were scanned.PARTIALorFAILED, the CLI prints one warning with the reasons in plain words and up to five skipped paths, such as:SBOM scan incomplete: 4 SBOM file(s) were not scanned (over the SBOM file limit, too large). Their findings keep their previous state. Skipped: ...--bomdownloads and before the scanner-skip message.Docs: README section "Scan SBOM Files in the Repository", a usage example, and a CHANGELOG entry under Unreleased.
Testing
Automated Tests
The tests cover:
OnScanRequestgo test ./...(23 packages),go vetand golangci-lint v2.15.0 pass.Manual Testing
The branch's binary was run against a local backend built from the matching backend change (Project-Moose #3191), using real Grype and public CycloneDX/SPDX SBOMs:
--include-sbom-files 20and4: SBOM findings returned, PARTIAL warning printed. The exit code was set only by findings; a warning alone exits 0.Reviewer Notes
--sbom: that flag generates an SBOM of the scanned repository. The README calls this out.mainalso fail on this branch. They are not touched here:go-mod-tidy:scan_bom_test.goimportsspf13/pflagdirectly.Checklist
Screenshots (if applicable)
N/A