Skip to content

Commit ffae246

Browse files
committed
Customize CodeQL workflow
- Rename it "CodeQL" (instead of "CodeQL Advanced"). - Expand and adjust event triggers, similar to other workflows. - More query packs: `security-extended` and `security-and-quality`. - Set empty workflow permissions (overridden at the job level). - Remove unneeded job-level permissions. - Clearly comment the job-level permissions that are kept. - Use v6 of `actions/checkout` (rather than v4). - Don't persist credentials in the `actions/checkout` step. - Pin CodeQL-related actions (and checkout) with full SHA OIDs. - Adjust style to match other workflow (where no reason not to).
1 parent 4321338 commit ffae246

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

.github/workflows/codeql.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@
99
# the `language` matrix defined below to confirm you have the correct set of
1010
# supported CodeQL languages.
1111
#
12-
name: "CodeQL Advanced"
12+
name: CodeQL
1313

1414
on:
1515
push:
16-
branches: [ "main" ]
16+
branches:
17+
- main
18+
- "run-ci/**"
19+
- "**/run-ci/**"
1720
pull_request:
18-
branches: [ "main" ]
21+
branches:
22+
- main
1923
schedule:
20-
- cron: '28 17 * * 3'
24+
- cron: '28 17 * * 3'
25+
workflow_dispatch:
26+
27+
permissions: {} # Expanded in the `analyze` job.
2128

2229
jobs:
2330
analyze:
@@ -30,14 +37,14 @@ jobs:
3037
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
3138
permissions:
3239
# required for all workflows
33-
security-events: write
40+
security-events: write # For uploading SARIF to view in the Security tab.
3441

3542
# required to fetch internal or private CodeQL packs
36-
packages: read
43+
# packages: read
3744

3845
# only required for workflows in private repositories
39-
actions: read
40-
contents: read
46+
# actions: read
47+
# contents: read
4148

4249
strategy:
4350
fail-fast: false
@@ -57,7 +64,9 @@ jobs:
5764
# 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
5865
steps:
5966
- name: Checkout repository
60-
uses: actions/checkout@v4
67+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
68+
with:
69+
persist-credentials: false
6170

6271
# Add any setup steps before running the `github/codeql-action/init` action.
6372
# This includes steps like installing compilers or runtimes (`actions/setup-node`
@@ -67,7 +76,7 @@ jobs:
6776

6877
# Initializes the CodeQL tools for scanning.
6978
- name: Initialize CodeQL
70-
uses: github/codeql-action/init@v4
79+
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
7180
with:
7281
languages: ${{ matrix.language }}
7382
build-mode: ${{ matrix.build-mode }}
@@ -76,7 +85,7 @@ jobs:
7685
# Prefix the list here with "+" to use these queries and those in the config file.
7786

7887
# 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
79-
# queries: security-extended,security-and-quality
88+
queries: security-extended,security-and-quality
8089

8190
# If the analyze step fails for one of the languages you are analyzing with
8291
# "We were unable to automatically build your code", modify the matrix above
@@ -96,6 +105,6 @@ jobs:
96105
exit 1
97106
98107
- name: Perform CodeQL Analysis
99-
uses: github/codeql-action/analyze@v4
108+
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
100109
with:
101-
category: "/language:${{matrix.language}}"
110+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)