Files
unleashed-firmware/.github/workflows/codeql.yml
T
Mykhailo Shevchuk 7898b15d8a CI: require the AI usage disclosure and finish the shell-injection hardening (#1054)
PR template: port the "No AI assistance" option and the "tick exactly one" note
from all-the-plugins (xMasterX/all-the-plugins#249) so the two repos agree, and
add a check that fails the PR unless exactly one of the three boxes is ticked.
The check needs no token and checks out nothing (`permissions: {}`), so plain
`pull_request` is safe for forks; `edited` is in the trigger list so fixing the
description re-runs it.

pr-build.yml: #1052 bound github.head_ref/ref_name to env, but the branch name
still reached a `run:` block through steps.vars.outputs.ref/.dist, which the
"Assemble PR report" step interpolated. A branch named `x$(id)` still executed
there. Bind those outputs to env as well, and reduce SAFE_REF to
[A-Za-z0-9._-] instead of only replacing '/', so the outputs are inert for
every consumer. Artifact names are unchanged for ordinary branch names.

Pin the two third-party actions to commits: dessant/lock-threads runs with
issues+pull-requests write, and a mutable tag can be repointed at any time.
2026-07-28 21:56:21 +03:00

121 lines
4.1 KiB
YAML

# 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"
run-name: "CodeQL Analyze ${{ github.ref_name }} by @${{ github.ACTOR }}"
on:
push:
branches: ["dev"]
workflow_dispatch:
# A full firmware build plus CodeQL analysis is expensive; back-to-back pushes to
# dev shouldn't run several at once. Matches the other workflows in this repo.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze
# 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
# Consider using larger runners for possible analysis time improvements.
runs-on: [ "ubuntu-latest" ]
timeout-minutes: 60
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["cpp"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
env:
PATH_SARIF_DIR: ".github/results.sarif"
PATH_SARIF_FILE: ".github/results.sarif/${{ matrix.language }}.sarif"
FBT_NO_SYNC: 0
DIST_SUFFIX: "codeql"
WORKFLOW_BRANCH_OR_TAG: release-cfw
LANG_CATEGORY: "/language:${{matrix.language}}"
steps:
- name: Checkout Firmware Files
uses: actions/checkout@v6
with:
clean: "true"
submodules: "true"
fetch-depth: "0"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
- name: Resolve CodeQL Build Env
uses: github/codeql-action/resolve-environment@v4
with:
language: ${{ matrix.language }}
#debug: true
- name: Build Firmware
shell: bash
if: ${{ success() }}
run: |
./fbt COMPACT=1 DEBUG=0 FBT_NO_SYNC=${{ env.FBT_NO_SYNC }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
if: ${{ success() }}
with:
threads: 4
category: "${{ env.LANG_CATEGORY }}"
output: "${{ env.PATH_SARIF_DIR }}"
upload-database: false
upload: "failure-only" # disable the upload here - we will upload in a different action
- name: Filter dirs for SARIF
# Third-party action pinned to a commit; mutable tags can be repointed.
uses: advanced-security/filter-sarif@f3b8118a9349d88f7b1c0c488476411145b6270d # v1
if: ${{ success() }}
with:
# filter out all test files unless they contain a sql-injection vulnerability
patterns: |
-build/**
-dist/**
-toolchain/**
-lib/**
input: "${{ env.PATH_SARIF_FILE }}"
output: "${{ env.PATH_SARIF_FILE }}"
- name: Upload CodeQL SARIF
uses: github/codeql-action/upload-sarif@v4
if: ${{ success() }}
with:
category: "${{ env.LANG_CATEGORY }}"
sarif_file: "${{ env.PATH_SARIF_FILE }}"
# optional: for debugging the uploaded sarif
# - name: Upload loc as a Build Artifact
# uses: actions/upload-artifact@v3
# with:
# name: sarif-results
# path: sarif-results
# retention-days: 1