Skip to content
Merged
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
105 changes: 105 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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: [ "develop" ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This workflow is gated to trigger only on the develop branch for both push and pull_request, but the repository's default branch is main and the existing CI workflows run on dev, develop, 0.12.0-dev, and main (see ci.yml). Because of that, code merged or opened as a PR against main — where releases happen — will bypass CodeQL scanning entirely. Consider widening the trigger branches to match the CI workflow (e.g. include main, dev, 0.12.0-dev) so the default/release branch is covered too.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/codeql.yml, line 16:

<comment>This workflow is gated to trigger only on the `develop` branch for both push and pull_request, but the repository's default branch is `main` and the existing CI workflows run on `dev`, `develop`, `0.12.0-dev`, and `main` (see ci.yml). Because of that, code merged or opened as a PR against `main` — where releases happen — will bypass CodeQL scanning entirely. Consider widening the trigger branches to match the CI workflow (e.g. include `main`, `dev`, `0.12.0-dev`) so the default/release branch is covered too.</comment>

<file context>
@@ -0,0 +1,105 @@
+
+on:
+  push:
+    branches: [ "develop" ]
+  pull_request:
+    branches: [ "develop" ]
</file context>

pull_request:
branches: [ "develop" ]
Comment on lines +15 to +18

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Develop-only event scanning 🐞 Bug ◔ Observability

The CodeQL workflow only runs on push/PR events for the develop branch, so changes targeting other
branches used by repo CI (e.g., main/dev) won’t get event-driven CodeQL results. This reduces timely
security feedback on those branches (even though the scheduled run still provides periodic
scanning).
Agent Prompt
## Issue description
CodeQL is only triggered for `develop` on `push` and `pull_request`, while the repo’s CI runs on additional branches.

## Issue Context
If changes are merged to `main`/`dev` (or PRs target them), this workflow won’t run on those events, reducing near-real-time scanning coverage.

## Fix Focus Areas
- .github/workflows/codeql.yml[14-20]
- .github/workflows/ci.yml[12-25]

## Suggested change
Update `on.push.branches` and `on.pull_request.branches` to include the same branch set as CI (or otherwise explicitly document/encode the intended security-scanning branch policy).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

schedule:
- cron: '20 8 * * 6'
Comment on lines +17 to +20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Scheduled scan wrong branch 🐞 Bug ☼ Reliability

The weekly schedule run will execute from the repository’s default branch workflow context, but
this workflow’s event-driven triggers are scoped to develop, so the scheduled CodeQL run may
analyze the default branch rather than develop. In this repo, other workflows gate deploy behavior
on refs/heads/main, so without an explicit checkout ref for scheduled events, the weekly scan can
diverge from the develop branch you’re targeting on push/PR.
Agent Prompt
### Issue description
The CodeQL workflow runs on a weekly schedule, but scheduled runs use the default-branch workflow context and your checkout step does not pin a ref. This can result in the scheduled scan analyzing the default branch instead of `develop`, while push/PR scans are limited to `develop`.

### Issue Context
This repo appears to treat `main` as a primary branch for deployments (docs workflow gates Pages operations on `refs/heads/main`), so it’s important the scheduled scan matches the intended target branch.

### Fix Focus Areas
- .github/workflows/codeql.yml[14-20]

### Suggested change
Conditionally pin checkout to `develop` for scheduled runs only, leaving push/PR behavior unchanged. For example:

```yml
- name: Checkout repository
  uses: actions/checkout@v7
  with:
    ref: ${{ github.event_name == 'schedule' && 'develop' || github.ref }}
```

(Alternatively, if you want weekly scanning on the default branch, clarify that intention and consider aligning push/PR branch filters accordingly.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


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: ${{ (matrix.language == 'swift' && 'macos-latest') || '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: actions
build-mode: none
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
- language: rust
build-mode: none
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major

Pin the remaining CodeQL actions to full commit SHAs.

This change pins actions/checkout, but github/codeql-action/init@v4 and github/codeql-action/analyze@v4 remain tag-based. Pin both actions to verified commit SHAs and keep the release comments current.

#!/usr/bin/env bash
set -euo pipefail

for action in \
  'github/codeql-action/init@v4' \
  'github/codeql-action/analyze@v4'
do
  repository="${action%@*}"
  ref="${action#*@}"
  gh api "repos/${repository}/commits/${ref}" \
    --jq '"\(.sha) \(.commit.message | split("\n")[0])"'
done

rg -n 'uses: github/codeql-action/(init|analyze)@' .github/workflows/codeql.yml
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/codeql.yml at line 64, Update the
github/codeql-action/init and github/codeql-action/analyze references in the
CodeQL workflow to verified full commit SHAs instead of the v4 tags, and update
each adjacent release comment to match the pinned version.


Comment thread
qodo-code-review[bot] marked this conversation as resolved.
# Add any setup steps before running the `github/codeql-action/init` action.
# This includes steps like installing compilers or runtimes (`actions/setup-node`
# or others). This is typically only required for manual builds.
# - name: Setup runtime (example)
# uses: actions/setup-example@v1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
Comment on lines +74 to +77

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Codeql config unused 🐞 Bug ⚙ Maintainability

The repo contains a CodeQL configuration file that constrains paths and query behavior, but the new
workflow does not reference it and instead selects languages via a matrix. This makes CodeQL results
inconsistent with the repo’s existing CodeQL configuration and can expand scanning scope beyond what
the config defines.
Agent Prompt
## Issue description
The workflow initializes CodeQL without using the repo’s existing `.github/codeql-config.yml`, so the configured paths/query-filters are not applied.

## Issue Context
`.github/codeql-config.yml` defines `paths`, `paths-ignore`, query pack usage, and filters. The workflow currently provides `languages` via a matrix and does not supply any `config-file` input.

## Fix Focus Areas
- .github/workflows/codeql.yml[44-53]
- .github/workflows/codeql.yml[73-78]
- .github/codeql-config.yml[1-30]

## Suggested change
1. In the `github/codeql-action/init` step, add `config-file: ./.github/codeql-config.yml`.
2. Decide on a single source of truth for languages:
   - If the repo intends Rust-only scanning, reduce the matrix to just Rust.
   - If the repo intends multi-language scanning, update `.github/codeql-config.yml` accordingly (paths/ignores/queries per language) so the workflow and config remain consistent.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The init step never passes config-file, so the repository's existing .github/codeql-config.yml is not applied by this workflow — its security-and-quality queries and paths/paths-ignore exclusions will be ignored, and analysis falls back to the default query set with default paths. Add config-file: .github/codeql-config.yml under with:.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/codeql.yml, line 77:

<comment>The `init` step never passes `config-file`, so the repository's existing `.github/codeql-config.yml` is not applied by this workflow — its `security-and-quality` queries and `paths`/`paths-ignore` exclusions will be ignored, and analysis falls back to the default query set with default paths. Add `config-file: .github/codeql-config.yml` under `with:`.</comment>

<file context>
@@ -0,0 +1,105 @@
+      uses: github/codeql-action/init@v4
+      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.
</file context>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder

# 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
- name: Run manual build steps
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@v4
with:
category: "/language:${{matrix.language}}"
Loading