diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..9956dec --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,42 @@ +name: "CodeQL Security Analysis" + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + # Run weekly on Monday at 6 AM UTC + - cron: '0 6 * * 1' + +jobs: + analyze: + name: Analyze Code + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ['javascript'] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + queries: security-extended # More thorough than default + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml new file mode 100644 index 0000000..aed1663 --- /dev/null +++ b/.github/workflows/gitleaks.yml @@ -0,0 +1,30 @@ +name: Secret Scanning (Gitleaks) + +on: + push: + branches: ['**'] + pull_request: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +jobs: + scan: + name: Scan for secrets + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full history for accurate scanning + + - name: Install Gitleaks + run: | + curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz | tar -xz + sudo mv gitleaks /usr/local/bin/ + + - name: Run Gitleaks + run: gitleaks detect --source . --config .gitleaks.toml --verbose diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 0000000..f9f6b86 --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,42 @@ +name: Semgrep SAST + +on: + push: + branches: ['**'] + pull_request: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + security-events: write + +jobs: + semgrep: + name: Semgrep security scan + runs-on: ubuntu-latest + + container: + image: semgrep/semgrep:1.79 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run Semgrep + run: | + semgrep scan \ + --config p/security-audit \ + --config p/secrets \ + --config p/owasp-top-ten \ + --config p/javascript \ + --config p/typescript \ + --sarif \ + --output=semgrep.sarif \ + --metrics=off + + - name: Upload SARIF to GitHub Security + uses: github/codeql-action/upload-sarif@v3 + if: always() + with: + sarif_file: semgrep.sarif diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml new file mode 100644 index 0000000..1956d5b --- /dev/null +++ b/.github/workflows/trivy.yml @@ -0,0 +1,49 @@ +name: Trivy Security Scan + +on: + push: + branches: ['**'] + pull_request: + branches: [main] + schedule: + - cron: '0 3 * * *' # Daily at 3 AM UTC + workflow_dispatch: + +permissions: + contents: read + security-events: write + +jobs: + scan: + name: Trivy vulnerability scan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run Trivy vulnerability scanner (filesystem) + uses: aquasecurity/trivy-action@0.34.0 + with: + scan-type: 'fs' + scan-ref: '.' + format: 'sarif' + output: 'trivy-results.sarif' + severity: 'CRITICAL,HIGH,MEDIUM' + ignore-unfixed: false + + - name: Upload Trivy results to GitHub Security + uses: github/codeql-action/upload-sarif@v3 + if: always() + with: + sarif_file: 'trivy-results.sarif' + + - name: Run Trivy for npm dependencies + uses: aquasecurity/trivy-action@0.34.0 + with: + scan-type: 'fs' + scan-ref: '.' + scanners: 'vuln' + format: 'table' + exit-code: 0 + severity: 'CRITICAL,HIGH'