Closes#380. Stacked on #392, which is stacked on #391; it merges after them.
The C/C++ non-literal format-string rule fired on sprintf(buf, GET_REQUEST) when GET_REQUEST is a macro such as #define GET_REQUEST "GET / HTTP/1.1\r\n\r\n". Seen in anon767/STM32F7HTTPS. A macro like that expands to a literal, so it is a false positive.
Change
Rule cra-ai-20-c-non-literal-format-string: the format argument must now be neither a literal nor an upper-case macro name (^(?![A-Z][A-Z0-9_]*$)[^"]).
Still flagged:printf(user_fmt), printf(msg), snprintf(buf, 8, fmt_table[2]).
No longer flagged:sprintf(buf, GET_REQUEST), printf(LOG_FMT, msg).
Nightly
c-sensor-node/Core/Src/cli.cpp gets a std::printf(STATUS_FMT, state) call after its existing lines, so the baseline lines don't move. It must stay silent. semgrep over the fixture gives exactly the baseline's findings.
Checked
semgrep --validate on the rule pack; a before/after run on a sample with each case.
Closes #380. Stacked on #392, which is stacked on #391; it merges after them.
The C/C++ non-literal format-string rule fired on `sprintf(buf, GET_REQUEST)` when `GET_REQUEST` is a macro such as `#define GET_REQUEST "GET / HTTP/1.1\r\n\r\n"`. Seen in `anon767/STM32F7HTTPS`. A macro like that expands to a literal, so it is a false positive.
## Change
- **Rule `cra-ai-20-c-non-literal-format-string`:** the format argument must now be neither a literal nor an upper-case macro name (`^(?![A-Z][A-Z0-9_]*$)[^"]`).
- **Still flagged:** `printf(user_fmt)`, `printf(msg)`, `snprintf(buf, 8, fmt_table[2])`.
- **No longer flagged:** `sprintf(buf, GET_REQUEST)`, `printf(LOG_FMT, msg)`.
## Nightly
`c-sensor-node/Core/Src/cli.cpp` gets a `std::printf(STATUS_FMT, state)` call after its existing lines, so the baseline lines don't move. It must stay silent. semgrep over the fixture gives exactly the baseline's findings.
## Checked
`semgrep --validate` on the rule pack; a before/after run on a sample with each case.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang
changed target branch from feat/define-credentials to main2026-09-25 11:16:40 +00:00
`sprintf(buf, GET_REQUEST)` with GET_REQUEST defined as a string literal
was reported as an externally controlled format string. Upper-case
macro names are now treated as constant formats; the nightly C++
fixture carries such a call, which must stay silent.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang
merged commit a3cfaf422f into main2026-09-25 11:27:23 +00:00
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 #380. Stacked on #392, which is stacked on #391; it merges after them.
The C/C++ non-literal format-string rule fired on
sprintf(buf, GET_REQUEST)whenGET_REQUESTis a macro such as#define GET_REQUEST "GET / HTTP/1.1\r\n\r\n". Seen inanon767/STM32F7HTTPS. A macro like that expands to a literal, so it is a false positive.Change
cra-ai-20-c-non-literal-format-string: the format argument must now be neither a literal nor an upper-case macro name (^(?![A-Z][A-Z0-9_]*$)[^"]).printf(user_fmt),printf(msg),snprintf(buf, 8, fmt_table[2]).sprintf(buf, GET_REQUEST),printf(LOG_FMT, msg).Nightly
c-sensor-node/Core/Src/cli.cppgets astd::printf(STATUS_FMT, state)call after its existing lines, so the baseline lines don't move. It must stay silent. semgrep over the fixture gives exactly the baseline's findings.Checked
semgrep --validateon the rule pack; a before/after run on a sample with each case.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p