| 1 | # CodeQL advanced setup. |
| 2 | # |
| 3 | # Scans the same languages the repository's default setup scanned (Actions, |
| 4 | # JavaScript/TypeScript, Python, Rust) with the same default query suite, but |
| 5 | # reads .github/codeql/codeql-config.yml so test paths stay out of alerts. |
| 6 | # |
| 7 | # Gated off by default. While the repository uses CodeQL "Default" setup, |
| 8 | # GitHub rejects SARIF uploads from this workflow ("Code Scanning could not |
| 9 | # process the submitted SARIF"), so the analyze job runs only when the |
| 10 | # repository variable CODEQL_ADVANCED_SETUP is 'true'. The founder flips it |
| 11 | # after switching the repository to "Advanced" setup (Settings -> Code |
| 12 | # security -> Code scanning); until then every run skips the job. |
| 13 | name: CodeQL |
| 14 | |
| 15 | on: |
| 16 | workflow_dispatch: |
| 17 | |
| 18 | permissions: {} |
| 19 | |
| 20 | concurrency: |
| 21 | group: codeql-${{ github.ref }} |
| 22 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 23 | |
| 24 | jobs: |
| 25 | analyze: |
| 26 | name: Analyze (${{ matrix.language }}) |
| 27 | if: vars.CODEQL_ADVANCED_SETUP == 'true' |
| 28 | runs-on: ubuntu-24.04 |
| 29 | timeout-minutes: 120 |
| 30 | permissions: |
| 31 | actions: read |
| 32 | contents: read |
| 33 | security-events: write |
| 34 | strategy: |
| 35 | fail-fast: false |
| 36 | matrix: |
| 37 | include: |
| 38 | - language: actions |
| 39 | build-mode: none |
| 40 | - language: javascript-typescript |
| 41 | build-mode: none |
| 42 | - language: python |
| 43 | build-mode: none |
| 44 | - language: rust |
| 45 | build-mode: none |
| 46 | steps: |
| 47 | - uses: actions/checkout@v7 |
| 48 | with: |
| 49 | persist-credentials: false |
| 50 | |
| 51 | - name: Initialize CodeQL |
| 52 | uses: github/codeql-action/init@v4 |
| 53 | with: |
| 54 | languages: ${{ matrix.language }} |
| 55 | build-mode: ${{ matrix.build-mode }} |
| 56 | config-file: ./.github/codeql/codeql-config.yml |
| 57 | |
| 58 | - name: Perform CodeQL analysis |
| 59 | uses: github/codeql-action/analyze@v4 |
| 60 | with: |
| 61 | category: /language:${{ matrix.language }} |
| 62 |