Skip to content

Commit d81861d

Browse files
authored
fix(repo): move codeql to yml based config s.t. it runs properly on forks (#32659)
## Current Behavior We are using the default codeql setup, which refuses to run on PRs from forks ## Expected Behavior We use the yml based codeql setup, which should run correctly > [!IMPORTANT] > This is only the first half of this effort. After this is merged, PRs will need to be rebased and the repo will need a settings update from @FrozenPandaz
1 parent 7534d1d commit d81861d

2 files changed

Lines changed: 205 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
schedule:
18+
- cron: '20 14 * * 6'
19+
20+
jobs:
21+
analyze:
22+
name: Analyze (${{ matrix.language }})
23+
# Runner size impacts CodeQL analysis time. To learn more, please see:
24+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
25+
# - https://gh.io/supported-runners-and-hardware-resources
26+
# - https://gh.io/using-larger-runners (GitHub.com only)
27+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
28+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
29+
permissions:
30+
# required for all workflows
31+
security-events: write
32+
33+
# required to fetch internal or private CodeQL packs
34+
packages: read
35+
36+
# only required for workflows in private repositories
37+
actions: read
38+
contents: read
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- language: actions
45+
build-mode: none
46+
47+
# We would like to test our Java / Kotlin... but its currently failing. We can follow up.
48+
# - language: java-kotlin
49+
# build-mode: autobuild
50+
- language: javascript-typescript
51+
build-mode: none
52+
- language: rust
53+
build-mode: none
54+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
55+
# Use `c-cpp` to analyze code written in C, C++ or both
56+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
57+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
58+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
59+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
60+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
61+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
65+
66+
# Add any setup steps before running the `github/codeql-action/init` action.
67+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
68+
# or others). This is typically only required for manual builds.
69+
# - name: Setup runtime (example)
70+
# uses: actions/setup-example@v1
71+
72+
# Initializes the CodeQL tools for scanning.
73+
- name: Initialize CodeQL
74+
uses: github/codeql-action/init@15403aac29bd91419968e066cded66bde56b0283 # v3
75+
with:
76+
languages: ${{ matrix.language }}
77+
build-mode: ${{ matrix.build-mode }}
78+
# If you wish to specify custom queries, you can do so here or in a config file.
79+
# By default, queries listed here will override any specified in a config file.
80+
# Prefix the list here with "+" to use these queries and those in the config file.
81+
82+
# 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
83+
# queries: security-extended,security-and-quality
84+
85+
# If the analyze step fails for one of the languages you are analyzing with
86+
# "We were unable to automatically build your code", modify the matrix above
87+
# to set the build mode to "manual" for that language. Then modify this step
88+
# to build your code.
89+
# ℹ️ Command-line programs to run using the OS shell.
90+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
91+
- if: matrix.build-mode == 'manual'
92+
shell: bash
93+
run: |
94+
echo 'If you are using a "manual" build mode for one or more of the' \
95+
'languages you are analyzing, replace this with the commands to build' \
96+
'your code, for example:'
97+
echo ' make bootstrap'
98+
echo ' make release'
99+
exit 1
100+
101+
- name: Perform CodeQL Analysis
102+
uses: github/codeql-action/analyze@15403aac29bd91419968e066cded66bde56b0283 # v3
103+
with:
104+
category: "/language:${{matrix.language}}"

.github/workflows/codeql-pr.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
pull_request:
16+
branches: [ "**" ]
17+
18+
jobs:
19+
analyze:
20+
name: Analyze (${{ matrix.language }})
21+
# Runner size impacts CodeQL analysis time. To learn more, please see:
22+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
23+
# - https://gh.io/supported-runners-and-hardware-resources
24+
# - https://gh.io/using-larger-runners (GitHub.com only)
25+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
26+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
27+
permissions:
28+
# required to fetch internal or private CodeQL packs
29+
packages: read
30+
31+
# only required for workflows in private repositories
32+
actions: read
33+
contents: read
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include:
39+
- language: actions
40+
build-mode: none
41+
42+
# See comment in @./codeql-master.yml about Java / Kotlin
43+
# - language: java-kotlin
44+
# build-mode: autobuild
45+
- language: javascript-typescript
46+
build-mode: none
47+
- language: rust
48+
build-mode: none
49+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
50+
# Use `c-cpp` to analyze code written in C, C++ or both
51+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
52+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
53+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
54+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
55+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
56+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
60+
61+
# Add any setup steps before running the `github/codeql-action/init` action.
62+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
63+
# or others). This is typically only required for manual builds.
64+
# - name: Setup runtime (example)
65+
# uses: actions/setup-example@v1
66+
67+
# Initializes the CodeQL tools for scanning.
68+
- name: Initialize CodeQL
69+
uses: github/codeql-action/init@15403aac29bd91419968e066cded66bde56b0283 # v3
70+
with:
71+
languages: ${{ matrix.language }}
72+
build-mode: ${{ matrix.build-mode }}
73+
# If you wish to specify custom queries, you can do so here or in a config file.
74+
# By default, queries listed here will override any specified in a config file.
75+
# Prefix the list here with "+" to use these queries and those in the config file.
76+
77+
# 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
78+
# queries: security-extended,security-and-quality
79+
80+
# If the analyze step fails for one of the languages you are analyzing with
81+
# "We were unable to automatically build your code", modify the matrix above
82+
# to set the build mode to "manual" for that language. Then modify this step
83+
# to build your code.
84+
# ℹ️ Command-line programs to run using the OS shell.
85+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
86+
- if: matrix.build-mode == 'manual'
87+
shell: bash
88+
run: |
89+
echo 'If you are using a "manual" build mode for one or more of the' \
90+
'languages you are analyzing, replace this with the commands to build' \
91+
'your code, for example:'
92+
echo ' make bootstrap'
93+
echo ' make release'
94+
exit 1
95+
96+
- name: Perform CodeQL Analysis
97+
uses: github/codeql-action/analyze@15403aac29bd91419968e066cded66bde56b0283 # v3
98+
with:
99+
category: "/language:${{matrix.language}}"
100+
upload: 'never'
101+
upload-database: false

0 commit comments

Comments
 (0)