From 31b07e8dd8132f454a0b4864e4c95b1073967509 Mon Sep 17 00:00:00 2001 From: Li Xun Date: Tue, 18 Jun 2024 10:05:56 +0800 Subject: [PATCH 1/2] Create codeql.yml to enable CodeQL Analysis Signed-off-by: Li Xun --- .github/codeql/codeql-config.yml | 6 +++ .github/workflows/codeql.yml | 64 ++++++++++++++++++++++++++++++++ 2 files changed, 70 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 00000000..ee3e1a29 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,6 @@ +name: "CodeQL config" +paths-ignore: + - external + - QuoteVerification/QuoteVerificationService + - QuoteVerification/QVL + - QuoteVerification/sgxssl diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..0e32673e --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,64 @@ +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '35 2 * * 0' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-22.04 + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + # required for all workflows + security-events: write + + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + build-mode: manual + # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + config-file: ./.github/codeql/codeql-config.yml + # 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. + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - name: Build + if: matrix.build-mode == 'manual' + run: | + sudo apt-get install libcurl4-openssl-dev libboost-dev libboost-system-dev libboost-thread-dev + QuoteGeneration/download_prebuilt.sh + wget -r -l1 -np -nd --accept 'sgx_linux_x64_sdk_*.bin' https://download.01.org/intel-sgx/latest/linux-latest/distro/ubuntu22.04-server/ + chmod +x ./sgx_linux_x64_sdk_*.bin + ./sgx_linux_x64_sdk_*.bin <<< "yes" + source ./sgxsdk/environment; make all + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" + From ed4a19c675bc07bdd7e068202ea7038454cc9db0 Mon Sep 17 00:00:00 2001 From: "Li, Xun" Date: Fri, 21 Jun 2024 08:53:36 +0800 Subject: [PATCH 2/2] fixup! Create codeql.yml to enable CodeQL Analysis Signed-off-by: Li, Xun --- .github/workflows/codeql.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0e32673e..d072a985 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -23,6 +23,7 @@ jobs: include: - language: c-cpp build-mode: manual + sarif-name: cpp # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' steps: - name: Checkout repository @@ -61,4 +62,22 @@ jobs: uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" + output: sarif-results + upload: failure-only + + - name: Filter SARIF + uses: advanced-security/filter-sarif@v1 + with: + patterns: | + -external/**/* + -QuoteVerification/QuoteVerificationService/**/* + -QuoteVerification/QVL/**/* + -QuoteVerification/sgxssl/**/* + input: sarif-results/${{ matrix.sarif-name }}.sarif + output: sarif-results/${{ matrix.sarif-name }}.sarif + + - name: Upload SARIF + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: sarif-results/${{ matrix.sarif-name }}.sarif