Skip to content

Commit 04e14ea

Browse files
inimazbenoit-cty
andauthored
chore (security): Setup code scanning alerts (#859)
* chore (security): Setup code scanning alerts This is to set up the feature of code scanning. It helps to automatically detect common vulnerability and coding errors. The job will be run every Saturday at 17:36. We can change this in the future. * Apply suggestions from code review Co-authored-by: Benoît Courty <6603048+benoit-cty@users.noreply.github.com> --------- Co-authored-by: Benoît Courty <6603048+benoit-cty@users.noreply.github.com>
1 parent 865809a commit 04e14ea

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/codeql.yml

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

0 commit comments

Comments
 (0)