|
| 1 | +name: Security Baseline |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + schedule: |
| 9 | + - cron: "37 3 * * 1" |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + actions: read |
| 14 | + contents: read |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: security-baseline-${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + osv: |
| 22 | + name: OSV vulnerability scan |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 29 | + with: |
| 30 | + persist-credentials: false |
| 31 | + |
| 32 | + - name: Run OSV-Scanner |
| 33 | + uses: google/osv-scanner-action/osv-scanner-action@9a498708959aeaef5ef730655706c5a1df1edbc2 # v2.3.8 |
| 34 | + with: |
| 35 | + scan-args: |- |
| 36 | + --recursive |
| 37 | + ./ |
| 38 | +
|
| 39 | + secrets: |
| 40 | + name: Secret scan |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + persist-credentials: false |
| 48 | + |
| 49 | + - name: Run TruffleHog |
| 50 | + uses: trufflesecurity/trufflehog@37b77001d0174ebec2fcca2bd83ff83a6d45a3ab # v3.95.3 |
| 51 | + with: |
| 52 | + extra_args: --results=verified,unknown |
| 53 | + path: ./ |
| 54 | + version: 3.95.3 |
| 55 | + |
| 56 | + workflow-lint: |
| 57 | + name: GitHub Actions lint |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 62 | + with: |
| 63 | + persist-credentials: false |
| 64 | + |
| 65 | + - name: Set up Go |
| 66 | + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
| 67 | + with: |
| 68 | + cache: false |
| 69 | + go-version: stable |
| 70 | + |
| 71 | + - name: Run actionlint |
| 72 | + run: | |
| 73 | + if [ -d .github/workflows ]; then |
| 74 | + go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 \ |
| 75 | + -ignore 'unknown permission scope "vulnerability-alerts"' |
| 76 | + fi |
| 77 | +
|
| 78 | + workflow-security: |
| 79 | + name: GitHub Actions security lint |
| 80 | + runs-on: ubuntu-latest |
| 81 | + permissions: |
| 82 | + actions: read |
| 83 | + contents: read |
| 84 | + steps: |
| 85 | + - name: Checkout repository |
| 86 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 87 | + with: |
| 88 | + persist-credentials: false |
| 89 | + |
| 90 | + - name: Set up uv |
| 91 | + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 |
| 92 | + with: |
| 93 | + enable-cache: false |
| 94 | + |
| 95 | + - name: Run zizmor |
| 96 | + run: | |
| 97 | + for attempt in 1 2 3; do |
| 98 | + set +e |
| 99 | + uvx --from zizmor==1.24.1 zizmor \ |
| 100 | + --persona=auditor \ |
| 101 | + --format=github \ |
| 102 | + --min-severity=high \ |
| 103 | + --min-confidence=medium \ |
| 104 | + --color=always \ |
| 105 | + -- ./ |
| 106 | + status="$?" |
| 107 | + set -e |
| 108 | +
|
| 109 | + if [ "$status" -eq 0 ]; then |
| 110 | + exit 0 |
| 111 | + fi |
| 112 | +
|
| 113 | + if [ "$status" -eq 3 ]; then |
| 114 | + echo "::warning::No inputs were collected by zizmor" |
| 115 | + exit 0 |
| 116 | + fi |
| 117 | +
|
| 118 | + if [ "$status" -ge 11 ]; then |
| 119 | + exit "$status" |
| 120 | + fi |
| 121 | +
|
| 122 | + if [ "$attempt" -lt 3 ]; then |
| 123 | + sleep "$((attempt * 15))" |
| 124 | + continue |
| 125 | + fi |
| 126 | +
|
| 127 | + exit "$status" |
| 128 | + done |
| 129 | + env: |
| 130 | + GH_TOKEN: ${{ github.token }} |
0 commit comments