From 4b2cbec11adf48c6e991ed5c8b494b16d0a93725 Mon Sep 17 00:00:00 2001 From: AMS21 Date: Wed, 6 Dec 2023 09:54:15 +0000 Subject: [PATCH] GitHub Actions: Add CodeQL code scanning --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..7153d7f093b --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +name: "CodeQL" + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + schedule: + - cron: '0 3 * * 1' + workflow_dispatch: + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: 'ubuntu-latest' + permissions: + actions: read + contents: read + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Deinit Crypto++ + run: git submodule deinit Externals/cryptopp + + - name: Install packages + run: | + sudo apt-get update -qq + sudo apt-get install -qq -y libsdl2-dev libglew-dev liblzo2-dev libjpeg-dev && + sudo apt-get install -qq -y libopenal-dev libogg-dev libtheora-dev libvorbis-dev + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: 'c-cpp' + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # 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 + # queries: security-extended,security-and-quality + + - name: Run CMake + run: cmake -B build -DCMAKE_C_FLAGS="-w" -DCMAKE_CXX_FLAGS="-w" -DCMAKE_UNITY_BUILD=ON -DUSE_LTO=OFF + + - name: Run CMake Build + run: cmake --build build --parallel $(nproc || echo 4) + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + upload: false + output: sarif-results + + - name: filter-sarif + uses: advanced-security/filter-sarif@v1 + with: + patterns: | + -**/Externals/** + input: sarif-results/cpp.sarif + output: sarif-results/cpp.sarif + + - name: Upload SARIF + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: sarif-results/cpp.sarif