Skip to content

Commit 9c5e20e

Browse files
authored
Create codeql.yml to enable CodeQL Analysis (#411)
Signed-off-by: Li Xun <xun.li@intel.com>
1 parent 436caaa commit 9c5e20e

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.github/codeql/codeql-config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: "CodeQL config"
2+
paths-ignore:
3+
- external
4+
- QuoteVerification/QuoteVerificationService
5+
- QuoteVerification/QVL
6+
- QuoteVerification/sgxssl

.github/workflows/codeql.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '35 2 * * 0'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (${{ matrix.language }})
14+
runs-on: ubuntu-22.04
15+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
16+
permissions:
17+
# required for all workflows
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- language: c-cpp
25+
build-mode: manual
26+
sarif-name: cpp
27+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
submodules: recursive
33+
34+
# Initializes the CodeQL tools for scanning.
35+
- name: Initialize CodeQL
36+
uses: github/codeql-action/init@v3
37+
with:
38+
languages: ${{ matrix.language }}
39+
build-mode: ${{ matrix.build-mode }}
40+
config-file: ./.github/codeql/codeql-config.yml
41+
# If you wish to specify custom queries, you can do so here or in a config file.
42+
# By default, queries listed here will override any specified in a config file.
43+
# Prefix the list here with "+" to use these queries and those in the config file.
44+
45+
# If the analyze step fails for one of the languages you are analyzing with
46+
# "We were unable to automatically build your code", modify the matrix above
47+
# to set the build mode to "manual" for that language. Then modify this step
48+
# to build your code.
49+
# ℹ️ Command-line programs to run using the OS shell.
50+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
51+
- name: Build
52+
if: matrix.build-mode == 'manual'
53+
run: |
54+
sudo apt-get install libcurl4-openssl-dev libboost-dev libboost-system-dev libboost-thread-dev
55+
QuoteGeneration/download_prebuilt.sh
56+
wget -r -l1 -np -nd --accept 'sgx_linux_x64_sdk_*.bin' https://download.01.org/intel-sgx/latest/linux-latest/distro/ubuntu22.04-server/
57+
chmod +x ./sgx_linux_x64_sdk_*.bin
58+
./sgx_linux_x64_sdk_*.bin <<< "yes"
59+
source ./sgxsdk/environment; make all
60+
61+
- name: Perform CodeQL Analysis
62+
uses: github/codeql-action/analyze@v3
63+
with:
64+
category: "/language:${{matrix.language}}"
65+
output: sarif-results
66+
upload: failure-only
67+
68+
- name: Filter SARIF
69+
uses: advanced-security/filter-sarif@v1
70+
with:
71+
patterns: |
72+
-external/**/*
73+
-QuoteVerification/QuoteVerificationService/**/*
74+
-QuoteVerification/QVL/**/*
75+
-QuoteVerification/sgxssl/**/*
76+
input: sarif-results/${{ matrix.sarif-name }}.sarif
77+
output: sarif-results/${{ matrix.sarif-name }}.sarif
78+
79+
- name: Upload SARIF
80+
uses: github/codeql-action/upload-sarif@v3
81+
with:
82+
sarif_file: sarif-results/${{ matrix.sarif-name }}.sarif
83+

0 commit comments

Comments
 (0)