Skip to content

static-analysis: make cppcheck analyse every source file - #497

Open
yosuke-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/ci-cppcheck
Open

yosuke-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/ci-cppcheck

Conversation

@yosuke-wolfssl

Copy link
Copy Markdown
Contributor

Problem

The cppcheck static-analysis job analysed only 2 of 51 src/*.c files, and was cancelled at its 30-minute timeout in 8 of the last 27 nightlies.

  • CI's cppcheck (2.10, from the bookworm test-deps image) does not read <limits.h>, so UCHAR_MAX is undefined and wolfssl/wolfcrypt/sp_int.h hits #error "Size of unsigned char not detected".
  • Every one of the ~1,300 configurations per file fails on some #error, so cppcheck reports noValidConfiguration ("This file is not analyzed"). The job suppressed that message.
  • Every file that includes alg_funcs.h was skipped. The 25–42 s per file went into building configurations that all fail, which is why the job sat at the timeout while reporting 0 findings.

Fix (.github/workflows/static-analysis.yml)

  • -D*_MAX gives the unix64 integer limits that sp_int.h needs. No wolfProvider #if or code uses these macros.
  • -U__has_include drops the one configuration cppcheck 2.10 cannot evaluate. The fallback branch defines the same WP_*_HEADER macros.
  • --config-exclude on the OpenSSL and wolfSSL include dirs stops library #ifdefs from multiplying configurations. --force still checks all of wolfProvider's own.
  • -j "$(nproc)" runs the files in parallel.
  • noValidConfiguration is no longer suppressed. The step fails and lists any file cppcheck could not analyse.

Verification

Run locally in debian:bookworm with cppcheck 2.10 and the same OpenSSL/wolfSSL as CI:

Before After
Files analysed 2 / 51 51 / 51
Planted out-of-bounds read in wp_rsa_kmgmt.c missed caught
Wall time, -j 4 — 8.8 min (same findings as single-threaded)
src/ findings 0 0 errors, 5 warnings
  • Removing the -D lines makes the step fail and list the 49 files.

Not in this PR: upgrading cppcheck in the test-deps image, after which the -D/-U workaround can go, and a wp_dec_pem2der.c failure-path issue the now-working check reports.

@yosuke-wolfssl yosuke-wolfssl self-assigned this Oct 2, 2026
Copilot AI balanced review requested due to automatic review settings October 2, 2026 07:16
@yosuke-wolfssl yosuke-wolfssl added the ci:all PR OSP toggle: run all label Oct 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

cppcheck execution failures are still suppressed, allowing false-successful analysis runs.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Improves cppcheck coverage and reliability across all provider source files.

Changes:

  • Adds cppcheck compatibility definitions and parallel analysis.
  • Fails when files have no valid configuration.
  • Documents the updated failure behavior.
File Description
.github/​workflows/​static-analysis.yml Expands cppcheck coverage and detects skipped files.
.github/​workflows/​README.md Documents cppcheck failure conditions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/static-analysis.yml
- cppcheck defines the unix64 integer limits, undefines
  __has_include, and excludes the OpenSSL and wolfSSL include
  directories from configuration checking.
- cppcheck runs with -j  and --cppcheck-build-dir in a
  fresh cppcheck-build directory.
- noValidConfiguration is no longer suppressed or filtered from the
  displayed output; the step fails and lists any file cppcheck could
  not analyse.
- cppcheck's exit status is saved to cppcheck-rc.txt, and the step
  fails when it is non-zero.
- The workflows README lists both failure conditions, and adds a
  troubleshooting row for a file cppcheck cannot analyse.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #497

No scan targets match the changed files in this PR. Review skipped.

@yosuke-wolfssl yosuke-wolfssl added ci:all PR OSP toggle: run all and removed ci:all PR OSP toggle: run all labels Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:all PR OSP toggle: run all

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants