diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4af39887..3d488ddb 100755 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,11 +4,6 @@ # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# name: "CodeQL" on: @@ -20,24 +15,41 @@ on: schedule: - cron: '34 0 * * 5' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: analyze: - name: Analyze + name: Analyze (${{ matrix.language }}, ${{ matrix.shard }}) runs-on: group: Large labels: [ubuntu-latest-x64-16core] strategy: fail-fast: false + # C# is split by sample folder so dependency restore and extraction run in parallel. + # Each shard uploads results under its own category. matrix: - language: [ 'csharp', 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + include: + - language: csharp + shard: IdentityServer/v7 + - language: csharp + shard: IdentityServer/v8 + - language: csharp + shard: BFF + - language: csharp + shard: various + - language: javascript + shard: all steps: + # C# buildless extraction scans the whole checkout regardless of source-root, so C# shards + # sparse-checkout only their folder (cone mode keeps root files such as global.json and nuget.config). - name: Checkout repository uses: actions/checkout@v4 + with: + sparse-checkout: ${{ matrix.shard != 'all' && matrix.shard || '' }} # Analysis runs without compiling the samples; compilation is verified by the Build workflow. - name: Initialize CodeQL @@ -45,6 +57,7 @@ jobs: with: languages: ${{ matrix.language }} build-mode: none + source-root: ${{ matrix.shard == 'all' && '.' || matrix.shard }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. @@ -52,3 +65,6 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 + with: + # JavaScript keeps its pre-sharding default category so existing alerts continue to update. + category: ${{ matrix.language == 'javascript' && '.github/workflows/codeql-analysis.yml:analyze/language:javascript/' || format('/language:{0}/{1}', matrix.language, matrix.shard) }}