From d63600a3a182d71a8d828e0a166338896a79494a Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 18:55:30 +0300 Subject: [PATCH 1/7] Create codeql.yml --- .github/workflows/codeql.yml | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..be9a76a --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,84 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '39 12 * * 3' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: 'ubuntu-latest' + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + build-mode: autobuild + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # 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. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # 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 + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From 70c06ba63eeaaf00c04a49609c0c23466b33eeff Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 18:57:57 +0300 Subject: [PATCH 2/7] Fix CodeQL --- .github/workflows/codeql.yml | 56 ++++++++---------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index be9a76a..485828e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,14 +1,3 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# name: "CodeQL Advanced" on: @@ -22,20 +11,10 @@ on: jobs: analyze: name: Analyze (${{ matrix.language }}) - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners (GitHub.com only) - # Consider using larger runners or machines with greater resources for possible analysis time improvements. runs-on: 'ubuntu-latest' permissions: - # required for all workflows security-events: write - - # required to fetch internal or private CodeQL packs packages: read - - # only required for workflows in private repositories actions: read contents: read @@ -43,42 +22,31 @@ jobs: fail-fast: false matrix: include: - - language: c-cpp - build-mode: autobuild + - language: c-cpp + build-mode: manual + steps: - name: Checkout repository uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - # 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. - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + - name: Install Dependencies + run: | + sudo apt update + sudo apt install -y gcc build-essential grub2-common grub-pc xorriso qemu-system-x86 mtools cpio - # 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 - - if: matrix.build-mode == 'manual' - shell: bash + - name: Build Project run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 + make clean + make + make test - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: - category: "/language:${{matrix.language}}" + category: "/language:${{matrix.language}}" \ No newline at end of file From a8f60d584f7ebcc49dbe97f54323a584f9dc8999 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 18:59:04 +0300 Subject: [PATCH 3/7] Add CodeQL status badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 29992f5..8f1c3cd 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![C/C++ CI](https://github.com/CIS-osdev/kernel/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/CIS-osdev/kernel/actions/workflows/c-cpp.yml) [![pages-build-deployment](https://github.com/CIS-osdev/kernel/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/CIS-osdev/kernel/actions/workflows/pages/pages-build-deployment) +[![CodeQL Advanced](https://github.com/0Nera/cis-kernel/actions/workflows/codeql.yml/badge.svg)](https://github.com/0Nera/cis-kernel/actions/workflows/codeql.yml) [![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/russian_os/10921) From c2a3f06cd071c646ccedf1675915d5ec6e1b75d3 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 19:05:57 +0300 Subject: [PATCH 4/7] Try fix CodeQL --- .github/workflows/codeql.yml | 59 ++++++++++++++---------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 485828e..9806401 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,52 +1,39 @@ -name: "CodeQL Advanced" +name: C/C++ CI + +permissions: + contents: read + pull-requests: write on: + workflow_dispatch: + branches: [ "*" ] push: branches: [ "master" ] pull_request: branches: [ "master" ] - schedule: - - cron: '39 12 * * 3' jobs: - analyze: - name: Analyze (${{ matrix.language }}) - runs-on: 'ubuntu-latest' - permissions: - security-events: write - packages: read - actions: read - contents: read - - strategy: - fail-fast: false - matrix: - include: - - language: c-cpp - build-mode: manual - + build: + runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - + - uses: actions/checkout@v4 + - name: Configure + run: | + sudo apt update + sudo apt install gcc build-essential grub2-common grub-pc xorriso qemu-system-x86 mtools cpio - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - - - name: Install Dependencies + languages: c-cpp + build-mode: manual + - name: Set up CodeQL Environment run: | - sudo apt update - sudo apt install -y gcc build-essential grub2-common grub-pc xorriso qemu-system-x86 mtools cpio - - - name: Build Project - run: | - make clean - make - make test - + source $(codeql env --init) + - name: Make Build with CodeQL + run: make clean && make + - name: Run Tests + run: make test - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: - category: "/language:${{matrix.language}}" \ No newline at end of file + category: "/language:c-cpp" \ No newline at end of file From c2a9905f500cc14d72c8b175abe17b189c77bea6 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 19:07:29 +0300 Subject: [PATCH 5/7] Rename :D --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9806401..9b1d2d4 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,4 +1,4 @@ -name: C/C++ CI +name: CodeQL C/C++ permissions: contents: read From 375903f1a6dfd116b6ec5a1b1d01cd2d912fa5c0 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 19:10:13 +0300 Subject: [PATCH 6/7] Update codeql.yml --- .github/workflows/codeql.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9b1d2d4..9057eca 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,11 +2,9 @@ name: CodeQL C/C++ permissions: contents: read - pull-requests: write on: workflow_dispatch: - branches: [ "*" ] push: branches: [ "master" ] pull_request: @@ -17,23 +15,25 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Configure + + - name: Install Dependencies run: | sudo apt update - sudo apt install gcc build-essential grub2-common grub-pc xorriso qemu-system-x86 mtools cpio + sudo apt install -y gcc build-essential grub2-common grub-pc xorriso qemu-system-x86 mtools cpio + - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: c-cpp build-mode: manual - - name: Set up CodeQL Environment + + - name: Build with CodeQL run: | - source $(codeql env --init) - - name: Make Build with CodeQL - run: make clean && make + make clean + make + - name: Run Tests run: make test + - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:c-cpp" \ No newline at end of file + uses: github/codeql-action/analyze@v3 \ No newline at end of file From 3eb8cc48bd4d18ef15ef3db4535aa7a071ac0be8 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Sun, 12 Jan 2025 19:13:46 +0300 Subject: [PATCH 7/7] Update permissions --- .github/workflows/codeql.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9057eca..949a6ca 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,6 +2,8 @@ name: CodeQL C/C++ permissions: contents: read + actions: read + security-events: write on: workflow_dispatch: