Our CRA rules for C were languages: [c], so semgrep never applied them to C++ sources (.cpp, .cc, .hpp), and C++ application code only got cppcheck. They now run on both.
The six C rules are languages: [c, cpp]: unbounded string functions, scanf("%s"), non-literal format strings, hard-coded credentials, broken hash/cipher, rand().
They also catch the std:: spellings C++ uses: std::sprintf, std::printf(fmt), std::snprintf and so on.
Tried with semgrep 1.154 on a C++ sample with one line per rule, the std:: forms and a std::string credential. Every planted line fires; std::printf("%s\n", …), snprintf and std::string::append stay quiet.
Control map: the four semgrep bindings with C rules (cra-ai-8, 13, 16, 20) now list cpp, so a C++ target counts as checked for them on the CRA status.
Guard against drift: a new test reads the rule pack and fails if a control-map binding claims fewer languages than its rules run on.
Nightly fixture:c-sensor-node gains Core/Src/cli.cpp, a small C++ service console with three planted flaws (a std::string credential, std::sprintf, a non-literal std::printf) and one clean call.
Its baseline adds exactly those three semgrep findings.
cppcheck 2.10, the agent image's Debian bookworm version, run with the agent's flags, finds nothing new in cli.cpp and still exactly the three baseline findings in sensors.c.
The Makefile is unchanged, so the SBOM baseline stays the same.
Checked
cargo fmt --all --check.
clippy with the CI flags for compliance-agent.
Tests: agent semgrep tests, including the new drift check; control-map (C++ counts for memory safety).
Closes #373.
Our CRA rules for C were `languages: [c]`, so semgrep never applied them to C++ sources (`.cpp`, `.cc`, `.hpp`), and C++ application code only got cppcheck. They now run on both.
## Changes
- **Rule pack** (`compliance-agent/rules/cra_semgrep.yaml`):
- The six C rules are `languages: [c, cpp]`: unbounded string functions, `scanf("%s")`, non-literal format strings, hard-coded credentials, broken hash/cipher, `rand()`.
- They also catch the `std::` spellings C++ uses: `std::sprintf`, `std::printf(fmt)`, `std::snprintf` and so on.
- Tried with semgrep 1.154 on a C++ sample with one line per rule, the `std::` forms and a `std::string` credential. Every planted line fires; `std::printf("%s\n", …)`, `snprintf` and `std::string::append` stay quiet.
- **Control map:** the four semgrep bindings with C rules (cra-ai-8, 13, 16, 20) now list `cpp`, so a C++ target counts as checked for them on the CRA status.
- **Guard against drift:** a new test reads the rule pack and fails if a control-map binding claims fewer languages than its rules run on.
- **Nightly fixture:** `c-sensor-node` gains `Core/Src/cli.cpp`, a small C++ service console with three planted flaws (a `std::string` credential, `std::sprintf`, a non-literal `std::printf`) and one clean call.
- Its baseline adds exactly those three semgrep findings.
- cppcheck 2.10, the agent image's Debian bookworm version, run with the agent's flags, finds nothing new in `cli.cpp` and still exactly the three baseline findings in `sensors.c`.
- The Makefile is unchanged, so the SBOM baseline stays the same.
## Checked
- `cargo fmt --all --check`.
- clippy with the CI flags for compliance-agent.
- Tests: agent semgrep tests, including the new drift check; control-map (C++ counts for memory safety).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
The C rules were semgrep `languages: [c]`, so C++ application code only
got cppcheck. They now run on C and C++, including the std:: spellings;
the control map says so, a test keeps the map and the rule pack in
step, and the nightly C fixture gains a C++ module with three planted
flaws.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #373.
Our CRA rules for C were
languages: [c], so semgrep never applied them to C++ sources (.cpp,.cc,.hpp), and C++ application code only got cppcheck. They now run on both.Changes
compliance-agent/rules/cra_semgrep.yaml):languages: [c, cpp]: unbounded string functions,scanf("%s"), non-literal format strings, hard-coded credentials, broken hash/cipher,rand().std::spellings C++ uses:std::sprintf,std::printf(fmt),std::snprintfand so on.std::forms and astd::stringcredential. Every planted line fires;std::printf("%s\n", …),snprintfandstd::string::appendstay quiet.cpp, so a C++ target counts as checked for them on the CRA status.c-sensor-nodegainsCore/Src/cli.cpp, a small C++ service console with three planted flaws (astd::stringcredential,std::sprintf, a non-literalstd::printf) and one clean call.cli.cppand still exactly the three baseline findings insensors.c.Checked
cargo fmt --all --check.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p