Skip to content

feat: add security scanning workflow (cargo audit + Trivy) (#177) - #220

Merged
ajianaz merged 4 commits into
developfrom
feat/security-scanning-workflow
Jun 7, 2026
Merged

ajianaz merged 4 commits into
developfrom
feat/security-scanning-workflow

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds automated security scanning CI workflow. Closes #177.

What's added

  • .github/workflows/security.yml — new workflow with 2 jobs:
    • Cargo Audit: scans Rust dependencies for known vulnerabilities
    • Trivy FS Scan: filesystem scan for CRITICAL/HIGH severity CVEs

Triggers

  • Push to develop / main
  • PRs to develop
  • Daily schedule at 06:00 UTC
  • Manual dispatch

Fixes included

  • Updated quinn-proto 0.11.12 to 0.11.14 (fixes CVE-2026-31812)
  • Both cargo audit and Trivy now report clean

Closes #177

Summary by CodeRabbit

  • Chores
    • Implemented automated security scanning in the CI/CD pipeline to identify vulnerabilities in dependencies and codebase through scheduled checks and pull request validation.

ajianaz added 2 commits June 7, 2026 20:42
- 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
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ajianaz, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78582a81-73b2-4d48-ad83-57e4e690dd63

📥 Commits

Reviewing files that changed from the base of the PR and between ee7dedd and 38c5518.

📒 Files selected for processing (1)
  • .github/workflows/security.yml
📝 Walkthrough

Walkthrough

Introduces a new GitHub Actions security scanning workflow that automatically runs Rust dependency checks via cargo audit and filesystem vulnerability scanning via Trivy on pushes to main/develop branches, pull requests targeting develop, and a daily schedule. The workflow fails the build on CRITICAL/HIGH severity findings while ignoring specific advisories and unfixed vulnerabilities.

Changes

Security scanning workflow

Layer / File(s) Summary
Security scanning workflow setup
.github/workflows/security.yml
Workflow metadata and trigger conditions defined (push to develop/main, PR to develop, scheduled daily at 06:00 UTC, manual dispatch). Cargo-audit job checks Rust dependencies and ignores advisory RUSTSEC-2024-0436 (documented as unmaintained/informational). Trivy job runs filesystem CVE scan with table output format, exits with code 1 on CRITICAL/HIGH findings, and configured to ignore unfixed issues. Node 24 runtime enforced via environment variable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Poem

🐰 A workflow of guards, now standing tall,
Cargo-audit scans, and Trivy watches all,
On push and pull, each day at dawn,
Security shadows forever drawn,
The code's now safer, strong and sound! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements cargo-audit and Trivy filesystem scanning as required, but omits the trivy-secrets job specified in issue #177 acceptance criteria. Add the missing trivy-secrets job to run Trivy secret detection configured to exit with code 1 on findings, as required by issue #177.
Out of Scope Changes check ⚠️ Warning The PR includes an out-of-scope change: updating quinn-proto dependency from 0.11.12 to 0.11.14, which is unrelated to the security workflow implementation. Either separate the quinn-proto dependency update into a dedicated PR or justify its inclusion as part of security scanning infrastructure requirements.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a security scanning workflow with cargo-audit and Trivy, matching the primary objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/security-scanning-workflow

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-cli · BYOK · MIT

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Harden the trivy job against supply chain attacks.

The job has the same security gaps as cargo-audit:

  1. Actions not pinned to hash: Tags can be moved by attackers. Pin to commit hashes.
  2. Credentials persist: actions/checkout should set persist-credentials: false.
  3. Overly broad permissions: Specify minimal read-only permissions.
🔒 Proposed hardening for trivy job

First, add a permissions block 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-29

Note: 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 win

Critical: Missing required trivy-secrets job.

The PR objectives explicitly require three jobs based on issue #177:

  1. cargo-audit ✓
  2. trivy (filesystem CVE scan) ✓
  3. 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 trivy job (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, and exit-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 value

Consider caching or pinning the cargo-audit version.

Installing cargo-audit on 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 || true

Option 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

📥 Commits

Reviewing files that changed from the base of the PR and between fdd36b3 and ee7dedd.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • .github/workflows/security.yml

Comment on lines +17 to +28
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Harden the cargo-audit job against supply chain attacks.

The job has several security gaps:

  1. Actions not pinned to hash: Tags like @v4 and @stable can be moved by attackers. Pin to commit hashes.
  2. Credentials persist: actions/checkout should set persist-credentials: false to prevent credentials from being written to .git/config.
  3. 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-16

Note: 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

@ajianaz
ajianaz merged commit 6297968 into develop Jun 7, 2026
9 checks passed
@ajianaz
ajianaz deleted the feat/security-scanning-workflow branch June 7, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add security scanning workflow (cargo audit + Trivy)

1 participant