Skip to content
Closed
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
172 changes: 172 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Static Analysis

on:
pull_request:
paths:
- 'kernel/realsense/**'
push:
branches: [master, dev]
paths:
- 'kernel/realsense/**'
Comment on lines +6 to +10

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The path filter only triggers on kernel/realsense/** changes, but the workflow itself (.github/workflows/static-analysis.yml) is not included. If you modify the workflow file, it won't run to validate the changes. Consider adding .github/workflows/static-analysis.yml to the paths filter so the workflow runs when it's modified, allowing you to test workflow changes in PRs.

Suggested change
- 'kernel/realsense/**'
push:
branches: [master, dev]
paths:
- 'kernel/realsense/**'
- 'kernel/realsense/**'
- '.github/workflows/static-analysis.yml'
push:
branches: [master, dev]
paths:
- 'kernel/realsense/**'
- '.github/workflows/static-analysis.yml'

Copilot uses AI. Check for mistakes.
workflow_dispatch:

permissions: read-all

jobs:
cppcheck:
name: cppcheck
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The actions/checkout action should use a pinned commit hash instead of a version tag for security. The existing workflows in this repository (e.g., build-jp6.2.yml:19) use the pattern actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3 where the commit hash is pinned with a version comment. This prevents supply chain attacks by ensuring the exact code being executed is known.

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Copilot uses AI. Check for mistakes.

- name: Install cppcheck
run: sudo apt-get update && sudo apt-get install -y cppcheck

- name: Run cppcheck
run: |
cppcheck \
--enable=warning,performance,portability \
--suppress=missingIncludeSystem \
--suppress=missingInclude \
--force \
--inline-suppr \
--template='[{severity}] {file}:{line}: {message} [{id}]' \
kernel/realsense/ 2>&1 | tee cppcheck_output.txt

# Generate summary
TOTAL=$(grep -cE '^\[(error|warning|performance|portability)\]' cppcheck_output.txt || true)
echo "## cppcheck Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Found **${TOTAL}** finding(s) in \`kernel/realsense/\`." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "$TOTAL" -gt 0 ]; then
echo '```' >> $GITHUB_STEP_SUMMARY
cat cppcheck_output.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi

- name: Upload results
if: always()
uses: actions/upload-artifact@v4

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The actions/upload-artifact action should use a pinned commit hash instead of a version tag for security. The existing workflows in this repository use pinned commit hashes for GitHub Actions to prevent supply chain attacks.

Suggested change
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808

Copilot uses AI. Check for mistakes.
with:
name: cppcheck-results
path: cppcheck_output.txt

sparse-smatch:
name: Sparse & Smatch
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The actions/checkout action should use a pinned commit hash instead of a version tag for security. The existing workflows in this repository use pinned commit hashes for GitHub Actions to prevent supply chain attacks.

Copilot uses AI. Check for mistakes.

- name: Install build dependencies and Sparse
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential bc wget flex bison curl libssl-dev xxd \
sparse \
libsqlite3-dev libxml2-dev llvm pkg-config

- name: Build and install Smatch
run: |
git clone --depth=1 https://github.com/error27/smatch.git /tmp/smatch

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

Cloning from the smatch repository using only --depth=1 without pinning a specific commit hash creates a security and reproducibility risk. If the repository is compromised or the HEAD commit changes, the workflow could pull in different code. Consider pinning to a specific commit hash or tag.

Suggested change
git clone --depth=1 https://github.com/error27/smatch.git /tmp/smatch
git clone --depth=1 --branch v1.72 https://github.com/error27/smatch.git /tmp/smatch

Copilot uses AI. Check for mistakes.
cd /tmp/smatch
make -j$(nproc)
sudo make PREFIX=/usr install
smatch --version

- name: Setup workspace
run: yes | ./setup_workspace.sh 6.2

- name: Apply patches
run: |
git config --global user.email "builder@example.com"
git config --global user.name "builder"
./apply_patches.sh 6.2

- name: Build kernel and modules
run: ./build_all.sh 6.2

- name: Run Sparse on d4xx
run: |
DEVDIR=${{ github.workspace }}
SRCS=$DEVDIR/sources_6.2
export CROSS_COMPILE=$DEVDIR/l4t-gcc/6.x/bin/aarch64-buildroot-linux-gnu-
KERNEL_HEADERS=$SRCS/kernel/kernel-jammy-src

# Delete d4xx.o to force recompilation — Sparse (C=1) only checks recompiled files
rm -f $SRCS/nvidia-oot/drivers/media/i2c/d4xx.o

make -j$(nproc) ARCH=arm64 C=1 \
-C $KERNEL_HEADERS \
M=$SRCS/nvidia-oot \
CONFIG_TEGRA_OOT_MODULE=m \
srctree.nvidia-oot=$SRCS/nvidia-oot \
srctree.hwpm=$SRCS/hwpm \
srctree.nvconftest=$SRCS/out/nvidia-conftest \
KBUILD_EXTRA_SYMBOLS=$SRCS/hwpm/drivers/tegra/hwpm/Module.symvers \
modules 2>&1 | tee $DEVDIR/sparse_raw.txt || true

grep -i "d4xx" $DEVDIR/sparse_raw.txt > $DEVDIR/sparse_output.txt || true

- name: Run Smatch on d4xx
run: |
DEVDIR=${{ github.workspace }}
SRCS=$DEVDIR/sources_6.2
export CROSS_COMPILE=$DEVDIR/l4t-gcc/6.x/bin/aarch64-buildroot-linux-gnu-
KERNEL_HEADERS=$SRCS/kernel/kernel-jammy-src

rm -f $SRCS/nvidia-oot/drivers/media/i2c/d4xx.o

make -j$(nproc) ARCH=arm64 C=1 CHECK="smatch -p=kernel" \
-C $KERNEL_HEADERS \
M=$SRCS/nvidia-oot \
CONFIG_TEGRA_OOT_MODULE=m \
srctree.nvidia-oot=$SRCS/nvidia-oot \
srctree.hwpm=$SRCS/hwpm \
srctree.nvconftest=$SRCS/out/nvidia-conftest \
KBUILD_EXTRA_SYMBOLS=$SRCS/hwpm/drivers/tegra/hwpm/Module.symvers \
modules 2>&1 | tee $DEVDIR/smatch_raw.txt || true

grep -i "d4xx" $DEVDIR/smatch_raw.txt > $DEVDIR/smatch_output.txt || true

- name: Generate summary
if: always()
run: |
echo "## Sparse & Smatch Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

SPARSE_COUNT=0
SMATCH_COUNT=0
[ -s sparse_output.txt ] && SPARSE_COUNT=$(wc -l < sparse_output.txt)
[ -s smatch_output.txt ] && SMATCH_COUNT=$(wc -l < smatch_output.txt)

echo "| Tool | Findings |" >> $GITHUB_STEP_SUMMARY
echo "|------|----------|" >> $GITHUB_STEP_SUMMARY
echo "| Sparse | ${SPARSE_COUNT} |" >> $GITHUB_STEP_SUMMARY
echo "| Smatch | ${SMATCH_COUNT} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

for TOOL in sparse smatch; do
FILE="${TOOL}_output.txt"
if [ -s "$FILE" ]; then
LABEL=$(echo "$TOOL" | sed 's/./\U&/')
echo "### $LABEL Findings" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
head -100 "$FILE" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
done

- name: Upload results
if: always()
uses: actions/upload-artifact@v4

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The actions/upload-artifact action should use a pinned commit hash instead of a version tag for security. The existing workflows in this repository use pinned commit hashes for GitHub Actions to prevent supply chain attacks.

Suggested change
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8

Copilot uses AI. Check for mistakes.
with:
name: sparse-smatch-results
path: |
sparse_output.txt
smatch_output.txt
sparse_raw.txt
smatch_raw.txt