-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add security check before docker publish #625
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request modifies the GitHub Actions workflow for Docker image release by introducing a vulnerability scanning step using Trivy before pushing the image. The workflow now separates the image build and push processes, with an intermediate security scanning step. This ensures that only images passing critical and high-severity vulnerability checks are pushed to the Docker registry. Changes
Sequence DiagramsequenceDiagram
participant Workflow as GitHub Actions
participant Builder as Docker Build
participant Scanner as Trivy
participant Registry as DockerHub
Workflow->>Builder: Build Docker image
Builder-->>Workflow: Image built (not pushed)
Workflow->>Scanner: Scan image for vulnerabilities
alt Scan Passes
Scanner-->>Workflow: No critical/high vulnerabilities
Workflow->>Registry: Push image
else Scan Fails
Scanner-->>Workflow: Critical/high vulnerabilities detected
Workflow->>Workflow: Halt deployment
end
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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 (3)
.github/workflows/release-image.yml (3)
39-45
: Update Trivy configuration for better security coverage.Consider the following improvements:
- Update Trivy to the latest version (current is 0.49.1)
- Include MEDIUM severity for better coverage
- Use 'sarif' format for better CI/CD integration and GitHub Security tab support
- uses: aquasecurity/[email protected] + uses: aquasecurity/[email protected] with: image-ref: ${{ env.TAGS }} - format: 'table' + format: 'sarif' + output: 'trivy-results.sarif' exit-code: '1' - severity: 'CRITICAL,HIGH' + severity: 'CRITICAL,HIGH,MEDIUM'
47-50
: Consider adding error handling for the push step.While the implementation is correct, consider adding error handling using
continue-on-error: false
and a notification step (e.g., Slack) on failure.- name: Push image uses: docker/build-push-action@v5 + continue-on-error: false with: context: . push: true tags: ${{ env.TAGS }} + - name: Notify on failure + if: failure() + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,commit,author,action,eventName,ref,workflow,job,took + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
38-38
: Remove trailing spaces.The yamllint tool detected trailing spaces on lines 38 and 46.
- tags: ${{ env.TAGS }} + tags: ${{ env.TAGS }} - severity: 'CRITICAL,HIGH' + severity: 'CRITICAL,HIGH'Also applies to: 46-46
🧰 Tools
🪛 yamllint (1.35.1)
[error] 38-38: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/release-image.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/release-image.yml
[error] 38-38: trailing spaces
(trailing-spaces)
[error] 46-46: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (1)
.github/workflows/release-image.yml (1)
36-37
: LGTM! Good separation of build and push steps.Separating the build and push steps is a good practice as it allows for intermediate validation steps.
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
User description
Fix #624
PR Type
Enhancement, Bug fix
Description
Added a security vulnerability scan step before pushing Docker images.
Integrated
aquasecurity/trivy-action
for scanning Docker images.Updated the GitHub Actions workflow to ensure secure image publishing.
Changes walkthrough 📝
release-image.yml
Add security scan step to Docker workflow
.github/workflows/release-image.yml
aquasecurity/trivy-action
.Summary by CodeRabbit