chore: transfer rules and workflows from action-genai #19
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 Scan | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| security-events: write | |
| actions: read | |
| jobs: | |
| npm-audit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - run: npm ci | |
| - run: npm audit --audit-level=high | |
| continue-on-error: true | |
| - name: Upload audit report | |
| if: always() | |
| run: npm audit --json > npm-audit-report.json || true | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: npm-audit-report | |
| path: npm-audit-report.json | |
| python-safety: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - run: pip install safety | |
| - run: safety scan --output json > safety-report.json || true | |
| continue-on-error: true | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: safety-report | |
| path: safety-report.json | |
| bandit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - run: pip install bandit | |
| - run: bandit -r src -f json -o bandit-report.json || true | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: bandit-report | |
| path: bandit-report.json | |
| trivy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache Trivy DB | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/trivy | |
| key: trivy-db-${{ github.run_id }} | |
| restore-keys: | | |
| trivy-db- | |
| continue-on-error: true | |
| - name: Build image for scanning | |
| run: docker build -t eventrelay:test -f Dockerfile.production . | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: 'eventrelay:test' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| exit-code: '0' | |
| ignore-unfixed: true | |
| vuln-type: 'os,library' | |
| severity: 'CRITICAL,HIGH' | |
| trivyignores: '.trivyignore' | |
| - name: Upload Trivy results to GitHub Security tab | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| - name: Generate human-readable report | |
| uses: aquasecurity/trivy-action@master | |
| if: always() | |
| with: | |
| image-ref: 'eventrelay:test' | |
| format: 'table' | |
| exit-code: '0' | |
| ignore-unfixed: true | |
| vuln-type: 'os,library' | |
| severity: 'CRITICAL,HIGH' | |
| trivyignores: '.trivyignore' |