Skip to content

Commit

Permalink
Create codeql.yml to enable CodeQL Analysis (#411)
Browse files Browse the repository at this point in the history
Signed-off-by: Li Xun <xun.li@intel.com>
  • Loading branch information
llly authored Jun 21, 2024
1 parent 436caaa commit 9c5e20e
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: "CodeQL config"
paths-ignore:
- external
- QuoteVerification/QuoteVerificationService
- QuoteVerification/QVL
- QuoteVerification/sgxssl
83 changes: 83 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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
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
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}}"
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

0 comments on commit 9c5e20e

Please sign in to comment.