Skip to content

Commit 227de67

Browse files
committed
adjust codeql frequency, restrict permissions, use commit hashes in actions
1 parent 5358172 commit 227de67

File tree

1 file changed

+60
-52
lines changed

1 file changed

+60
-52
lines changed

.github/workflows/codeql.yml

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ name: "CodeQL Advanced"
1313

1414
on:
1515
push:
16-
branches: [ "main" ]
16+
branches:
17+
- "main"
1718
pull_request:
18-
branches: [ "main" ]
19+
branches:
20+
- "main"
1921
schedule:
20-
- cron: '40 8 * * 2'
22+
- cron: '0 0 9 1 * *' # At 09:00 AM, on day 1 of the month
2123

2224
jobs:
2325
analyze:
@@ -31,10 +33,8 @@ jobs:
3133
permissions:
3234
# required for all workflows
3335
security-events: write
34-
3536
# required to fetch internal or private CodeQL packs
3637
packages: read
37-
3838
# only required for workflows in private repositories
3939
actions: read
4040
contents: read
@@ -43,56 +43,64 @@ jobs:
4343
fail-fast: false
4444
matrix:
4545
include:
46-
- language: c-cpp
47-
build-mode: autobuild
48-
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
49-
# Use `c-cpp` to analyze code written in C, C++ or both
50-
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
51-
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
52-
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
53-
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
54-
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
55-
# 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
46+
- language: c-cpp
47+
build-mode: autobuild
48+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
49+
# Use `c-cpp` to analyze code written in C, C++ or both
50+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
51+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
52+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
53+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
54+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
55+
# 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
5656
steps:
57-
- name: Checkout repository
58-
uses: actions/checkout@v4
57+
- name: Harden Runner
58+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
59+
with:
60+
disable-sudo: true
61+
egress-policy: audit
62+
63+
- name: Checkout repository
64+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
65+
with:
66+
persist-credentials: false
5967

60-
# Add any setup steps before running the `github/codeql-action/init` action.
61-
# This includes steps like installing compilers or runtimes (`actions/setup-node`
62-
# or others). This is typically only required for manual builds.
63-
# - name: Setup runtime (example)
64-
# uses: actions/setup-example@v1
68+
# Add any setup steps before running the `github/codeql-action/init` action.
69+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
70+
# or others). This is typically only required for manual builds.
71+
# - name: Setup runtime (example)
72+
# uses: actions/setup-example@v1
6573

66-
# Initializes the CodeQL tools for scanning.
67-
- name: Initialize CodeQL
68-
uses: github/codeql-action/init@v3
69-
with:
70-
languages: ${{ matrix.language }}
71-
build-mode: ${{ matrix.build-mode }}
72-
# If you wish to specify custom queries, you can do so here or in a config file.
73-
# By default, queries listed here will override any specified in a config file.
74-
# Prefix the list here with "+" to use these queries and those in the config file.
74+
# Initializes the CodeQL tools for scanning.
75+
- name: Initialize CodeQL
76+
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
77+
with:
78+
languages: ${{ matrix.language }}
79+
build-mode: ${{ matrix.build-mode }}
80+
# If you wish to specify custom queries, you can do so here or in a config file.
81+
# By default, queries listed here will override any specified in a config file.
82+
# Prefix the list here with "+" to use these queries and those in the config file.
7583

76-
# 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
77-
# queries: security-extended,security-and-quality
84+
# 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
85+
# queries: security-extended,security-and-quality
7886

79-
# If the analyze step fails for one of the languages you are analyzing with
80-
# "We were unable to automatically build your code", modify the matrix above
81-
# to set the build mode to "manual" for that language. Then modify this step
82-
# to build your code.
83-
# ℹ️ Command-line programs to run using the OS shell.
84-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
85-
- if: matrix.build-mode == 'manual'
86-
shell: bash
87-
run: |
88-
echo 'If you are using a "manual" build mode for one or more of the' \
89-
'languages you are analyzing, replace this with the commands to build' \
90-
'your code, for example:'
91-
echo ' make bootstrap'
92-
echo ' make release'
93-
exit 1
87+
# If the analyze step fails for one of the languages you are analyzing with
88+
# "We were unable to automatically build your code", modify the matrix above
89+
# to set the build mode to "manual" for that language. Then modify this step
90+
# to build your code.
91+
# ℹ️ Command-line programs to run using the OS shell.
92+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
93+
- if: matrix.build-mode == 'manual'
94+
shell: bash
95+
run: |
96+
echo 'If you are using a "manual" build mode for one or more of the' \
97+
'languages you are analyzing, replace this with the commands to build' \
98+
'your code, for example:'
99+
echo ' make bootstrap'
100+
echo ' make release'
101+
exit 1
94102
95-
- name: Perform CodeQL Analysis
96-
uses: github/codeql-action/analyze@v3
97-
with:
98-
category: "/language:${{matrix.language}}"
103+
- name: Perform CodeQL Analysis
104+
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
105+
with:
106+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)