fix(sast): an upper-case format macro is not a non-literal format (#380)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 9m20s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 9m20s
`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
This commit is contained in:
1 parent
aee2f5b9eb
commit
a9fa64314d
2 files changed
+10
-1
No files matched your search
@@ -171,9 +171,11 @@ rules:
|
||||
- pattern: std::fprintf($F, $FMT, ...)
|
||||
- pattern: std::sprintf($B, $FMT, ...)
|
||||
- pattern: std::snprintf($B, $N, $FMT, ...)
|
||||
# Not a literal, and not an upper-case macro (`#define GET_REQUEST
|
||||
# "GET / HTTP/1.1"`): a macro like that expands to a literal.
|
||||
- metavariable-regex:
|
||||
metavariable: $FMT
|
||||
regex: ^[^"]
|
||||
regex: ^(?![A-Z][A-Z0-9_]*$)[^"]
|
||||
|
||||
- id: cra-ai-8-c-hardcoded-credential
|
||||
languages: [c, cpp]
|
||||
|
||||
@@ -20,3 +20,10 @@ void status(const char* state) {
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
// A format macro expands to a literal: not a finding (#380).
|
||||
#define STATUS_FMT "state: %s\n"
|
||||
|
||||
void status_line(const char* state) {
|
||||
std::printf(STATUS_FMT, state);
|
||||
}
|
||||
Reference in new issue
Block a user