Run CodeQL code scan #63
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2025 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Zero-configuration modular workflow to run CodeQL code scans. | |
# | |
# CodeQL is a semantic code analysis tool that finds vulnerabilities by | |
# understanding the code's logic. It is provided by GitHub. CodeQL's findings | |
# are reported in the repo's code-scanning results page, | |
# https://github.com/quantumlib/REPO/security/code-scanning/. | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
name: CodeQL code scan | |
run-name: Run CodeQL code scan ${{inputs.reason}} | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- main | |
- master | |
# Support merge queues. | |
merge_group: | |
types: | |
- checks_requested | |
# Allow manual invocation. | |
workflow_dispatch: | |
# Allow calling from nightly.yaml. | |
workflow_call: | |
inputs: | |
reason: | |
type: string | |
# Declare default permissions as read only. | |
permissions: read-all | |
jobs: | |
create-matrix: | |
name: Determine languages used | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 5 | |
outputs: | |
language-matrix: ${{steps.matrix.outputs.languages}} | |
steps: | |
- name: Get list of programming languages used in this repo | |
id: matrix | |
uses: advanced-security/set-codeql-language-matrix@975244ea2e4c0668b8d289ac2b61fa7f0976f328 | |
with: | |
access-token: ${{secrets.GITHUB_TOKEN}} | |
endpoint: ${{github.event.repository.languages_url}} | |
codeql: | |
if: ${{needs.create-matrix.outputs.language-matrix != '[]'}} | |
name: Run CodeQL scanner for ${{matrix.language}} | |
needs: create-matrix | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 10 | |
permissions: | |
actions: read | |
contents: read | |
packages: read | |
security-events: write | |
strategy: | |
fail-fast: false | |
matrix: | |
language: ${{fromJSON(needs.create-matrix.outputs.language-matrix)}} | |
steps: | |
- name: Check out a copy of the git repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Initialize CodeQL scanning tool | |
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3 | |
with: | |
languages: ${{matrix.language}} | |
queries: security-and-quality | |
config: | | |
paths-ignore: | |
- '**/*.gltf' | |
- '**/*.json' | |
- '**/*.md' | |
- '**/*.png' | |
- '**/*.rst' | |
- '**/*.svg' | |
- '**/*.stim' | |
- '**/*.txt' | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3 | |
with: | |
category: "/language:${{matrix.language}}" |