ci: add Trivy security scan to PR pipeline - #63
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe pull request adds a composite Trivy action. The action resolves Maven dependencies, scans repository files and Dockerfile base images, aggregates findings, and fails on unfixed HIGH or CRITICAL vulnerabilities. A pull-request workflow job runs the scan and gates ChangesTrivy security scanning
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PullRequest
participant trivy_scan
participant TrivyAction
participant Maven
participant Trivy
PullRequest->>trivy_scan: trigger eligible pull request job
trivy_scan->>TrivyAction: run shared scan action
TrivyAction->>Maven: resolve project dependencies
TrivyAction->>Trivy: scan files and Dockerfile base images
Trivy-->>TrivyAction: return vulnerability reports
TrivyAction-->>trivy_scan: return scan status
trivy_scan-->>PullRequest: publish job result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/steps/trivy/action.yml:
- Around line 62-67: Update the trivy image-scan failure branch in the loop
around the `trivy image` command to exit nonzero when scanning a concrete image
fails, instead of always echoing and continuing. Preserve the existing skip
behavior for `scratch` and unresolved image variables by ensuring those cases
are filtered before this failure path.
- Around line 13-17: Update the Install Trivy step’s uses reference from the
mutable aquasecurity/setup-trivy@v0.3.1 tag to a reviewed, immutable
40-character commit SHA, keeping the existing version and cache inputs
unchanged.
- Around line 37-39: Update the Maven arguments in the dependency-resolution
step to remove the -fn flag, and make the mvn invocation propagate
dependency:go-offline failures instead of converting them into a warning.
Preserve the existing arguments and optional .mvn/settings.xml handling.
In @.github/workflows/test.yml:
- Around line 45-56: Update the trivy_scan workflow so fork pull requests never
run tokenized Maven dependency resolution: disable credential persistence in the
Checkout step and remove or conditionally skip the Trivy composite action’s
Maven resolution for fork-originated pull requests, while preserving it for
same-repository pull requests as appropriate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 241c476c-3c1b-40af-99ff-2237a53055a1
📒 Files selected for processing (3)
.github/steps/trivy/action.yml.github/workflows/test.yml.trivyignore
f77f8d7 to
60f2104
Compare
…s for skipped scans
…to scan_code/scan_image
…d commit status for image scan
…aml, single Scan Code job in libs
60f2104 to
9f345d2
Compare
Adds a Trivy-based PR security gate:
Summary by CodeRabbit