Skip to content

Commit 56b3db5

Browse files
authored
CodeQL CI
1 parent 4ba0ee4 commit 56b3db5

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

.github/workflows/codeql.yml

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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: [ "main, master" ]
17+
schedule:
18+
- cron: '0 0 * * *'
19+
pull_request:
20+
branches: '*'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners
29+
# Consider using larger runners for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-20.04' }}
31+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
32+
permissions:
33+
actions: read
34+
contents: read
35+
security-events: write
36+
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
language: [ 'cpp' ]
41+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
42+
# Use only 'java' to analyze code written in Java, Kotlin or both
43+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
44+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
45+
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v3
49+
with:
50+
submodules: recursive
51+
52+
# Initializes the CodeQL tools for scanning.
53+
- name: Initialize CodeQL
54+
uses: github/codeql-action/init@v2
55+
with:
56+
languages: ${{ matrix.language }}
57+
# If you wish to specify custom queries, you can do so here or in a config file.
58+
# By default, queries listed here will override any specified in a config file.
59+
# Prefix the list here with "+" to use these queries and those in the config file.
60+
61+
# 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
62+
# queries: security-extended,security-and-quality
63+
queries: security-and-quality
64+
65+
66+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
67+
# If this step fails, then you should remove it and run the build manually (see below)
68+
#- name: Autobuild
69+
# uses: github/codeql-action/autobuild@v2
70+
71+
# ℹ️ Command-line programs to run using the OS shell.
72+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
73+
74+
# If the Autobuild fails above, remove it and uncomment the following three lines.
75+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
76+
77+
- run: |
78+
sudo apt-get install -y build-essential
79+
./configure
80+
make
81+
82+
- name: Perform CodeQL Analysis
83+
uses: github/codeql-action/analyze@v2
84+
with:
85+
category: "/language:${{matrix.language}}"
86+
upload: false
87+
id: step1
88+
89+
# Filter out rules with low severity or high false positve rate
90+
# Also filter out warnings in third-party code
91+
- name: Filter out unwanted errors and warnings
92+
uses: advanced-security/filter-sarif@v1
93+
with:
94+
patterns: |
95+
-**:cpp/path-injection
96+
-**:cpp/world-writable-file-creation
97+
-**:cpp/poorly-documented-function
98+
-**:cpp/potentially-dangerous-function
99+
-**:cpp/use-of-goto
100+
-**:cpp/integer-multiplication-cast-to-long
101+
-**:cpp/comparison-with-wider-type
102+
-**:cpp/leap-year/*
103+
-**:cpp/ambiguously-signed-bit-field
104+
-**:cpp/suspicious-pointer-scaling
105+
-**:cpp/suspicious-pointer-scaling-void
106+
-**:cpp/unsigned-comparison-zero
107+
-**/cmake*/Modules/**
108+
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
109+
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
110+
111+
- name: Upload CodeQL results to code scanning
112+
uses: github/codeql-action/upload-sarif@v2
113+
with:
114+
sarif_file: ${{ steps.step1.outputs.sarif-output }}
115+
category: "/language:${{matrix.language}}"
116+
117+
- name: Upload CodeQL results as an artifact
118+
if: success() || failure()
119+
uses: actions/upload-artifact@v3
120+
with:
121+
name: codeql-results
122+
path: ${{ steps.step1.outputs.sarif-output }}
123+
retention-days: 5
124+

0 commit comments

Comments
 (0)