Skip to content

Commit 8ddd3a0

Browse files
Adding CPP CodeQL Scanning (#309)
* Add files via upload * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 49937f4 commit 8ddd3a0

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: "CodeQL Analysis"
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
analyze:
10+
name: Analyze with CodeQL
11+
runs-on: ubuntu-latest
12+
13+
# Run everything inside your Docker image
14+
container:
15+
image: intellabs/vdms:latest
16+
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
language: [ 'cpp' ] # VDMS is C++ based
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
submodules: recursive
32+
33+
34+
- name: Install latest CMake
35+
run: |
36+
apt-get update
37+
apt-get remove --purge -y cmake cmake-data || true
38+
apt-get install -y wget tar xz-utils build-essential
39+
40+
CMAKE_VERSION=3.30.4
41+
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz
42+
tar -xzf cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz
43+
mv cmake-${CMAKE_VERSION}-linux-x86_64 /opt/cmake
44+
ln -sf /opt/cmake/bin/* /usr/local/bin/
45+
cmake --version
46+
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@v3
49+
with:
50+
languages: cpp
51+
queries: security-extended,security-and-quality
52+
build-mode: manual
53+
54+
- name: Configure CMake (disable linking)
55+
run: |
56+
sed -i "s|#include <stdio.h>|#include <stdio.h>\n#include <stdexcept>|" src/pmgd/test/neighbortest.cc
57+
sed -i "s|#include <stdio.h>|#include <stdio.h>\n#include <stdexcept>|" src/pmgd/tools/mkgraph.cc
58+
sed -i "s|java-11-openjdk|java-17-openjdk|g" src/pmgd/java/CMakeLists.txt
59+
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
60+
-DCMAKE_C_LINK_EXECUTABLE="/bin/true" \
61+
-DCMAKE_CXX_LINK_EXECUTABLE="/bin/true"
62+
63+
- name: Build (compile only, no linking)
64+
run: cmake --build build -j$(nproc)
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v3
68+
with:
69+
category: '/language:cpp'
70+
output: ./codeql-results
71+
72+
- name: Upload SARIF File
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name : codeql-results
76+
path: ./codeql-results/**/*.sarif

0 commit comments

Comments
 (0)