Repository navigation
feat(workflows)!: step 4, scan every published image with Trivy - #44
seantronsen wants to merge 12 commits into
Conversation
|
Tests: OpenCHAMI/github-actions-testbed#7 (the testbed |
271fd5e to
e249218
Compare
e249218 to
3f48376
Compare
|
Conflicts to be resolved if/when #41 is merged. |
|
Will review once this is rebased. |
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
3f48376 to
47c0b6c
Compare
done |
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
…kflow Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Respectfully, I'd like to push back on this: #44 (comment) I looked around the org first. Some repos support workflow_dispatch for their own Trivy setups, but I didn't find any that actually use it. This workflow is meant to replace those setups as the standard, so it should follow the build workflow's design rather than carry over unused features. trivy-image-scan scans what build-release-goreleaser publishes, and that only runs on PRs (pr-) and v* tag pushes. A manual run has nothing new to scan, so a PR-number or tag override would just be extra logic for a case the build doesn't support. So the goals are:
Ongoing CVE coverage for published images until their EOL (e.g. a scheduled rescan) is worth having, but that's out of scope for this PR. If it's something you want, I can create a tracking issue and implement immediately after the release of v4. |
|
I'm fine if we restrict how it runs, as long as we are explicit both in documentation and error modes.
The org is probably not a good reference. Most of the actions there aren't exactly fleshed out. This PR stack is probably the first attempt at any "standard" flow, which is why I bring up the failure mode accommodation here.
As stated above, limiting the run mode for this action to tag pushes is fine as long asthe documentation is clear about that and any attempt to run otherwise is met with a clear error. My thought for workflow_dispatch is if a scan needs to run to scan a test image, but I don't see that as a common use case. |
Co-authored-by: Devon Bautista <17506592+synackd@users.noreply.github.com> Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
4a049f1 to
7ccf3e8
Compare
Tracking issue created: #61 |
synackd
left a comment
There was a problem hiding this comment.
I think this is largely good, just a documentation nit.
|
|
||
| ### trivy-image-scan (Reusable Workflow) | ||
| Scans an already-pushed container image with Trivy and uploads SARIF findings to GitHub Advanced Security. Designed to chain after `build-release-goreleaser`. | ||
| Scans already-pushed container images with Trivy and uploads SARIF findings to GitHub Advanced Security. It scans each image at the build's tag (`pr-<N>` on pull requests, else the pushed `v*` tag; any other trigger fails), one job per image, by digest. Fork PRs publish no images and are skipped. GitHub doesn't let `GITHUB_TOKEN` list packages, so image names come from `images`, else the `ghcr.io` entries in the GoReleaser config (`dockers_v2[].images`), else the repository name (see `discover-ghcr-images`). Every name must be an existing package; all bad names are reported, then the run fails. Run it after `build-release-goreleaser`. |
There was a problem hiding this comment.
This paragraph explicitly states that unsupported triggers fail, but that restriction is embedded in the longer explanation of scanning and image discovery. The usage example below starts at jobs:, so someone copying it could miss which caller events are supported.
I think it might be better to put a short callout immediately before Usage and include the caller's triggers in the example, since that would make the restriction easier to discover before running the workflow. For example:
Supported triggers: Call this workflow from
pull_requestevents orpushevents for tags beginning withv. Other events—includingworkflow_dispatch,workflow_run, andrelease—fail with an error. Run the scan after the image-publishing job.
on:
pull_request:
push:
tags: ['v*']That would also make the documentation's event names directly match the trigger check and error message. This is a readability suggestion; the restriction is already documented correctly.
There was a problem hiding this comment.
I'm fine with this and will do it when I get home, but it also hints at a larger docs update. In another PR higher up in the stack, I reorganized all the docs into a focused layout, but my original plan was to hold off on major content changes across the board until the current stack is approved (another reason for the release staging setup) to avoid unnecessary contention over the .md files (simplifies stack rebases).
Signed-off-by: Sean Tronsen <sean.tronsen@gmail.com>
Description
Decouples Trivy image scanning from the build workflows so repos that publish more than one image get every image scanned, without passing outputs between workflows.
trivy-image-scan: finds image names with the newactions/discover-ghcr-imagesaction (theimagesinput, else theghcr.ioentries in the GoReleaser config, else the repo name), verifies they exist, and scans each one at the build's tag (pr-<N>on PRs, else the pushedv*tag; any other trigger fails), one job per image, with a SARIF category per image.GITHUB_TOKENcan't list packages, hence the name sources.image-refinput; callers grantpackages: readinstead.Testbed: OpenCHAMI/github-actions-testbed#7.
Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryType of Change