|
| 1 | +name: Security Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + schedule: |
| 9 | + - cron: '30 2 * * 1' # Weekly scan on Monday at 02:30 |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + security-events: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + # 1. SAST - Semgrep |
| 17 | + semgrep-sast: |
| 18 | + name: Semgrep SAST |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: (github.actor != 'dependabot[bot]') |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - name: Setup Python |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: '3.11' |
| 27 | + - name: Install Semgrep |
| 28 | + run: python3 -m pip install semgrep |
| 29 | + - name: Semgrep Scan |
| 30 | + run: | |
| 31 | + semgrep scan --sarif --output=semgrep.sarif --config p/security-audit --config p/secrets --config p/typescript --config p/rust --config .semgrep.yml || true |
| 32 | + - name: Upload SARIF file |
| 33 | + uses: github/codeql-action/upload-sarif@v3 |
| 34 | + with: |
| 35 | + sarif_file: semgrep.sarif |
| 36 | + if: always() |
| 37 | + |
| 38 | + # 2. Dependency Audit & Vulnerability Scanning |
| 39 | + dependency-scan: |
| 40 | + name: Vulnerability Scan (NPM & Trivy) |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Setup Node.js |
| 46 | + uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: '20' |
| 49 | + cache: 'npm' |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: npm ci |
| 53 | + |
| 54 | + - name: NPM Audit |
| 55 | + run: npm audit --audit-level=high |
| 56 | + continue-on-error: true |
| 57 | + |
| 58 | + - name: Trivy FS Scan (Filesystem) |
| 59 | + uses: aquasecurity/trivy-action@master |
| 60 | + with: |
| 61 | + scan-type: 'fs' |
| 62 | + ignore-unfixed: true |
| 63 | + format: 'table' |
| 64 | + severity: 'CRITICAL,HIGH' |
| 65 | + exit-code: '1' # Fail on high/critical vulnerabilities |
| 66 | + |
| 67 | + # 3. Rust Security Audit |
| 68 | + rust-audit: |
| 69 | + name: Rust Audit |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + - name: Install cargo-audit |
| 74 | + run: cargo install cargo-audit |
| 75 | + - name: Run Audit |
| 76 | + run: | |
| 77 | + cd native |
| 78 | + cargo audit |
| 79 | +
|
| 80 | + # 4. Secret Scanning (Gitleaks) |
| 81 | + gitleaks: |
| 82 | + name: Secret Scanning |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + with: |
| 87 | + fetch-depth: 0 |
| 88 | + - name: Gitleaks Scan |
| 89 | + uses: gitleaks/gitleaks-action@v2 |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + |
| 93 | + # 5. DAST Baseline Scan (OWASP ZAP) |
| 94 | + dast-scan: |
| 95 | + name: OWASP ZAP DAST Scan |
| 96 | + runs-on: ubuntu-latest |
| 97 | + needs: [dependency-scan] |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - name: Setup Node |
| 102 | + uses: actions/setup-node@v4 |
| 103 | + with: |
| 104 | + node-version: '20' |
| 105 | + |
| 106 | + - name: Install & Build Renderer |
| 107 | + run: | |
| 108 | + npm ci |
| 109 | + npm run build:renderer |
| 110 | + # Start a local server to serve the built renderer for DAST |
| 111 | + npx http-server dist/renderer -p 8080 & |
| 112 | + sleep 10 # Wait for server to start |
| 113 | + |
| 114 | + - name: ZAP Baseline Scan |
| 115 | + uses: zaproxy/action-baseline@v0.12.0 |
| 116 | + with: |
| 117 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + docker_name: 'ghcr.io/zaproxy/zaproxy:stable' |
| 119 | + target: 'http://localhost:8080' |
| 120 | + fail_action: false |
0 commit comments