Repository navigation
feat(cve-scan): add a source mode that scans a go.mod with snyk test - #378
Draft
vcauesantos wants to merge 1 commit into
Draft
vcauesantos wants to merge 1 commit into
vcauesantos wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What happened
vcluster-sdk is a Go library. It publishes no image, so the daily CVE scan never covers it. The
cve-scanaction can only scan images:image-refis required, the action pulls the image, and the Snyk adapter runssnyk container test. So libraries get no CVE alerts in the Security tab, and the cve-remediation agent never sees them.What this PR changes
cve-scancan now scan ago.modinstead of an image. A newsource-pathinput points at a manifest inside the checkout. When it is set, the action skips the registry login and the image pull, and Snyk runssnyk test --file=<path>. Counting, the severity threshold, Slack messages and the job summary are shared with image mode. The summary and Slack text name the repo and path instead of an image.Exactly one of
image-refandsource-pathmust be set.image-refis now optional. Setting both, or neither, is a config error. A source path must be relative, stay inside the checkout, and exist.dockerfile-pathonly makes sense for an image, so it is rejected in source mode.Source SARIF gets its own category. Runs are keyed as
Snyk/OpenSource/<path>/..., so they never collide with the image categories already in the Security tab.Each vulnerability is counted once.
snyk testlists one entry per dependency path, so the same CVE can appear several times. Source mode dedupes by id. Image mode counts exactly as before.Existing callers are unaffected. With
source-pathempty, every image caller runs the same code as today, and the result JSON still uses theimagekey. That keeps the change safe to ship oncve-scan/v1.The caller must check out the code and set up Go before the action, since Snyk resolves Go modules with the Go toolchain. The README has a source-mode example.
How it was tested
dockerfile-pathwith a source path, the dedupe, and the SARIF category. All 166 tests pass, also under bash 5 in Docker.source-pathand checks it fails with the path in the summary.make lint(shellcheck, actionlint, zizmor) andmake check-docspass.Not yet checked against real Snyk: the tool name and category it writes for
snyk test. The vcluster-sdk caller will test that from this branch before merge.Related to DEVOPS-1882