-
-
Notifications
You must be signed in to change notification settings - Fork 164
165 lines (138 loc) · 4.47 KB
/
static-analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: "Static Analysis"
on:
push:
branches: [ "main", "master" ]
schedule:
- cron: '0 0 * * *'
pull_request:
branches: '*'
jobs:
codeql:
name: GitHub CodeQL
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: security-and-quality
- name: Install Deps, Configure and Build
run: |
./.github/workflows/codeql-buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:cpp"
upload: false
id: step1
# Filter out rules with low severity or high false positve rate
# Also filter out warnings in third-party code
- name: Filter out unwanted errors and warnings
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**:cpp/path-injection
-**:cpp/world-writable-file-creation
-**:cpp/poorly-documented-function
-**:cpp/potentially-dangerous-function
-**:cpp/use-of-goto
-**:cpp/integer-multiplication-cast-to-long
-**:cpp/comparison-with-wider-type
-**:cpp/leap-year/*
-**:cpp/ambiguously-signed-bit-field
-**:cpp/suspicious-pointer-scaling
-**:cpp/suspicious-pointer-scaling-void
-**:cpp/unsigned-comparison-zero
-**/cmake*/Modules/**
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:cpp"
- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
retention-days: 5
- name: Fail if a warning is found
run: |
./.github/workflows/fail_on_warning.py \
${{ steps.step1.outputs.sarif-output }}/cpp.sarif
scan-build:
name: Clang scan-build
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Deps, Configure and Build
env:
WRAPPER: "scan-build --use-cc=cc --use-c++=c++ -sarif -o build/sarif"
run: |
./.github/workflows/codeql-buildscript.sh
- name: Install Deps, Configure and Build
env:
WRAPPER: "scan-build --use-cc=cc --use-c++=c++ -o build/scan-build-html"
run: |
./.github/workflows/codeql-buildscript.sh
- uses: actions/upload-artifact@v2
with:
name: "Scan-Build Bug Reports"
path: ${{ github.workspace }}/build/scan-build-html
- name: Bundle sarif
run: |
npx -y @microsoft/sarif-multitool merge build/sarif/*/*.sarif -o build/sarif/
- name: Upload results to code scanning
uses: github/codeql-action/upload-sarif@v2
with:
category: "scan-build"
sarif_file: build/sarif/merged.sarif
- name: Fail if a warning is found
run: |
./.github/workflows/fail_on_warning.py build/sarif/merged.sarif
codechecker:
name: CodeChecker
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Deps, Configure and Build
run: |
./.github/workflows/codeql-buildscript.sh
- name: Run CodeChecker
uses: whisperity/codechecker-analysis-action@v1
id: codechecker
with:
ctu: true
logfile: ${{ github.workspace }}/build/compile_commands.json
- uses: actions/upload-artifact@v2
with:
name: "CodeChecker Bug Reports"
path: ${{ steps.codechecker.outputs.result-html-dir }}
- name: Fail if a warning is found
if: ${{ steps.codechecker.outputs.warnings == 'true' }}
run: exit 1