-
Notifications
You must be signed in to change notification settings - Fork 2
chore(ci): add CodeQL analysis #26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name: CodeQL | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| schedule: | ||
| - cron: "23 9 * * 1" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| env: | ||
| GO_VERSION: "1.26.5" | ||
|
|
||
| jobs: | ||
| codeql: | ||
| name: CodeQL Analysis | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} | ||
| check-latest: true | ||
| cache: true | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v4 | ||
| with: | ||
| languages: go | ||
| build-mode: manual | ||
| env: | ||
| CODEQL_EXTRACTOR_GO_BUILD_TRACING: "on" | ||
|
|
||
| - name: Build with CodeQL | ||
| run: go build ./... | ||
|
Comment on lines
+41
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
git ls-files .github/workflows/codeql.yml
echo '---'
cat -n .github/workflows/codeql.yml | sed -n '1,220p'Repository: NVIDIA/fleet-intelligence-client Length of output: 1884 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Search for CodeQL / setup-go usage in workflows for context
rg -n "setup-go|codeql-action/init|CODEQL_EXTRACTOR_GO_BUILD_TRACING|go build|go clean -cache|cache: true" .github/workflows -SRepository: NVIDIA/fleet-intelligence-client Length of output: 847 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/codeql.yml')
print(p.exists())
PYRepository: NVIDIA/fleet-intelligence-client Length of output: 175 🏁 Script executed: #!/bin/bash
set -euo pipefail
cat -n .github/workflows/codeql.yml | sed -n '1,220p'Repository: NVIDIA/fleet-intelligence-client Length of output: 1851 🌐 Web query:
💡 Result: The actions/setup-go action provides built-in support for caching both Go modules and build outputs (the GOCACHE directory) [1][2]. Caching is enabled by default [1][3]. Regarding build tracing and caching in the context of CodeQL: 1. CodeQL Build Tracing: When using CodeQL to create a database for Go, the process involves tracing the build command (e.g., go build) to extract build information [4][5]. In manual mode, you provide the explicit build command that CodeQL should trace [5]. CodeQL uses a build tracer to intercept compiler invocations during this command to collect the necessary data [5][6][7]. 2. Interaction with setup-go Cache: While actions/setup-go can cache the GOCACHE, this cache is managed by the Go toolchain itself based on source changes or dependency files [8][9]. CodeQL's tracing process is primarily concerned with capturing build commands and compiler invocations to generate the database [5]. If you are using setup-go with cache enabled alongside CodeQL, they operate independently: setup-go accelerates your standard Go build/test steps by restoring cached objects, while CodeQL performs its own tracing of the build process to build the database [4][10]. 3. Cache Invalidation and Build Tracing: A key point is that the Go build cache (GOCACHE) is not automatically updated based on source code changes to avoid excessive cache growth [8][9]. If you rely on cached build outputs during a CodeQL manual build, ensure your cache configuration aligns with your project's needs (e.g., by including source files in cache-dependency-path) [8][9]. CodeQL typically requires a clean, full build to correctly trace all files and dependencies for complete analysis [4]. Therefore, relying on heavily cached, incremental build outputs in a CodeQL tracing environment might sometimes lead to incomplete data capture if the tracer relies on seeing the full build process [5][6]. Users often perform a clean build for CodeQL analysis to ensure all dependencies and source files are correctly traced [4][10]. Citations:
🌐 Web query:
💡 Result: For GitHub Actions, the Citations:
🌐 Web query:
💡 Result: The environment variable GOCACHE is used by the Go toolchain to specify the location of the build cache, and it is enabled by default in all standard Go installations. You can verify its active location at any time by running the command Citations:
🌐 Web query:
💡 Result: CodeQL captures source code for analysis by instrumenting the build process to intercept and observe compiler invocations [1][2]. When using a manual build approach, CodeQL relies on these observations to understand data flow and create the database [2][3]. Core Mechanisms for Tracing Builds 1. Direct Tracing: You can wrap your build command directly with the CodeQL tracer. This is typically done using the Citations:
Clear the Go build cache before the traced CodeQL build. 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v4 | ||
| with: | ||
| category: "/language:go" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,220p' .github/workflows/codeql.ymlRepository: NVIDIA/fleet-intelligence-client
Length of output: 1431
🏁 Script executed:
rg -n "actions/(checkout|setup-go)@|cache:|go build|codeql" .github/workflows .github -SRepository: NVIDIA/fleet-intelligence-client
Length of output: 3530
🏁 Script executed:
Repository: NVIDIA/fleet-intelligence-client
Length of output: 2479
🌐 Web query:
actions/checkout latest major Node 24 compatibility actions/setup-go latest major Node 24 compatibility GitHub Actions💡 Result:
Both actions/checkout and actions/setup-go have been upgraded to support the Node.js 24 runtime [1][2][3]. Key details regarding Node 24 compatibility for these actions are: 1. Compatibility Requirements: Both actions now utilize the Node 24 runtime. To use these latest versions, your GitHub Actions runner must be version v2.327.1 or later [1][2][3]. 2. actions/checkout: Node 24 support was introduced in v5.0.0 [4]. Users are advised to use the latest major version (currently v7) to ensure full compatibility and access to the latest features [1][5]. 3. actions/setup-go: Node 24 support was introduced in the v6 major release [2][3][6]. General GitHub Actions Node 24 Context: As of July 30, 2026, Node 20 is in the process of being deprecated for GitHub Actions runners, with Node 24 becoming the standard runtime [7]. Runners began using Node 24 by default on June 16, 2026 [7]. If you encounter compatibility issues with specific older workflows, you can temporarily allow the use of Node 20 by setting the environment variable ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true, though this is a transitional measure as Node 20 support is being removed [7][8]. Additionally, note that Node 24 is not supported on older environments such as macOS 13.4 and lower, or Linux ARM32 [7][9].
Citations:
Use the current Node 24-compatible action majors and disable Go caching for this job.
actions/checkout@v4andactions/setup-go@v5are behind the current supported releases, andcache: truecan letgo build ./...reuse cached objects so CodeQL misses some traced compilations.🤖 Prompt for AI Agents