From 55be67b2e613cfe7b9a3d85023f04806c03e10b5 Mon Sep 17 00:00:00 2001 From: Kevin Stubbings Date: Sat, 12 Nov 2022 11:26:06 -0800 Subject: [PATCH] Add CodeQL workflow (#4125) * Add CodeQL workflow * Improve CodeQL setup Install proper packages to enable GTK and Qt client builds. Exclude 3rd-party dependencies from analysis (they should be analyzed separately in their own repositories). Speed C++ analysis up by building with Ninja. Speed JavaScript analysis up by skipping CMake configuration and build, which is not required for interpreted languages. * Revert unintentional branch specification change * Exclude generated JavaScript files from CodeQL analysis Co-authored-by: Mike Gelfand Co-authored-by: Mike Gelfand --- .github/codeql/codeql-config.yml | 2 + .github/workflows/codeql.yml | 86 ++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/codeql/codeql-config.yml create mode 100644 .github/workflows/codeql.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 000000000..a8312c0e7 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,2 @@ +paths-ignore: +- web/public_html/transmission-app.js diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..37c3c7d40 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,86 @@ +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '29 14 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'javascript' ] + + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Update and Install Dependencies + if: ${{ matrix.language == 'cpp' }} + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + g++ \ + gettext \ + libcurl4-openssl-dev \ + libdeflate-dev \ + libevent-dev \ + libfmt-dev \ + libglibmm-2.4-dev \ + libgtkmm-3.0-dev \ + libminiupnpc-dev \ + libnatpmp-dev \ + libpsl-dev \ + libssl-dev \ + ninja-build \ + pkg-config \ + qtbase5-dev \ + qttools5-dev + + - name: Configure Project + if: ${{ matrix.language == 'cpp' }} + run: | + cmake -S . -B _build -G Ninja \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DENABLE_TESTS=OFF \ + -DENABLE_NLS=OFF \ + -DRUN_CLANG_TIDY=OFF + + - name: Build Dependencies + if: ${{ matrix.language == 'cpp' }} + run: | + ninja -C _build -t targets | + grep -E 'third-party/.*-build:' | + cut -d: -f1 | + xargs -L1 ninja -C _build + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + config-file: ./.github/codeql/codeql-config.yml + + - name: Build Project + if: ${{ matrix.language == 'cpp' }} + run: | + ninja -C _build + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}"