Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ jobs:
target/
key: ${{ runner.os }}-security-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo-audit
run: cargo install cargo-audit --force
- name: Install cargo-audit (best-effort)
run: cargo install cargo-audit --force || echo "cargo-audit install failed, will fallback to cargo-deny"

- name: Install cargo-deny (fallback)
run: cargo install cargo-deny --version 0.17.0 --locked

- name: Run security audit
run: cargo audit --json > audit-results.json
- name: Run security audit (audit or deny advisories)
run: |
if command -v cargo-audit >/dev/null 2>&1; then
cargo audit --json > audit-results.json || true
else
cargo deny check advisories || true
# Optional JSON output is not available in this pinned version; artifact may be empty
: > audit-results.json
fi
continue-on-error: true

- name: Upload audit results
Expand All @@ -50,11 +60,16 @@ jobs:

- name: Fail on high/critical vulnerabilities
run: |
if cargo audit --deny warnings --deny unmaintained --deny unsound --deny yanked; then
echo "βœ… No high-risk vulnerabilities found"
if command -v cargo-audit >/dev/null 2>&1; then
if cargo audit --deny warnings --deny unmaintained --deny unsound --deny yanked; then
echo "βœ… No high-risk vulnerabilities found"
else
echo "❌ High-risk vulnerabilities detected"
exit 1
fi
else
echo "❌ High-risk vulnerabilities detected"
exit 1
# Fallback to cargo-deny advisories; nonzero exit indicates advisories present
cargo deny check advisories
fi

cargo-deny:
Expand Down Expand Up @@ -85,12 +100,19 @@ jobs:
path: ./
base: main
head: HEAD
extra_args: --debug --only-verified
# Treat documented example secrets as allowlisted patterns
extra_args: >-
--debug --only-verified
--exclude-path docs/** --exclude-path examples/**
--exclude-path README.md

vulnerability-scanning:
name: Container Vulnerability Scan
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Run on push to main, develop, and on PRs so it doesn't get skipped
if: >
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) ||
(github.event_name == 'pull_request')
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -235,7 +257,10 @@ jobs:
reproducible-builds:
name: Reproducible Build Verification
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Run on push to main, develop, and on PRs so it doesn't get skipped
if: >
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) ||
(github.event_name == 'pull_request')
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
Loading
Loading