|
| 1 | +name: Security Scanners |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '12 15 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + pull_request: |
| 10 | + branches: [main] |
| 11 | + |
| 12 | +permissions: |
| 13 | + actions: none |
| 14 | + contents: none |
| 15 | + |
| 16 | +jobs: |
| 17 | + gitleaks: |
| 18 | + permissions: |
| 19 | + actions: read |
| 20 | + contents: read |
| 21 | + security-events: write |
| 22 | + runs-on: ubuntu-latest |
| 23 | + env: |
| 24 | + GITLEAKS_VERSION: "8.30.0" |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + - name: Install gitleaks |
| 30 | + run: | |
| 31 | + curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" | tar -xz; |
| 32 | + sudo mv gitleaks /usr/local/bin/; |
| 33 | + gitleaks --version; |
| 34 | + - name: Run gitleaks |
| 35 | + id: gitleaks |
| 36 | + run: | |
| 37 | + set +e |
| 38 | + gitleaks git --config=.gitleaks.toml --baseline-path=.gitleaks-baseline.json --report-path=gitleaks-report.sarif --report-format=sarif . |
| 39 | + GITLEAKS_EXIT=$? |
| 40 | + set -e |
| 41 | + echo "exit_code=$GITLEAKS_EXIT" >> "$GITHUB_OUTPUT" |
| 42 | + exit 0 |
| 43 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 44 | + if: always() |
| 45 | + with: |
| 46 | + name: gitleaks.sarif |
| 47 | + path: gitleaks-report.sarif |
| 48 | + if-no-files-found: error |
| 49 | + - uses: github/codeql-action/upload-sarif@5e7a52feb2a3dfb87f88be2af33b9e2275f48de6 # v4.32.2 |
| 50 | + continue-on-error: true |
| 51 | + with: |
| 52 | + sarif_file: gitleaks-report.sarif |
| 53 | + - if: steps.gitleaks.outputs.exit_code != '0' |
| 54 | + run: | |
| 55 | + echo "::error::gitleaks found secrets" |
| 56 | + exit ${{ steps.gitleaks.outputs.exit_code }} |
| 57 | +
|
| 58 | + bandit: |
| 59 | + permissions: |
| 60 | + actions: read |
| 61 | + contents: read |
| 62 | + security-events: write |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 66 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 67 | + with: |
| 68 | + python-version: '3.x' |
| 69 | + - name: Run bandit |
| 70 | + id: bandit |
| 71 | + run: | |
| 72 | + pip install "bandit[sarif]==1.9.3" |
| 73 | + set +e |
| 74 | + bandit -r . -f sarif -o bandit-report.sarif |
| 75 | + BANDIT_EXIT=$? |
| 76 | + set -e |
| 77 | + echo "exit_code=$BANDIT_EXIT" >> "$GITHUB_OUTPUT" |
| 78 | + exit 0 |
| 79 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 80 | + if: always() |
| 81 | + with: |
| 82 | + name: bandit.sarif |
| 83 | + path: bandit-report.sarif |
| 84 | + if-no-files-found: error |
| 85 | + - uses: github/codeql-action/upload-sarif@5e7a52feb2a3dfb87f88be2af33b9e2275f48de6 # v4.32.2 |
| 86 | + continue-on-error: true |
| 87 | + with: |
| 88 | + sarif_file: bandit-report.sarif |
| 89 | + - if: steps.bandit.outputs.exit_code != '0' |
| 90 | + run: | |
| 91 | + echo "::error::bandit found security issues" |
| 92 | + exit ${{ steps.bandit.outputs.exit_code }} |
| 93 | +
|
| 94 | + semgrep: |
| 95 | + permissions: |
| 96 | + actions: read |
| 97 | + contents: read |
| 98 | + security-events: write |
| 99 | + runs-on: ubuntu-latest |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 102 | + with: |
| 103 | + fetch-depth: 0 |
| 104 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 105 | + with: |
| 106 | + python-version: '3.x' |
| 107 | + - name: Run semgrep |
| 108 | + id: semgrep |
| 109 | + env: |
| 110 | + BASELINE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }} |
| 111 | + run: | |
| 112 | + pip install "semgrep==1.151.0" |
| 113 | + BASELINE_ARGS="" |
| 114 | + if [ -n "$BASELINE_SHA" ]; then |
| 115 | + BASELINE_ARGS="--baseline-commit $BASELINE_SHA" |
| 116 | + fi |
| 117 | + set +e |
| 118 | + semgrep scan --oss-only --metrics=off --config=r/all \ |
| 119 | + --exclude-rule="ai.generic.detect-generic-ai-anthprop.detect-generic-ai-anthprop" \ |
| 120 | + --exclude-rule="ai.generic.detect-generic-ai-oai.detect-generic-ai-oai" \ |
| 121 | + --sarif-output semgrep-report.sarif $BASELINE_ARGS |
| 122 | + SEMGREP_EXIT=$? |
| 123 | + set -e |
| 124 | + echo "exit_code=$SEMGREP_EXIT" >> "$GITHUB_OUTPUT" |
| 125 | + exit 0 |
| 126 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 127 | + if: always() |
| 128 | + with: |
| 129 | + name: semgrep.sarif |
| 130 | + path: semgrep-report.sarif |
| 131 | + if-no-files-found: error |
| 132 | + - uses: github/codeql-action/upload-sarif@5e7a52feb2a3dfb87f88be2af33b9e2275f48de6 # v4.32.2 |
| 133 | + continue-on-error: true |
| 134 | + with: |
| 135 | + sarif_file: semgrep-report.sarif |
| 136 | + - if: steps.semgrep.outputs.exit_code != '0' |
| 137 | + run: | |
| 138 | + echo "::error::semgrep found security issues" |
| 139 | + exit ${{ steps.semgrep.outputs.exit_code }} |
| 140 | +
|
| 141 | + checkov: |
| 142 | + permissions: |
| 143 | + actions: read |
| 144 | + contents: read |
| 145 | + security-events: write |
| 146 | + runs-on: ubuntu-latest |
| 147 | + steps: |
| 148 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 149 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 150 | + with: |
| 151 | + python-version: '3.x' |
| 152 | + - name: Run checkov |
| 153 | + id: checkov |
| 154 | + run: | |
| 155 | + pip install "checkov==3.2.500" |
| 156 | + set +e |
| 157 | + checkov -d . --output sarif --output-file-path . |
| 158 | + CHECKOV_EXIT=$? |
| 159 | + mv results_sarif.sarif checkov-report.sarif || true |
| 160 | + set -e |
| 161 | + echo "exit_code=$CHECKOV_EXIT" >> "$GITHUB_OUTPUT" |
| 162 | + exit 0 |
| 163 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 164 | + if: always() |
| 165 | + with: |
| 166 | + name: checkov.sarif |
| 167 | + path: checkov-report.sarif |
| 168 | + if-no-files-found: error |
| 169 | + - uses: github/codeql-action/upload-sarif@5e7a52feb2a3dfb87f88be2af33b9e2275f48de6 # v4.32.2 |
| 170 | + continue-on-error: true |
| 171 | + with: |
| 172 | + sarif_file: checkov-report.sarif |
| 173 | + - if: steps.checkov.outputs.exit_code != '0' |
| 174 | + run: | |
| 175 | + echo "::error::checkov found IaC issues" |
| 176 | + exit ${{ steps.checkov.outputs.exit_code }} |
0 commit comments