Repository navigation
ci: add the shared scan-image action - #19
Merged
Merged
Conversation
Add actions/scan-image, based on FOCA's copy (the newest pins), with the Trivy binary version as the new input trivy-version. The CI test job scans a clean image (and checks the full report) and an image with fixable findings (and expects a failure). Refs #14 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAdds and documents the shared, pinned Sequence diagram for the shared image scan actionsequenceDiagram
participant Job as CI job
participant Action as scan-image
participant Trivy as Trivy
participant CodeQL as Code scanning
participant Artifact as Workflow artifact
Job->>Action: Invoke with image, category, upload, report, fail
Action->>Trivy: Scan image with ignore-unfixed
Trivy-->>Action: Fixable findings as trivy-results.sarif
opt upload == true
Action->>CodeQL: upload-sarif(trivy-results.sarif, category)
end
opt report == true
Action->>Trivy: Scan image as JSON and table
Trivy-->>Action: trivy-report.json and trivy-report.txt
Action->>Artifact: Upload trivy-report-category
end
opt fail == true
Action->>Trivy: Scan severity CRITICAL,HIGH with exit-code 1
Trivy-->>Action: Success or failure on fixable findings
end
Flow diagram for CI validation of image scanningflowchart LR
Prepare[Prepare clean and vulnerable images] --> Clean[scan-image clean image]
Clean --> Reports[Check SARIF, JSON, and table reports]
Prepare --> Vulnerable[scan-image alpine:3.10.0]
Vulnerable --> Expected[Expect failure on fixable HIGH/CRITICAL findings]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
uniqueg
marked this pull request as ready for review
October 28, 2026 06:37
There was a problem hiding this comment.
Hey - I've found 6 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="actions/scan-image/action.yml" line_range="45" />
<code_context>
+ uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
+ with:
+ image-ref: ${{ inputs.image }}
+ trivyignores: .trivyignore.yaml
+ ignore-unfixed: true
+ format: sarif
</code_context>
<issue_to_address>
**Pull requests can suppress findings**
When a contributor adds a matching vulnerability to the caller’s `.trivyignore.yaml` in a PR that runs this action, trivy reads the caller’s PR-controlled `.trivyignore.yaml` for the SARIF scan and the failure check, so a contributor can suppress a fixable critical or high finding and make the scan pass without reporting it.
Load accepted findings only from a trusted base-branch configuration, or require trusted review of changes to the ignore file before scanning it.
Also at `actions/scan-image/action.yml:61`, `actions/scan-image/action.yml:71`, `actions/scan-image/action.yml:90`.
</issue_to_address>
### Comment 2
<location path="actions/scan-image/action.yml" line_range="45" />
<code_context>
+ uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
+ with:
+ image-ref: ${{ inputs.image }}
+ trivyignores: .trivyignore.yaml
+ ignore-unfixed: true
+ format: sarif
</code_context>
<issue_to_address>
**Scans fail without an ignore file**
When the caller’s workspace does not contain `.trivyignore.yaml`, the Trivy action receives `.trivyignore.yaml` unconditionally, so Trivy fails before producing scan results and callers cannot use the action.
Make the ignore-file option conditional on the file being present or provide a fallback.
Also at `actions/scan-image/action.yml:61`, `actions/scan-image/action.yml:71`, `actions/scan-image/action.yml:90`.
</issue_to_address>
### Comment 3
<location path="actions/scan-image/action.yml" line_range="91-92" />
<code_context>
+ with:
+ image-ref: ${{ inputs.image }}
+ trivyignores: .trivyignore.yaml
+ severity: CRITICAL,HIGH
+ ignore-unfixed: true
+ exit-code: "1"
+ version: ${{ inputs.trivy-version }}
</code_context>
<issue_to_address>
**Unfixed secrets fail the scan**
When the image contains a CRITICAL or HIGH secret finding, trivy’s `ignore-unfixed` filters vulnerabilities, not secret findings, so the secret remains in the final scan and `exit-code: 1` fails the action outside the fixable-findings gate.
Keep secret findings from triggering the final fixable-vulnerability failure gate.
Also at `actions/scan-image/action.yml:46`.
</issue_to_address>
### Comment 4
<location path="actions/scan-image/action.yml" line_range="44" />
<code_context>
+ - name: Scan image (fixable findings)
+ uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
+ with:
+ image-ref: ${{ inputs.image }}
+ trivyignores: .trivyignore.yaml
+ ignore-unfixed: true
</code_context>
<issue_to_address>
**Scan results describe different images**
When a registry tag is updated between the separate scan steps, each Trivy step resolves `inputs.image` independently, so the SARIF, full report, and failure check can describe different image contents and callers receive contradictory scan results.
Resolve the image reference once and use the same image for every Trivy step.
Also at `actions/scan-image/action.yml:60`, `actions/scan-image/action.yml:70`, `actions/scan-image/action.yml:89`.
</issue_to_address>
### Comment 5
<location path=".github/workflows/ci.yml" line_range="124-127" />
<code_context>
+ env:
+ OUTCOME: ${{ steps.bad-image.outcome }}
+ run: |
+ if [[ "${OUTCOME}" != failure ]]; then
+ echo "::error::Expected the scan of the vulnerable image to fail, got ${OUTCOME}"
+ exit 1
+ fi
passed:
</code_context>
<issue_to_address>
**Unrelated failures pass the gate test**
When the vulnerable-image scan fails for a reason other than detecting fixable critical or high findings, the CI check accepts any `failure` outcome from the scan step, so a failure before Trivy evaluates the findings passes as though the fixable-findings gate worked.
Verify that the scan failed because it detected fixable critical or high findings, rather than checking only the step outcome.
</issue_to_address>
### Comment 6
<location path="actions/scan-image/action.yml" line_range="80" />
<code_context>
+ if: inputs.report == 'true'
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: trivy-report-${{ inputs.category }}
+ path: |
+ trivy-report.json
</code_context>
<issue_to_address>
**Some categories prevent report uploads**
When `report` is `true` and `category` contains a character rejected in artifact names, such as `/` or `:`, `upload-artifact` rejects the interpolated artifact name, so the artifact step fails and the action does not publish the report.
Sanitize the category before using it in the artifact name or reject invalid categories with a clear validation error.
</issue_to_address>Sourcery assessment
Approval pending. 6 findings to address first.
Blocking findings: actions/scan-image/action.yml:45, actions/scan-image/action.yml:45, actions/scan-image/action.yml:92, actions/scan-image/action.yml:44, .github/workflows/ci.yml:127, and 1 more
Expect findings in the SARIF results of the vulnerable image, so that a failure before the scan doesn't pass the test, and document the ignore file, the category characters, digests and secret findings. Refs #14 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Adds the shared composite action
actions/scan-image, based on FOCA's copy (the newest pins: trivy-action v0.36.0, upload-sarif v4.39.1, upload-artifact v7.0.2). The Trivy binary version is now the inputtrivy-version(defaultv0.75.0); the README notes that Dependabot doesn't bump it. Dependabot already covers/actions/*, so nodependabot.ymlchange is needed.The rollout in the caller repos is split off into child issues of #11, each blocked by this issue: elixir-cloud-aai/foca#548, elixir-cloud-aai/cloud-registry#270, elixir-cloud-aai/protes#329 (trs-filer has no copy yet).
Closes #14
Verification
pre-commit run --all-files(yamllint/schema checks, markdownlint, actionlint, gitleaks): passed.testjob scan a clean image builtFROM scratch(expect success and the full report files) andalpine:3.10.0(expect the step to fail on fixable findings). CI passed (run 40644536425): the vulnerable scan failed on "Total: 12 (HIGH: 9, CRITICAL: 3)" as intended.Light lane: the action is a copy of an already reviewed action plus one input; the change touches CI only, with no secrets, permissions or release workflow.
Declined review findings
None.
Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Introduce and validate a shared Trivy-based Docker image scanning action for use across workflows.
New Features:
Enhancements:
CI:
Documentation: