refactor(ci): extract trivy image scan into separate reusable workflow - #290
Conversation
|
The failure with OSV-Scanner job will be addressed in a separate PR: #291 |
cf24a10 to
52060ff
Compare
The trivy_image job in reusable_vuln_scan.yml requires elevated permissions (packages: write, id-token: write) that cause startup failures in callers that only need source/dependency scanning. GitHub validates all job permissions at parse time, even for conditionally-skipped jobs. Extract trivy_image into reusable_trivy_image_scan.yml so callers can independently opt into image scanning with the required permissions, without affecting the lighter-weight vuln scan workflow. Changes: - New: reusable_trivy_image_scan.yml with the trivy_image job - Removed: trivy_image job, its inputs (enable_trivy_image, image_ref, image_digest), and outputs from reusable_vuln_scan.yml - Cleaned up concurrency group and permissions in reusable_vuln_scan.yml Fixes: complytime/.github Security Checks startup failure Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
The trivy-action installs the Trivy binary at runtime, defaulting to the latest release if no version is specified. zizmor flags this as unpinned-tools (supply chain risk). Pin to v0.70.0 in both reusable_vuln_scan.yml and reusable_trivy_image_scan.yml. Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
52060ff to
c0d6145
Compare
trevor-vaughan
left a comment
There was a problem hiding this comment.
The change makes sense but it needs a CI test in the current repo to self-validate before we push it out using both a positive and negative test case.
It can probably piggyback off of ci_test_publish_ghcr on a temp image.
The scan_result step checked for vulns but never wrote the passed output to GITHUB_OUTPUT, leaving the scan_passed workflow output always empty. Add the missing output assignment. Addresses PR complytime#290 review feedback from @trevor-vaughan. Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Add ci_test_trivy_image_scan.yml with positive and negative test cases: - Positive: builds a clean temp image, scans it, verifies scan_passed output and vuln attestation via cosign when digest is provided - Negative: verifies no attestation is produced when digest is omitted Follows the ci_test_publish_ghcr.yml pattern: build temp image, run tests, verify outputs, cleanup package versions. Addresses PR complytime#290 review feedback from @trevor-vaughan. Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
There was a problem hiding this comment.
@marcusburghardt I agree a CI self-test is valuable as per @trevor-vaughan ask to validate this. Apart from that Everything LGTM, I really liked the separation.
|
I am working on it. : ) |
|
Addressed in
Follows the |
|
@sonupreetam would you like to take a quick look again after the last two commits? |
|
@marcusburghardt Everything looks good, thank you! |
The scan_result step checked for vulns but never wrote the passed output to GITHUB_OUTPUT, leaving the scan_passed workflow output always empty. Add the missing output assignment. Addresses PR #290 review feedback from @trevor-vaughan. Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Summary
The
trivy_imagejob inreusable_vuln_scan.ymlrequires elevated permissions(
packages: write,id-token: write) that cause startup failures in callersthat only need source/dependency scanning. GitHub validates all job permissions at
parse time, even for conditionally-skipped jobs.
This PR extracts the
trivy_imagejob into a dedicatedreusable_trivy_image_scan.ymlso callers can independently opt into image scanning with the required permissions,
without affecting the lighter-weight vuln scan workflow.
reusable_trivy_image_scan.ymltrivy_imagejobreusable_vuln_scan.ymltrivy_imagejob, its inputs (enable_trivy_image,image_ref,image_digest), outputs, and cleaned up permissions and concurrency groupRelated Issues
Review Hints
The two files should be reviewed together. The new
reusable_trivy_image_scan.ymlis a direct extraction of thetrivy_imagejob fromreusable_vuln_scan.ymlwith its own inputs/outputs.All reusable workflow references in consumer repos are pinned to SHA
cfd981e(v0.2.1). Nothing breaks until a SHA is bumped, giving a safe migration window.After this merges and is tagged, consumer repos that use image scanning in their publish pipelines (
complytime-collector-components) need to update theirci_publish_ghcr.ymlto callreusable_trivy_image_scan.ymlinstead ofreusable_vuln_scan.ymlwithenable_trivy_image: true. A draft PR is already prepared: refactor(ci): use dedicated trivy image scan workflow complytime-collector-components#247.The synced
ci_security.ymlacross the org does not need changes -- it never usedenable_trivy_image. The next org sync will resolve the startup failures automatically.