Security Audit #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Security Audit | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| schedule: | |
| # Run weekly security audit | |
| - cron: "0 2 * * 1" # Every Monday at 2 AM UTC | |
| jobs: | |
| security-audit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm run ci-install | |
| - name: Run security audit | |
| run: npm run security-audit | |
| - name: Run npm audit | |
| run: npm audit --audit-level=moderate | |
| - name: Check for vulnerabilities | |
| run: | | |
| if [ $? -ne 0 ]; then | |
| echo "Security vulnerabilities found!" | |
| npm audit --audit-level=moderate --json > audit-results.json | |
| exit 1 | |
| fi | |
| - name: Upload audit results | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: security-audit-results | |
| path: audit-results.json | |
| dependency-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm run ci-install | |
| - name: Check for outdated dependencies | |
| run: | | |
| npm outdated --json > outdated.json || true | |
| if [ -s outdated.json ]; then | |
| echo "Outdated dependencies found:" | |
| cat outdated.json | |
| else | |
| echo "All dependencies are up to date" | |
| fi | |
| - name: Check lockfile integrity | |
| run: | | |
| if [ -f package-lock.json ]; then | |
| npm ci --dry-run | |
| else | |
| echo "Missing package-lock.json" | |
| exit 1 | |
| fi |