-
Notifications
You must be signed in to change notification settings - Fork 125
NO-JIRA: chore(workflows): add Trivy scan action for container image and filesystem vulnerability scanning #2788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Skipping CI for Draft Pull Request. |
|
Warning Rate limit exceeded@jiridanek has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 24 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
WalkthroughAdds a new reusable composite GitHub Action for Trivy scans, integrates it into the build-notebooks workflow (replacing inline scan steps), and adds a test workflow that exercises image and filesystem scan modes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/actions/trivy-scan-action/action.yml (1)
127-136: Summary step correctly handles missing report file.The step appropriately warns when the report file is not found rather than failing, which is useful when the scan step fails. Consider adding
if: always()to ensure the summary is added even when the scan step fails.🔎 Optional improvement
- name: Add report to job summary + if: always() shell: bash run: |
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/actions/trivy-scan-action/action.yml(1 hunks).github/workflows/build-notebooks-TEMPLATE.yaml(1 hunks).github/workflows/test-trivy-scan-action.yaml(1 hunks)
🔇 Additional comments (5)
.github/workflows/build-notebooks-TEMPLATE.yaml (1)
364-371: Clean refactoring to use the reusable action.The integration properly delegates Trivy scanning to the new composite action with all required inputs. The workflow maintains consistency by using the existing
TRIVY_VERSIONenvironment variable..github/workflows/test-trivy-scan-action.yaml (2)
27-43: Good conditional dependency installation.The approach of collecting missing packages into an array before running apt-get is efficient and avoids unnecessary apt-get calls when dependencies are already present.
45-57: Proper socket access configuration.The ACL configuration correctly grants the runner user access to the rootful podman socket. Execute permission on the directory for traversal and read-write on the socket for communication are the minimum required permissions.
.github/actions/trivy-scan-action/action.yml (2)
67-81: Well-structured setup step with proper error handling.Good use of
set -Eeuo pipefailand proper variable quoting throughout. The template is correctly copied to the report folder for access within the Trivy container.
111-123: Verify unquoted variable expansions are intentional.The variables
$PODMAN_ARGS(line 112) and$SCAN_ARGS(line 116) are intentionally unquoted to allow word splitting for multiple arguments. This works correctly as long as paths don't contain spaces. Given that GitHub workspace paths and podman socket paths typically don't contain spaces, this is acceptable.Ensure that
inputs.podman-socketandinputs.workspace-pathdon't contain spaces in actual usage. The default values are safe.
827dcf7 to
f021316
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ide-developer The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/actions/trivy-scan-action/action.yml (1)
114-127: Consider adding a brief comment explaining intentional unquoting.The unquoted
$PODMAN_ARGS(line 116) and$SCAN_ARGS(line 120) are correct—they must be unquoted to allow word splitting for multiple arguments. A brief inline comment would help future maintainers understand this is intentional rather than an oversight, especially given the PR's focus on quoting improvements.🔎 Suggested comment
# Run Trivy scan in container + # Note: PODMAN_ARGS and SCAN_ARGS are intentionally unquoted to allow word splitting podman run --rm \ $PODMAN_ARGS \
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/actions/trivy-scan-action/action.yml(1 hunks).github/workflows/build-notebooks-TEMPLATE.yaml(1 hunks).github/workflows/test-trivy-scan-action.yaml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/test-trivy-scan-action.yaml
🔇 Additional comments (4)
.github/workflows/build-notebooks-TEMPLATE.yaml (1)
364-371: LGTM!The refactoring from inline Trivy orchestration to the reusable composite action is clean. The inputs are correctly mapped from the
resolve-targetstep outputs, and the hardcodedpodman-socketpath aligns with theCONTAINER_HOSTenvironment variable defined earlier in the workflow..github/actions/trivy-scan-action/action.yml (3)
67-81: LGTM!The setup step correctly initializes the report directory with proper error handling (
set -Eeuo pipefail) and consistent quoting of variables and paths.
102-112: Consider addingSCAN_ARGSfor filesystem scans if needed.Currently, the
fsbranch leavesSCAN_ARGSempty (from the default initialization). This works, but for clarity and future extensibility, you might want to document this or consider if any fs-specific arguments are needed.The current implementation is correct and functional.
131-140: LGTM!The summary step includes proper error handling with
set -Eeuo pipefailand a defensive check for the report file's existence. The warning message for missing reports is appropriate rather than failing the step.
…and filesystem vulnerability scanning Improved bash script robustness in [`.github/actions/trivy-scan-action/action.yml`](.github/actions/trivy-scan-action/action.yml:1) by adding: **Error Handling:** - Added `set -Eeuo pipefail` at the beginning of all three bash script blocks (lines 71, 86, 128) - Ensures scripts fail fast on errors, undefined variables, and pipeline failures **Variable Quoting:** - Quoted all variable assignments and expansions to handle paths with spaces and special characters - Applied to: `REPORT_FOLDER`, `REPORT_FILE`, `REPORT_TEMPLATE`, `SCAN_TARGET`, `SCAN_TYPE` - Quoted all GitHub Actions inputs and step outputs references - Quoted command substitutions like `basename` - Quoted file operations: `mkdir`, `cp`, `cat` - Quoted `podman run` arguments including volume mounts and image references **Key Improvements:** - Prevents word splitting and globbing issues - Ensures silent failures are caught immediately - Handles edge cases with special characters in paths - Maintains compatibility with existing functionality while adding robustness
f021316 to
e4779b8
Compare
|
New changes are detected. LGTM label has been removed. |
|
@coderabbitai create github issue for .github/actions/trivy-scan-action/action.yml (1) The step appropriately warns when the report file is not found rather than failing, which is useful when the scan step fails. Consider adding if: always() to ensure the summary is added even when the scan step fails. 🔎 Optional improvement
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@jiridanek, I'll create a GitHub issue for this improvement suggestion. 🏁 Script executed: Length of output: 55 @jiridanek, I've created GitHub issue #2789 for the improvement suggestion to add |
Description
Enhanced bash script robustness in
.github/actions/trivy-scan-action/action.ymlwith comprehensive improvements:Error Handling:
set -Eeuo pipefailto all three bash script blocks (lines 71, 87, 130)Variable Initialization:
SCAN_ARGS=""andPODMAN_ARGS=""(lines 95-96)set -uVariable Quoting:
REPORT_FOLDER,REPORT_FILE,REPORT_TEMPLATE,SCAN_TARGET,SCAN_TYPEbasenamemkdir,cp,catpodman runarguments including volume mounts and image referencesBenefits:
How Has This Been Tested?
Self checklist (all need to be checked):
make test(gmakeon macOS) before asking for reviewDockerfile.konfluxfiles should be done inodh/notebooksand automatically synced torhds/notebooks. For Konflux-specific changes, modifyDockerfile.konfluxfiles directly inrhds/notebooksas these require special attention in the downstream repository and flow to the upcoming RHOAI release.Merge criteria:
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.