Skip to content

ci: add native CodeQL scans - #854

Merged
Youw merged 7 commits into
masterfrom
add-codeql-scans
Nov 15, 2026
Merged

Youw merged 7 commits into
masterfrom
add-codeql-scans

Conversation

@Youw

@Youw Youw commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Add a dedicated CodeQL workflow with one Release library build per platform. Scan every push to master, weekly, on manual dispatch, and on PRs carrying ci-codeql, including when the label is added. Superseded PR scans are canceled; master scans are preserved.

Use default C/C++ queries and separate platform categories, with current major action refs (checkout@v7, codeql-action@v4, setup-msvc-dev@v4). Select macOS 15/Xcode 16.4 for supported tracing. Explicit full-database mode avoids the manual-build overlay warning; native Java access avoids the Windows JNI warning.

The existing build workflow and README are unchanged. CodeQL builds only the libraries, without test or packaging variants.

Both the manual full scan and label-gated PR scan passed on the final commit:

Platform Full scan job PR scan job Library sources traced
Linux 1m11s 1m09s linux/hid.c, libusb/hid.c
Windows 1m40s 1m55s windows/hid.c, windows/hidapi_descriptor_reconstruct.c
macOS 3m17s 3m34s mac/hid.c

Times exclude queueing and are single pilot measurements. The full scan used 6m08s of aggregate runner time. Jobs run in parallel with ordinary CI; the PR scan finished about 40 seconds after GitHub Builds in this pilot, so waiting for all checks can still take longer.

Validation: clean actionlint, 11 event/label checks, successful existing CI, and no build warnings in the six final CodeQL job logs. All three full analyses uploaded 58 rules with empty error/warning fields. The full Linux scan reports one existing cpp/comparison-with-wider-type finding at libusb/hid.c:588; Windows and macOS report none. The finding remains available for separate triage.

Coverage is limited to the selected native library builds; tests, examples, BSD-specific code and inactive preprocessor branches are outside this scan. Scheduled/default-branch triggers take effect after merge.

Fixes #596

Related to libusb/libusb#1294, the reference workflow linked by #596.

Assisted-by: Codex:GPT-6

Youw added 5 commits November 16, 2026 01:01
Reuse Linux, Windows and macOS CMake builds for CodeQL on master pushes,
weekly schedules, manual dispatch and pull requests labelled ci-codeql.
Keep other branch and unlabelled pull-request builds free of scan overhead.

Fixes #596

Assisted-by: Codex:GPT-6
Keep CMake package consumers on arm64 when CodeQL launches tools through
Rosetta. Remove the README explanation as requested.

Assisted-by: Codex:GPT-6
Keep the existing check names for pushes and ordinary pull request events.
Prefix scan-only checks so skipped jobs cannot replace required CI results.

Assisted-by: Codex:GPT-6
Run tracing after the normal checks and capture a clean rebuild of the
configured native targets. This retains source coverage without carrying
tracing overhead into the remaining compiler and packaging checks.

Assisted-by: Codex:GPT-6
Scan one Release library build on Linux, Windows and macOS in parallel
with ordinary CI. Keep master-push, weekly and manual scans, and gate
pull-request scans on ci-codeql. Restore the ordinary build workflow.

Assisted-by: Codex:GPT-6
@Youw Youw added the ci-codeql Triggers CodeQL scan label Nov 15, 2026
Apply concurrency after the job's label gate so skipped label events
cannot cancel a scan, while opened and labelled events share one scan.

Assisted-by: Codex:GPT-6
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Use checkout v7 while retaining current major tags for CodeQL and MSVC
setup. Disable unsupported overlays for manual C/C++ builds and enable
the JNI native access used by CodeQL's Windows path resolver.

Assisted-by: Codex:GPT-6
@Youw
Youw marked this pull request as ready for review November 15, 2026 23:46
@Youw
Youw merged commit 3b99c04 into master Nov 15, 2026
37 checks passed
@Youw
Youw deleted the add-codeql-scans branch November 15, 2026 23:57
Youw added a commit that referenced this pull request Nov 16, 2026
Use int for the get_path loop index to match num_ports. The eight-entry
libusb buffer already bounds the count, so path formatting and error
handling remain unchanged while CodeQL's narrow/wide comparison is removed.

Addresses https://github.com/libusb/hidapi/security/code-scanning/1
Related to #854 and #596.

Assisted-by: Codex:GPT-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-codeql Triggers CodeQL scan

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CodeQL checks

2 participants