| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
name: Analyze raylib with CodeQL |
| 7 |
|
| 8 |
on: |
| 9 |
workflow_dispatch: |
| 10 |
|
| 11 |
|
| 12 |
pull_request: |
| 13 |
branches: '*' |
| 14 |
schedule: |
| 15 |
- cron: '0 0 * * 1' |
| 16 |
|
| 17 |
env: |
| 18 |
|
| 19 |
BUILD_TYPE: Release |
| 20 |
|
| 21 |
jobs: |
| 22 |
analyze: |
| 23 |
name: Analyze |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} |
| 30 |
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} |
| 31 |
permissions: |
| 32 |
actions: read |
| 33 |
contents: read |
| 34 |
security-events: write |
| 35 |
|
| 36 |
strategy: |
| 37 |
fail-fast: false |
| 38 |
matrix: |
| 39 |
language: [ 'cpp' ] |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
steps: |
| 46 |
- name: Checkout repository |
| 47 |
uses: actions/checkout@v4 |
| 48 |
with: |
| 49 |
submodules: recursive |
| 50 |
|
| 51 |
- name: Create Build Environment |
| 52 |
|
| 53 |
|
| 54 |
run: cmake -E make_directory ${{github.workspace}}/build |
| 55 |
|
| 56 |
- name: Setup Environment |
| 57 |
run: | |
| 58 |
sudo apt-get update -qq |
| 59 |
sudo apt-get install gcc-multilib |
| 60 |
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev |
| 61 |
|
| 62 |
- name: Configure CMake |
| 63 |
|
| 64 |
|
| 65 |
shell: bash |
| 66 |
working-directory: ${{github.workspace}}/build |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=Desktop |
| 71 |
|
| 72 |
|
| 73 |
- name: Initialize CodeQL |
| 74 |
uses: github/codeql-action/init@v3 |
| 75 |
with: |
| 76 |
languages: ${{ matrix.language }} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
queries: security-and-quality |
| 84 |
|
| 85 |
- name: Build |
| 86 |
|
| 87 |
run: | |
| 88 |
cd build |
| 89 |
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=Desktop |
| 90 |
cmake --build . --config $BUILD_TYPE |
| 91 |
|
| 92 |
- name: Perform CodeQL Analysis |
| 93 |
uses: github/codeql-action/analyze@v3 |
| 94 |
with: |
| 95 |
category: "/language:${{matrix.language}}" |
| 96 |
upload: false |
| 97 |
id: step1 |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
- name: Filter out unwanted errors and warnings |
| 102 |
uses: advanced-security/filter-sarif@v1 |
| 103 |
with: |
| 104 |
patterns: | |
| 105 |
-**:cpp/path-injection |
| 106 |
-**:cpp/world-writable-file-creation |
| 107 |
-**:cpp/poorly-documented-function |
| 108 |
-**:cpp/potentially-dangerous-function |
| 109 |
-**:cpp/use-of-goto |
| 110 |
-**:cpp/integer-multiplication-cast-to-long |
| 111 |
-**:cpp/comparison-with-wider-type |
| 112 |
-**:cpp/leap-year/* |
| 113 |
-**:cpp/ambiguously-signed-bit-field |
| 114 |
-**:cpp/suspicious-pointer-scaling |
| 115 |
-**:cpp/suspicious-pointer-scaling-void |
| 116 |
-**:cpp/unsigned-comparison-zero |
| 117 |
-**/cmake*/Modules/** |
| 118 |
-**/src/external/glfw/** |
| 119 |
-**/src/external/** |
| 120 |
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif |
| 121 |
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif |
| 122 |
|
| 123 |
- name: Upload CodeQL results to code scanning |
| 124 |
uses: github/codeql-action/upload-sarif@v2 |
| 125 |
with: |
| 126 |
sarif_file: ${{ steps.step1.outputs.sarif-output }} |
| 127 |
category: "/language:${{matrix.language}}" |
| 128 |
|
| 129 |
- name: Upload CodeQL results as an artifact |
| 130 |
if: success() || failure() |
| 131 |
uses: actions/upload-artifact@v4 |
| 132 |
with: |
| 133 |
name: codeql-results |
| 134 |
path: ${{ steps.step1.outputs.sarif-output }} |
| 135 |
retention-days: 5 |