|
| 1 | +name: CodeQL |
| 2 | + |
| 3 | +# Advanced setup, replacing the repo-settings "default setup". |
| 4 | +# |
| 5 | +# Default setup pinned every scan to a 4-vCPU GitHub-hosted runner with no |
| 6 | +# cancel-in-progress, which put PR scans at 30-125 min and re-ran them on every |
| 7 | +# push (PR #6183 burned six overlapping runs). None of that is configurable from |
| 8 | +# the settings UI, so the config moves into the repo. |
| 9 | +# |
| 10 | +# Before enabling this, disable default setup or the two will both run: |
| 11 | +# gh api -X PATCH repos/:owner/:repo/code-scanning/default-setup -f state=not-configured |
| 12 | +# |
| 13 | +# The runs-on expression is the same CI_PROVIDER escape hatch as ci.yml and must |
| 14 | +# change together with it. |
| 15 | + |
| 16 | +on: |
| 17 | + # Pushes to main are infrequent (merges only), so a full scan per push is |
| 18 | + # affordable and is what GitHub recommends pairing with the PR trigger: |
| 19 | + # "Scanning code when someone pushes a change, and whenever a pull request is |
| 20 | + # created, prevents developers from introducing new vulnerabilities." |
| 21 | + push: |
| 22 | + branches: [main] |
| 23 | + pull_request: |
| 24 | + branches: [main, staging] |
| 25 | + # Draft PRs are excluded via the job-level `if`, not here: `types` would |
| 26 | + # also have to re-list the default event types to keep synchronize working. |
| 27 | + paths: |
| 28 | + - '**/*.ts' |
| 29 | + - '**/*.tsx' |
| 30 | + - '**/*.js' |
| 31 | + - '**/*.jsx' |
| 32 | + - '**/*.mjs' |
| 33 | + - '**/*.cjs' |
| 34 | + - '.github/workflows/**' |
| 35 | + - '.github/actions/**' |
| 36 | + - '.github/codeql/**' |
| 37 | + schedule: |
| 38 | + # Safety net behind the push trigger, and the thing that keeps the |
| 39 | + # default-branch alert view fresh when main is quiet. Only fires once this |
| 40 | + # file is on the default branch — schedule events ignore other branches. |
| 41 | + - cron: '17 8 * * *' |
| 42 | + workflow_dispatch: |
| 43 | + |
| 44 | +# Scheduled main scans must run to completion — only PR pushes supersede. |
| 45 | +concurrency: |
| 46 | + group: codeql-${{ github.ref }} |
| 47 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 48 | + |
| 49 | +permissions: |
| 50 | + contents: read |
| 51 | + |
| 52 | +jobs: |
| 53 | + analyze: |
| 54 | + name: Analyze ${{ matrix.language }} |
| 55 | + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-latest' }} |
| 56 | + timeout-minutes: 60 |
| 57 | + if: github.event.pull_request.draft != true |
| 58 | + permissions: |
| 59 | + security-events: write |
| 60 | + contents: read |
| 61 | + actions: read |
| 62 | + |
| 63 | + strategy: |
| 64 | + fail-fast: false |
| 65 | + matrix: |
| 66 | + # One entry covers both JS and TS — `javascript`, `typescript` and |
| 67 | + # `javascript-typescript` all resolve to the same extractor |
| 68 | + # (github/codeql-action src/languages/builtin.json), so the three |
| 69 | + # entries default setup listed were one analysis, not three. |
| 70 | + # `javascript-typescript` is the documented spelling. Python dropped: |
| 71 | + # 7 files in the tree. |
| 72 | + language: [javascript-typescript, actions] |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Checkout repository |
| 76 | + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 |
| 77 | + with: |
| 78 | + persist-credentials: false |
| 79 | + |
| 80 | + - name: Initialize CodeQL |
| 81 | + uses: github/codeql-action/init@18420e3271f74589575af831a523c833acda327f # codeql-bundle-v2.26.2 |
| 82 | + with: |
| 83 | + languages: ${{ matrix.language }} |
| 84 | + config-file: ./.github/codeql/codeql-config.yml |
| 85 | + |
| 86 | + - name: Perform CodeQL Analysis |
| 87 | + uses: github/codeql-action/analyze@18420e3271f74589575af831a523c833acda327f # codeql-bundle-v2.26.2 |
| 88 | + env: |
| 89 | + NODE_OPTIONS: --max-old-space-size=8192 |
| 90 | + with: |
| 91 | + category: /language:${{ matrix.language }} |
0 commit comments