Add terraform scanner wokrflow - #7
Conversation
|
Caution Review failedPull request was closed or merged during review Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new GitHub Actions workflow that runs Trivy IaC scans on PRs touching Terraform files, and updates the linter workflow to broaden PR trigger types and run on PR events or when a pull request review is approved. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant GH as GitHub
participant Runner as Actions Runner
participant Trivy as Trivy IaC Scanner
participant Upload as SARIF Uploader
Dev->>GH: Open/update PR touching *.tf/*.tfvars/*.hcl
GH->>Runner: Trigger terraform-scan workflow
Runner->>Runner: Checkout repository
Runner->>Trivy: Run Trivy IaC (misconf, fs) -> produce trivy.sarif
Trivy->>Upload: Provide trivy.sarif
Upload->>GH: Upload SARIF results to Code Scanning
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
🧹 Nitpick comments (1)
.github/workflows/terraform-scan.yml (1)
30-34: Pincodeql-actionto SHA for supply chain security consistency.Similar to the tfsec-action, consider using SHA pinning instead of tag reference for consistent security posture across the workflow.
The
if: always()condition is correctly used to ensure SARIF results are uploaded even when the scan step fails.🔒 Proposed fix for consistent SHA pinning
- name: Upload tfsec SARIF if: always() - uses: github/codeql-action/upload-sarif@v3 + uses: github/codeql-action/upload-sarif@<SHA> # v3 with: sarif_file: tfsec.sarifYou can find the latest v3 SHA by running:
gh api repos/github/codeql-action/git/matching-refs/tags/v3 --jq '.[0].object.sha'🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/terraform-scan.yml around lines 30 - 34, The GitHub Actions step named "Upload tfsec SARIF" currently uses the tag reference "github/codeql-action/upload-sarif@v3"; replace this tag with the corresponding commit SHA to pin the action for supply-chain security (e.g., "github/codeql-action/upload-sarif@<commit-sha>"). Keep the existing "if: always()" behavior and the "sarif_file: tfsec.sarif" input unchanged; only change the uses reference to the resolved SHA for the upload-sarif action.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/terraform-scan.yml:
- Around line 30-34: The GitHub Actions step named "Upload tfsec SARIF"
currently uses the tag reference "github/codeql-action/upload-sarif@v3"; replace
this tag with the corresponding commit SHA to pin the action for supply-chain
security (e.g., "github/codeql-action/upload-sarif@<commit-sha>"). Keep the
existing "if: always()" behavior and the "sarif_file: tfsec.sarif" input
unchanged; only change the uses reference to the resolved SHA for the
upload-sarif action.
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow to run tfsec on Terraform-related pull requests and publish results to GitHub code scanning.
Changes:
- Introduces a new workflow triggered on PRs touching
.tf,.tfvars, and.hclfiles - Runs
aquasecurity/tfsec-actionand uploads SARIF output viaupload-sarif
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Purpose
$subject

Security checks
Summary by CodeRabbit