Pilot: C/C++ microcontroller SAST (cppcheck, CRA C rules, vendor excludes, no silent semgrep failures) #334

Closed
opened 2026-09-23 10:32:57 +00:00 by sharang · 0 comments
Owner

Part of the pilot epic. P0, before the pilot starts on 2026-09-30.

The first pilot customer brings C/C++ microcontroller firmware source. Today such code gets almost no SAST:

  • the only rule source is semgrep --config=auto, and our CRA rule pack (compliance-agent/rules/cra_semgrep.yaml) covers Python and JS only;
  • there is no C analyzer in the image;
  • no nightly fixture has ever produced a C finding;
  • semgrep timeouts and errors are only logged (orchestrator.rs, semgrep.rs), so a failed SAST reads as a clean scan;
  • vendor SDK trees (HAL, CMSIS, middleware) are scanned in full.

Scope

  • Add cppcheck to the agent image. A pipeline/cppcheck.rs scanner turns its XML v2 output into Finding rows with CWE, file:line and a mapped severity. It runs only on C/C++ trees, with -j2 and a timeout, and a failure is recorded as a skipped stage.
  • Add C/C++ rules with CRA refs to our semgrep pack: banned unsafe calls (gets, strcpy, strcat, sprintf, scanf("%s")), format-string sinks, hard-coded credentials and keys, weak crypto, and rand() used for security.
  • Exclude vendor code from SAST by default (Drivers/, CMSIS/, Middlewares/Third_Party/, and the like), and list the exclusions on the scan run. The SBOM still covers that code.
  • Semgrep runs with --jobs 2, and a timeout or error becomes a skipped stage.
  • Add a nightly fixture: a microcontroller project with planted flaws, whose baseline asserts the rule ids exactly.
Part of the pilot epic. P0, before the pilot starts on 2026-09-30. The first pilot customer brings C/C++ microcontroller firmware source. Today such code gets almost no SAST: - the only rule source is `semgrep --config=auto`, and our CRA rule pack (`compliance-agent/rules/cra_semgrep.yaml`) covers Python and JS only; - there is no C analyzer in the image; - no nightly fixture has ever produced a C finding; - semgrep timeouts and errors are only logged (`orchestrator.rs`, `semgrep.rs`), so a failed SAST reads as a clean scan; - vendor SDK trees (HAL, CMSIS, middleware) are scanned in full. **Scope** - Add **cppcheck** to the agent image. A `pipeline/cppcheck.rs` scanner turns its XML v2 output into `Finding` rows with CWE, file:line and a mapped severity. It runs only on C/C++ trees, with `-j2` and a timeout, and a failure is recorded as a skipped stage. - Add **C/C++ rules with CRA refs** to our semgrep pack: banned unsafe calls (`gets`, `strcpy`, `strcat`, `sprintf`, `scanf("%s")`), format-string sinks, hard-coded credentials and keys, weak crypto, and `rand()` used for security. - **Exclude vendor code from SAST by default** (`Drivers/`, `CMSIS/`, `Middlewares/Third_Party/`, and the like), and list the exclusions on the scan run. The SBOM still covers that code. - Semgrep runs with `--jobs 2`, and a timeout or error becomes a skipped stage. - Add a **nightly fixture**: a microcontroller project with planted flaws, whose baseline asserts the rule ids exactly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/pruefwerk#334