Skip to content

Commit f3a50fb

Browse files
Merge pull request #535 from microsoft/psl-codequality
chore: add CodeQL Advanced security scanning workflow
2 parents 201acae + f6581ae commit f3a50fb

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

.github/workflows/codeql.yml

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

0 commit comments

Comments
 (0)