Skip to content

security

security #532

Workflow file for this run

name: security
on:
push:
workflow_dispatch:
schedule:
- cron: "0 4 * * *" # run once a day at 4 AM
jobs:
trivy-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Run Trivy dependency scan
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
with:
scan-type: fs
format: table
exit-code: "1"
vuln-type: "os,library"
gitleaks:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cargo-audit:
name: cargo-audit
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Rust
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable
- name: Restore cache
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-audit-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ github.run_id }}
restore-keys: |
cargo-audit-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
cargo-audit-${{ runner.os }}-
- name: Install cargo-audit
run: |
# Get currently installed version (if any)
if command -v cargo-audit >/dev/null 2>&1; then
CURRENT_VERSION=$(cargo audit --version | awk '{print $2}')
else
CURRENT_VERSION=""
fi
# Get latest version from crates.io
LATEST_VERSION=$(cargo search cargo-audit --limit 1 | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
echo "Current cargo-audit version: ${CURRENT_VERSION:-none}"
echo "Latest cargo-audit version : $LATEST_VERSION"
# Install if not installed or if outdated
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "Installing latest cargo-audit ($LATEST_VERSION)"
cargo install cargo-audit --force
else
echo "cargo-audit is up to date"
fi
- name: Run cargo audit
run: |
cargo audit
- name: Save cache
uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
if: always()
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-audit-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ github.run_id }}