Skip to content

Commit 5e3e243

Browse files
committed
merge codeql and pvs-studio to static_analysis.yml
1 parent 948ba20 commit 5e3e243

File tree

2 files changed

+99
-21
lines changed

2 files changed

+99
-21
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
# Consider using larger runners for possible analysis time improvements.
4242
runs-on: ubuntu-latest
4343
timeout-minutes: 360
44+
if: false
4445
permissions:
4546
actions: read
4647
contents: read

.github/workflows/static_analysis.yml

Lines changed: 98 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,80 @@ on:
66
- master
77
pull_request:
88
types: [opened, synchronize, reopened]
9+
10+
permissions:
11+
actions: read
12+
contents: read
13+
security-events: write
14+
915
jobs:
10-
# SonarQube:
11-
# name: Build and analyze
12-
# runs-on: ubuntu-latest
13-
# env:
14-
# BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
15-
# steps:
16-
# - uses: actions/checkout@v4
16+
CodeQL:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
board:
22+
- 'raspberry_pi_pico'
23+
steps:
24+
- name: Checkout TinyUSB
25+
uses: actions/checkout@v4
26+
27+
- name: Get Dependencies
28+
uses: ./.github/actions/get_deps
29+
with:
30+
arg: -b${{ matrix.board }}
31+
32+
- name: Setup Toolchain
33+
uses: ./.github/actions/setup_toolchain
34+
with:
35+
toolchain: 'arm-gcc'
36+
37+
- name: Initialize CodeQL
38+
uses: github/codeql-action/init@v4
39+
with:
40+
languages: 'c-cpp'
41+
queries: security-and-quality
42+
43+
- name: Build
44+
run: |
45+
cmake examples -B build -G Ninja -DBOARD=${{ matrix.board }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=MinSizeRel
46+
cmake --build build
47+
48+
- name: Perform CodeQL Analysis
49+
uses: github/codeql-action/analyze@v4
50+
with:
51+
category: CodeQL
52+
upload: always
53+
id: step1
54+
55+
# - name: Filter out unwanted errors and warnings
56+
# uses: advanced-security/filter-sarif@v1
1757
# with:
18-
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
19-
# - name: Install Build Wrapper
20-
# uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
21-
# - name: Run Build Wrapper
22-
# run: |
23-
# build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset ${{ env.BOARD }} -t ${{ env.EXAMPLE }}
24-
# - name: SonarQube Scan
25-
# uses: SonarSource/sonarqube-scan-action@v6
26-
# env:
27-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
58+
# patterns: |
59+
# -**:cpp/path-injection
60+
# -**:cpp/world-writable-file-creation
61+
# -**:cpp/poorly-documented-function
62+
# -**:cpp/potentially-dangerous-function
63+
# -**:cpp/use-of-goto
64+
# -**:cpp/integer-multiplication-cast-to-long
65+
# -**:cpp/comparison-with-wider-type
66+
# -**:cpp/leap-year/*
67+
# -**:cpp/ambiguously-signed-bit-field
68+
# -**:cpp/suspicious-pointer-scaling
69+
# -**:cpp/suspicious-pointer-scaling-void
70+
# -**:cpp/unsigned-comparison-zero
71+
# -**/third*party/**
72+
# -**/3rd*party/**
73+
# -**/external/**
74+
# input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
75+
# output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
76+
#
77+
# - name: Upload SARIF
78+
# uses: github/codeql-action/upload-sarif@v4
2879
# with:
29-
# args: >
30-
# --define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
80+
# sarif_file: ${{ steps.step1.outputs.sarif-output }}
81+
# category: CodeQL
82+
3183
PVS-Studio:
3284
runs-on: ubuntu-latest
3385
strategy:
@@ -49,14 +101,17 @@ jobs:
49101
with:
50102
toolchain: 'arm-gcc'
51103

52-
- name: Analyze
104+
- name: Install Tools
53105
run: |
54106
wget -q -O - https://files.pvs-studio.com/etc/pubkey.txt | sudo apt-key add -
55107
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.pvs-studio.com/etc/viva64.list
56108
sudo apt update
57109
sudo apt install pvs-studio
58110
pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
59-
cmake examples -B build -G Ninja -DBOARD=${{ matrix.board }} -DCMAKE_BUILD_TYPE=MinSizeRel
111+
112+
- name: Analyze
113+
run: |
114+
cmake examples -B build -G Ninja -DBOARD=${{ matrix.board }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=MinSizeRel
60115
cmake --build build
61116
pvs-studio-analyzer analyze -f build/compile_commands.json -j --exclude-path hw/mcu/ --exclude-path lib/
62117
plog-converter -t sarif -o pvs.sarif PVS-Studio.log
@@ -66,3 +121,25 @@ jobs:
66121
with:
67122
sarif_file: pvs.sarif
68123
category: PVS-Studio
124+
125+
# SonarQube:
126+
# name: Build and analyze
127+
# runs-on: ubuntu-latest
128+
# env:
129+
# BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
130+
# steps:
131+
# - uses: actions/checkout@v4
132+
# with:
133+
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
134+
# - name: Install Build Wrapper
135+
# uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
136+
# - name: Run Build Wrapper
137+
# run: |
138+
# build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset ${{ env.BOARD }} -t ${{ env.EXAMPLE }}
139+
# - name: SonarQube Scan
140+
# uses: SonarSource/sonarqube-scan-action@v6
141+
# env:
142+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
143+
# with:
144+
# args: >
145+
# --define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

0 commit comments

Comments
 (0)