Repository navigation
executable file
·120 lines (109 loc) · 5.2 KB
/
Copy pathcodeql.yml
File metadata and controls
executable file
·120 lines (109 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# 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 Advanced"
# Each language is analysed only when a file of it changed
# (scripts/ci-changes.sh, the one table from files to jobs): Rust for *.rs
# and the Cargo files, JavaScript for scripts and HTML, Actions for the
# workflows; all three for a change of this file or .github/codeql/. The
# weekly run analyses everything. A pull request that leaves a language out
# keeps that language's analysis from main.
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '34 0 * * 6'
workflow_dispatch:
# a newer push to a pull request replaces its running analysis; each commit on
# main keeps its own run – with one group for main, a third push cancelled the
# waiting analysis of the second, and its commit showed a red ✗ (#275)
concurrency:
group: codeql-${{ github.event_name }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# The languages whose files changed, as a JSON list for the matrix below.
changes:
name: changes
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read
outputs:
languages: ${{ steps.c.outputs.codeql }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Self-test of the change table
run: bash scripts/ci-changes.sh --self-test
- id: c
env:
CI_PUSH_BEFORE: ${{ github.event.before }}
CI_MERGE_BASE: ${{ github.event.merge_group.base_sha }}
run: bash scripts/ci-changes.sh
analyze:
name: Analyze (${{ matrix.language }})
needs: changes
if: needs.changes.outputs.languages != '[]'
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write
# required to fetch internal or private CodeQL packs
packages: read
# only required for workflows in private repositories
actions: read
contents: read
strategy:
fail-fast: false
matrix:
# actions, javascript-typescript, rust – each with build-mode none
language: ${{ fromJSON(needs.changes.outputs.languages) }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
# Add any setup steps before running the `github/codeql-action/init` action.
# This includes steps like installing compilers or runtimes (`actions/setup-node`
# or others). This is typically only required for manual builds.
# - name: Setup runtime (example)
# uses: actions/setup-example@v1
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: none
# leaves test-only code (tests/, src/**/tests.rs) out of the analysis;
# the reasons are in the file
config-file: ./.github/codeql/codeql-config.yml
# 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.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
env:
# Rust only: our model pack (.github/codeql/extensions/teamcraft-models,
# barriers for vault paths). Advanced setup does not pick it up by
# itself. The action runs `codeql database run-queries`, which on pull
# requests already gets --additional-packs for its diff-range pack, so
# that directory is listed here too (a later flag replaces an earlier).
CODEQL_ACTION_EXTRA_OPTIONS: ${{ matrix.language == 'rust' && format('{{"database":{{"run-queries":["--additional-packs={0}/.github/codeql/extensions{1}","--model-packs=rudalabs/teamcraft-rust-models"]}}}}', github.workspace, github.event_name == 'pull_request' && format(':{0}/pr-diff-range', runner.temp) || '') || '' }}
with:
category: "/language:${{matrix.language}}"