NPM Audit Signatures #126
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: NPM Audit Signatures | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 6 AM UTC | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - 'package*.json' | |
| pull_request: | |
| branches: [ "main" ] | |
| paths: | |
| - 'package*.json' | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| audit-signatures: | |
| name: Audit Package Signatures | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run npm audit | |
| run: npm audit --audit-level=moderate | |
| - name: Verify package signatures | |
| run: npm audit signatures | |
| - name: Check for vulnerabilities | |
| run: | | |
| AUDIT_RESULT=$(npm audit --json) | |
| VULN_COUNT=$(echo "$AUDIT_RESULT" | jq '.vulnerabilities | length') | |
| if [ "$VULN_COUNT" -gt 0 ]; then | |
| echo "::error::Security vulnerabilities found in dependencies ($VULN_COUNT vulnerabilities)" | |
| exit 1 | |
| else | |
| echo "No security vulnerabilities found" | |
| fi |