From 05eabe1dd69bfd51c7ffbf5e8a6de3d7b3672481 Mon Sep 17 00:00:00 2001 From: Jorge <46056498+jorgectf@users.noreply.github.com> Date: Mon, 3 Jul 2023 09:21:23 +0200 Subject: [PATCH] Add CodeQL workflow --- .github/workflows/codeql.yml | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 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 0000000000..ee9c685eba --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,97 @@ +name: "CodeQL" + +on: + push: + branches: [ 'develop', 'main', 'vnext' ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ 'develop' ] + schedule: + - cron: '43 8 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'csharp' && 'windows-latest') || 'ubuntu-latest' }} + + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp', 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - if: matrix.language == 'csharp' + name: Setup vcpkg + working-directory: ../ + run: | + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.bat + + - if: matrix.language == 'csharp' + name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1 + + - if: matrix.language == 'csharp' + uses: nuget/setup-nuget@v1 + with: + nuget-version: latest + + - if: matrix.language == 'csharp' + name: Nuget restore + run: nuget restore Telegram.sln + + - if: matrix.language == 'csharp' + name: Build vcpkg + working-directory: ../vcpkg + run: | + ./vcpkg.exe install ffmpeg[opus,vpx]:x64-uwp lz4:x64-uwp openssl:x64-uwp zlib:x64-uwp libwebp:x64-uwp libogg:x64-uwp opus:x64-uwp + ./vcpkg.exe integrate install + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # 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 + + - if: matrix.language == 'csharp' + name: Build C# + env: + CONFIG: RELEASE + ARCH: x64 + MODE: SideloadOnly + CERTIFICATE: PackageCertificateThumbprint=60FFAEE648D4D34A1089405643B511F50BEF8A49 + run: | + .\UpdateManifest.ps1 -path "Telegram.Msix\\" -config "$CONFIG" -mode "$MODE" + msbuild Telegram.sln /target:Telegram_Msix /p:Configuration=Release /p:Platform="$ARCH" /p:UapAppxPackageBuildMode=$MODE /p:AppxBundlePlatforms="$ARCH" /p:AppxBundle=Always /p:AppxPackageSigningEnabled=True /p:$certificate + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - if: matrix.language != 'csharp' + name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}"