File tree Expand file tree Collapse file tree 5 files changed +137
-0
lines changed
Expand file tree Collapse file tree 5 files changed +137
-0
lines changed Original file line number Diff line number Diff line change 1+ name : " CodeQL"
2+
3+ on :
4+ push :
5+ branches : [ "master" ]
6+ pull_request :
7+ # The branches below must be a subset of the branches above
8+ branches : [ "master" ]
9+ schedule :
10+ - cron : ' 39 10 * * 0'
11+
12+ jobs :
13+ analyze :
14+ name : Analyze
15+ runs-on : ubuntu-latest
16+ permissions :
17+ actions : read
18+ contents : read
19+ security-events : write
20+
21+ strategy :
22+ fail-fast : false
23+ matrix :
24+ language : [ 'cpp' ]
25+
26+ steps :
27+ - name : Checkout repository
28+ uses : actions/checkout@v4
29+ with :
30+ submodules : recursive
31+
32+ - name : Install dependencies
33+ run : |
34+ sudo apt-get update
35+ sudo apt-get install -y --no-install-recommends \
36+ libconfig-dev \
37+ libopus-dev \
38+ libsodium-dev \
39+ libvpx-dev \
40+ ninja-build \
41+ pkg-config
42+
43+ - name : Initialize CodeQL
44+ uses : github/codeql-action/init@v3
45+ with :
46+ languages : ${{ matrix.language }}
47+ queries : security-and-quality
48+
49+ - name : Build
50+ run : |
51+ cmake -GNinja -B build -S .
52+ cmake --build build --parallel $(nproc)
53+
54+ - name : Perform CodeQL Analysis
55+ uses : github/codeql-action/analyze@v3
56+ with :
57+ category : " /language:${{ matrix.language }}"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+ cmake -GNinja -B build -S .
4+ cmake --build build --parallel $( nproc)
Original file line number Diff line number Diff line change 1+ # other/docker/codeql/codeql.Dockerfile
2+ FROM toxchat/c-toxcore:sources AS sources
3+ FROM ubuntu:22.04
4+
5+ RUN apt-get update && \
6+ DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
7+ build-essential \
8+ ca-certificates \
9+ cmake \
10+ curl \
11+ git \
12+ libconfig-dev \
13+ libopus-dev \
14+ libsodium-dev \
15+ libvpx-dev \
16+ ninja-build \
17+ pkg-config \
18+ unzip \
19+ wget \
20+ && apt-get clean \
21+ && rm -rf /var/lib/apt/lists/*
22+
23+ # Install CodeQL
24+ ARG CODEQL_VERSION=v2.23.9
25+ RUN curl -L -o /tmp/codeql.zip https://github.com/github/codeql-cli-binaries/releases/download/${CODEQL_VERSION}/codeql-linux64.zip && \
26+ unzip -q /tmp/codeql.zip -d /opt && \
27+ rm /tmp/codeql.zip
28+
29+ ENV PATH="/opt/codeql:$PATH"
30+
31+ RUN groupadd -r -g 1000 builder \
32+ && useradd -m --no-log-init -r -g builder -u 1000 builder
33+
34+ WORKDIR /home/builder/c-toxcore
35+
36+ # Copy sources
37+ COPY --chown=builder:builder --from=sources /src/ /home/builder/c-toxcore/
38+
39+ # Pre-create build directory
40+ RUN mkdir -p build codeql-db && chown builder:builder codeql-db build
41+
42+ # Copy scripts
43+ COPY --chown=builder:builder other/docker/codeql/build.sh .
44+ COPY --chown=builder:builder other/docker/codeql/run-analysis.sh .
45+
46+ RUN chmod +x build.sh run-analysis.sh
47+
48+ USER builder
49+
50+ # Download standard queries as builder
51+ RUN codeql pack download codeql/cpp-queries
52+
53+ CMD ["./run-analysis.sh" ]
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -eux
4+
5+ BUILD=codeql
6+
7+ # Ensure the sources image is built
8+ other/docker/sources/build.sh
9+
10+ # Build the codeql image
11+ docker build -t " toxchat/c-toxcore:$BUILD " -f " other/docker/$BUILD /$BUILD .Dockerfile" .
12+
13+ # Run the container
14+ echo " Running CodeQL analysis..."
15+ docker run --rm " toxchat/c-toxcore:$BUILD "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+ echo " Creating CodeQL Database..."
4+ codeql database create codeql-db --language=cpp --overwrite --command=" ./build.sh"
5+ echo " Analyzing..."
6+ codeql database analyze codeql-db codeql/cpp-queries:codeql-suites/cpp-security-and-quality.qls --format=csv --output=codeql-db/results.csv
7+ echo " Analysis complete. Results in codeql-db/results.csv"
8+ cat codeql-db/results.csv
You can’t perform that action at this time.
0 commit comments