Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SAST tool CodeQL scan #529

Merged
merged 6 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

env:
LLVM_VERSION: 19
LLVM_VERSION_MINOR: 0

jobs:
analyze:
name: Analyze

runs-on: ubuntu-latest

permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: manual

steps:

- name: Install llvm and its dependencies
run: |
curl -L "https://apt.llvm.org/llvm-snapshot.gpg.key" | sudo apt-key add -
curl -L "https://packages.lunarg.com/lunarg-signing-key-pub.asc" | sudo apt-key add -
echo "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy main" | sudo tee -a /etc/apt/sources.list
echo "deb https://packages.lunarg.com/vulkan jammy main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
clang-${{ env.LLVM_VERSION }} \
llvm-${{ env.LLVM_VERSION }}-dev \
libclang-${{ env.LLVM_VERSION }}-dev \
libclang-cpp${{ env.LLVM_VERSION }}-dev \
libpolly-${{ env.LLVM_VERSION }}-dev \
libzstd-dev \
libedit-dev

- name: Checkout opencl-clang sources for action files
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ github.ref }}

- name: Checkout SPIRV-LLVM-Translator sources
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: KhronosGroup/SPIRV-LLVM-Translator
path: SPIRV-LLVM-Translator
ref: main

- name: Build SPIRV-LLVM-Translator
run: |
builddir=${{ github.workspace }}/SPIRV-LLVM-Translator/build
cmake -B "$builddir" \
${{ github.workspace }}/SPIRV-LLVM-Translator \
-DLLVM_INCLUDE_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX="$builddir"/install \
-DCMAKE_BUILD_TYPE=Release
cmake --build "$builddir" -j $(nproc)
cmake --install "$builddir"
echo "spirv-translator-dir=${builddir}/install" >> $GITHUB_ENV

- name: Initialize CodeQL
uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}

- name: Build opencl-clang
run: |
mkdir build && cd build
cmake ${{ github.workspace }} \
-DPREFERRED_LLVM_VERSION="${{ env.LLVM_VERSION }}.${{ env.LLVM_VERSION_MINOR }}" \
-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF \
-DSPIRV_TRANSLATOR_DIR=${{ env.spirv-translator-dir }} \
-DCMAKE_BUILD_TYPE=Release
cmake --build . -j $(nproc)

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
with:
category: "/language:${{matrix.language}}"
2 changes: 0 additions & 2 deletions .github/workflows/on-push-verification-out-of-tree.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# ===---
# Running on push & pull_request.
# This workflow parses the destination branch
# to choose correct dependencies revisions
# ===---

name: Out-of-tree build
Expand Down
Loading