Skip to content

Security Audit

Security Audit #571

name: Security Audit
on:
schedule:
# Run weekly on Monday at 00:00 UTC
- cron: '0 0 * * 1'
workflow_dispatch:
push:
paths:
- 'package.json'
- 'pnpm-lock.yaml'
- '**/package.json'
jobs:
audit:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: |
~/.pnpm-store
~/.local/share/pnpm/store
~/.cache/pnpm
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
timeout-minutes: 10
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
- name: Run pnpm audit
run: pnpm audit --audit-level=moderate
- name: Check Snyk configuration
id: snyk
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: |
if [ -n "$SNYK_TOKEN" ]; then
echo "configured=true" >> "$GITHUB_OUTPUT"
else
echo "configured=false" >> "$GITHUB_OUTPUT"
fi
- name: Run Snyk Security Scan
if: ${{ steps.snyk.outputs.configured == 'true' }}
run: pnpm dlx snyk@latest test --all-projects --severity-threshold=medium
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- name: Report missing Snyk configuration
if: ${{ steps.snyk.outputs.configured == 'false' }}
run: echo "Snyk scan skipped because SNYK_TOKEN is not configured." >> "$GITHUB_STEP_SUMMARY"
- name: Generate Security Report
if: always()
run: |
echo "## Security Audit Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Run completed at: $(date)" >> $GITHUB_STEP_SUMMARY