Repository navigation
feat: add security scanning workflow (cargo audit + Trivy) (#177) - #220
Conversation
- New GitHub Actions workflow: security.yml - cargo audit: scans Rust dependencies for known vulnerabilities - Trivy: filesystem scan for CRITICAL/HIGH severity issues - Runs on push to develop/main, PRs to develop, daily schedule - Updated quinn-proto 0.11.12 → 0.11.14 (fixes CVE-2026-31812) - Both scanners now report clean
|
Warning Review limit reached
More reviews will be available in 47 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIntroduces a new GitHub Actions security scanning workflow that automatically runs Rust dependency checks via ChangesSecurity scanning workflow
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-cli · BYOK · MIT |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.github/workflows/security.yml (2)
30-44:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHarden the trivy job against supply chain attacks.
The job has the same security gaps as cargo-audit:
- Actions not pinned to hash: Tags can be moved by attackers. Pin to commit hashes.
- Credentials persist:
actions/checkoutshould setpersist-credentials: false.- Overly broad permissions: Specify minimal read-only permissions.
🔒 Proposed hardening for trivy job
First, add a
permissionsblock to the job:trivy: name: Trivy FS Scan runs-on: ubuntu-latest + permissions: + contents: read steps:Then, update the steps to disable credential persistence and pin actions to commit hashes:
- - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false - name: Run Trivy vulnerability scanner - uses: aquasecurity/[email protected] + uses: aquasecurity/trivy-action@f8c766c8e1f3c2f0ae4adc2e8b463f3e1599c106 # 0.30.0, pinned 2025-01-29Note: Update the commit hashes to the latest verified versions from the respective repositories.
🤖 Prompt for 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. In @.github/workflows/security.yml around lines 30 - 44, The trivy job needs supply-chain hardening: add a minimal read-only permissions block for the job, set actions/checkout to persist-credentials: false, and replace floating tags for actions with pinned commit SHAs (replace actions/checkout@v4 and aquasecurity/[email protected] with their verified commit hashes); update the trivy step inputs unchanged but ensure you pin both action references and disable credential persistence for the checkout step.Source: Linters/SAST tools
16-44:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winCritical: Missing required trivy-secrets job.
The PR objectives explicitly require three jobs based on issue
#177:
- cargo-audit ✓
- trivy (filesystem CVE scan) ✓
- trivy-secrets (secret detection) ✗ MISSING
The acceptance criteria state: "Trivy secret scan fails the run when secrets are found." Without this job, the workflow cannot detect committed secrets (API keys, tokens, passwords), which defeats a core objective of the security workflow.
🔐 Proposed trivy-secrets job implementation
Add the following job after the
trivyjob (after line 44):ignore-unfixed: true + + trivy-secrets: + name: Trivy Secret Scan + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + - name: Run Trivy secret scanner + uses: aquasecurity/trivy-action@f8c766c8e1f3c2f0ae4adc2e8b463f3e1599c106 # 0.30.0 + with: + scan-type: "fs" + scan-ref: "." + scanners: "secret" + format: "table" + exit-code: "1"Note: Update the commit hashes to the latest verified versions. The
scanners: "secret"parameter configures Trivy to run only secret detection, andexit-code: "1"ensures the workflow fails when secrets are found (as required by the acceptance criteria).🤖 Prompt for 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. In @.github/workflows/security.yml around lines 16 - 44, Add a new GitHub Actions job named trivy-secrets (parallel to existing cargo-audit and trivy jobs) that runs on ubuntu-latest and uses aquasecurity/trivy-action to perform a Trivy secret scan; configure the job to check the repository (scan-ref: ".") with scanners: "secret" and set exit-code: "1" so the workflow fails if any secrets are found, and mirror the checkout step used in the trivy job to ensure the scanner has the repo contents. Reference the existing job names cargo-audit and trivy when locating where to insert the new trivy-secrets job.
🧹 Nitpick comments (1)
.github/workflows/security.yml (1)
23-24: 💤 Low valueConsider caching or pinning the cargo-audit version.
Installing
cargo-auditon every workflow run:
- Slows down the job (~30-60 seconds)
- Makes builds non-reproducible (latest version is always used)
- Introduces a dependency on crates.io availability
For better performance and reproducibility, consider one of these approaches:
Option 1: Use GitHub Actions cache:
- name: Cache cargo-audit uses: actions/cache@v4 with: path: ~/.cargo/bin/cargo-audit key: cargo-audit-${{ hashFiles('**/Cargo.lock') }} - name: Install cargo-audit run: cargo install cargo-audit || trueOption 2: Pin to a specific version:
run: cargo install cargo-audit --version 0.21.0🤖 Prompt for 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. In @.github/workflows/security.yml around lines 23 - 24, Update the workflow step named "Install cargo-audit" (which currently runs `cargo install cargo-audit`) to either add a cache step using actions/cache@v4 that caches the cargo-audit binary (keyed e.g. by Cargo.lock hash) and make the install idempotent (run `cargo install cargo-audit || true`), or pin the installation to a specific release by changing the command to `cargo install cargo-audit --version <x.y.z>` so runs are faster and reproducible; adjust the steps around the existing "Install cargo-audit" step accordingly.
🤖 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/workflows/security.yml:
- Around line 17-28: The cargo-audit job should be hardened: add a minimal
permissions block (e.g., contents: read) at the job level to avoid broad write
access, update the checkout step (uses: actions/checkout@v4) to include
persist-credentials: false, and replace floating action refs
(actions/checkout@v4 and dtolnay/rust-toolchain@stable) with pinned commit SHAs;
also consider pinning any other external actions used and ensure the "Install
cargo-audit" or "Run cargo audit" steps do not rely on persisted credentials or
elevated permissions.
---
Outside diff comments:
In @.github/workflows/security.yml:
- Around line 30-44: The trivy job needs supply-chain hardening: add a minimal
read-only permissions block for the job, set actions/checkout to
persist-credentials: false, and replace floating tags for actions with pinned
commit SHAs (replace actions/checkout@v4 and aquasecurity/[email protected]
with their verified commit hashes); update the trivy step inputs unchanged but
ensure you pin both action references and disable credential persistence for the
checkout step.
- Around line 16-44: Add a new GitHub Actions job named trivy-secrets (parallel
to existing cargo-audit and trivy jobs) that runs on ubuntu-latest and uses
aquasecurity/trivy-action to perform a Trivy secret scan; configure the job to
check the repository (scan-ref: ".") with scanners: "secret" and set exit-code:
"1" so the workflow fails if any secrets are found, and mirror the checkout step
used in the trivy job to ensure the scanner has the repo contents. Reference the
existing job names cargo-audit and trivy when locating where to insert the new
trivy-secrets job.
---
Nitpick comments:
In @.github/workflows/security.yml:
- Around line 23-24: Update the workflow step named "Install cargo-audit" (which
currently runs `cargo install cargo-audit`) to either add a cache step using
actions/cache@v4 that caches the cargo-audit binary (keyed e.g. by Cargo.lock
hash) and make the install idempotent (run `cargo install cargo-audit || true`),
or pin the installation to a specific release by changing the command to `cargo
install cargo-audit --version <x.y.z>` so runs are faster and reproducible;
adjust the steps around the existing "Install cargo-audit" step accordingly.
🪄 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
Run ID: 951bec12-689f-44f2-b485-723ffd43439b
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
.github/workflows/security.yml
| cargo-audit: | ||
| name: Cargo Audit | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
| - name: Install cargo-audit | ||
| run: cargo install cargo-audit | ||
| - name: Run cargo audit | ||
| # Ignored advisories (with justification): | ||
| # RUSTSEC-2024-0436: paste unmaintained — informational, no vulnerability | ||
| run: cargo audit --ignore RUSTSEC-2024-0436 |
There was a problem hiding this comment.
Harden the cargo-audit job against supply chain attacks.
The job has several security gaps:
- Actions not pinned to hash: Tags like
@v4and@stablecan be moved by attackers. Pin to commit hashes. - Credentials persist:
actions/checkoutshould setpersist-credentials: falseto prevent credentials from being written to.git/config. - Overly broad permissions: The job inherits default write permissions. Specify minimal read-only permissions.
🔒 Proposed hardening for cargo-audit job
First, add a permissions block to the job to grant minimal read-only access:
cargo-audit:
name: Cargo Audit
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:Then, update the checkout step to disable credential persistence and pin actions to commit hashes:
- - uses: actions/checkout@v4
- - uses: dtolnay/rust-toolchain@stable
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ with:
+ persist-credentials: false
+ - uses: dtolnay/rust-toolchain@41d0582c4400c94f946e8ddea86aa10c6a896191 # stable, pinned 2024-12-16Note: Update the commit hashes to the latest verified versions from the respective repositories.
🧰 Tools
🪛 zizmor (1.25.2)
[warning] 21-21: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 17-28: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[error] 21-21: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 22-22: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for 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.
In @.github/workflows/security.yml around lines 17 - 28, The cargo-audit job
should be hardened: add a minimal permissions block (e.g., contents: read) at
the job level to avoid broad write access, update the checkout step (uses:
actions/checkout@v4) to include persist-credentials: false, and replace floating
action refs (actions/checkout@v4 and dtolnay/rust-toolchain@stable) with pinned
commit SHAs; also consider pinning any other external actions used and ensure
the "Install cargo-audit" or "Run cargo audit" steps do not rely on persisted
credentials or elevated permissions.
Source: Linters/SAST tools
Summary
Adds automated security scanning CI workflow. Closes #177.
What's added
.github/workflows/security.yml— new workflow with 2 jobs:Triggers
Fixes included
Closes #177
Summary by CodeRabbit