Closes#374. Stacked on #391 (C rules on C++); it merges after #391.
The hard-coded credential rule for C only matched variable initialisers (const char *password = "..."). The usual embedded style, a macro in a config header (#define WIFI_PASS "..."), went unnoticed, so most ESP-IDF and STM32 projects gave no hits. semgrep's structural C patterns do not see preprocessor lines (tried: no match, no error).
Changes (cra-ai-8-c-hardcoded-credential, same rule id)
#define lines: a pattern-regex alternative matches #define NAME "value" in C and C++ sources and headers. Its named groups feed the same $NAME / $VALUE checks as the variable patterns. Keeping one rule id means the control map, the triage and the baselines need no change.
Credential names:PASS now counts on its own as well (WIFI_PASS, MQTT_PASS), besides passw/pwd/secret/api_key/token/psk/credential.
Placeholders are ignored, for variables too: changeme, password, secret, admin, xxx…, YOUR_…, <…> and ***. Values under six characters are still not reported.
Tried with semgrep 1.154:
Flagged:WIFI_PASS "Zebra-4711-x", PSK "a8f5…", DEVICE_PWD_DEFAULT "admin123" (in .h and .hpp), and wifi_password = "hunter2hunter2".
c-sensor-node gains Core/Inc/net_config.h: MQTT_PASSWORD "sensor-Mq77!" is reported (baseline net_config.h:7), and the placeholder OTA_TOKEN "changeme" is not. The fixture's existing findings are unchanged.
Checked
semgrep --validate on the rule pack; agent semgrep tests, including the control-map language check.
Closes #374. Stacked on #391 (C rules on C++); it merges after #391.
The hard-coded credential rule for C only matched variable initialisers (`const char *password = "..."`). The usual embedded style, a macro in a config header (`#define WIFI_PASS "..."`), went unnoticed, so most ESP-IDF and STM32 projects gave no hits. semgrep's structural C patterns do not see preprocessor lines (tried: no match, no error).
## Changes (`cra-ai-8-c-hardcoded-credential`, same rule id)
- **`#define` lines:** a `pattern-regex` alternative matches `#define NAME "value"` in C and C++ sources and headers. Its named groups feed the same `$NAME` / `$VALUE` checks as the variable patterns. Keeping one rule id means the control map, the triage and the baselines need no change.
- **Credential names:** `PASS` now counts on its own as well (`WIFI_PASS`, `MQTT_PASS`), besides passw/pwd/secret/api_key/token/psk/credential.
- **Placeholders are ignored,** for variables too: `changeme`, `password`, `secret`, `admin`, `xxx…`, `YOUR_…`, `<…>` and `***`. Values under six characters are still not reported.
Tried with semgrep 1.154:
- **Flagged:** `WIFI_PASS "Zebra-4711-x"`, `PSK "a8f5…"`, `DEVICE_PWD_DEFAULT "admin123"` (in `.h` and `.hpp`), and `wifi_password = "hunter2hunter2"`.
- **Not flagged:** `WIFI_SSID`, `MQTT_PASSWORD "changeme"`, `API_KEY "YOUR_API_KEY"`, `TOKEN ""`, `SECRET_LEN 32`, `mqtt_passwd[] = "changeme"`, `compass_heading = "north-east"`.
## Nightly
`c-sensor-node` gains `Core/Inc/net_config.h`: `MQTT_PASSWORD "sensor-Mq77!"` is reported (baseline `net_config.h:7`), and the placeholder `OTA_TOKEN "changeme"` is not. The fixture's existing findings are unchanged.
## Checked
`semgrep --validate` on the rule pack; agent semgrep tests, including the control-map language check.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
The C credential rule only matched variable initialisers, so the usual
`#define WIFI_PASS "..."` in a config header went unnoticed. A regex
alternative now covers #define lines in C and C++, PASS counts as a
credential name, and placeholders (changeme, YOUR_..., xxx) are
ignored. The nightly C fixture gains a config header with one real and
one placeholder credential.
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 #374. Stacked on #391 (C rules on C++); it merges after #391.
The hard-coded credential rule for C only matched variable initialisers (
const char *password = "..."). The usual embedded style, a macro in a config header (#define WIFI_PASS "..."), went unnoticed, so most ESP-IDF and STM32 projects gave no hits. semgrep's structural C patterns do not see preprocessor lines (tried: no match, no error).Changes (
cra-ai-8-c-hardcoded-credential, same rule id)#definelines: apattern-regexalternative matches#define NAME "value"in C and C++ sources and headers. Its named groups feed the same$NAME/$VALUEchecks as the variable patterns. Keeping one rule id means the control map, the triage and the baselines need no change.PASSnow counts on its own as well (WIFI_PASS,MQTT_PASS), besides passw/pwd/secret/api_key/token/psk/credential.changeme,password,secret,admin,xxx…,YOUR_…,<…>and***. Values under six characters are still not reported.Tried with semgrep 1.154:
WIFI_PASS "Zebra-4711-x",PSK "a8f5…",DEVICE_PWD_DEFAULT "admin123"(in.hand.hpp), andwifi_password = "hunter2hunter2".WIFI_SSID,MQTT_PASSWORD "changeme",API_KEY "YOUR_API_KEY",TOKEN "",SECRET_LEN 32,mqtt_passwd[] = "changeme",compass_heading = "north-east".Nightly
c-sensor-nodegainsCore/Inc/net_config.h:MQTT_PASSWORD "sensor-Mq77!"is reported (baselinenet_config.h:7), and the placeholderOTA_TOKEN "changeme"is not. The fixture's existing findings are unchanged.Checked
semgrep --validateon the rule pack; agent semgrep tests, including the control-map language check.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
0305b8cf7eto5a5d7d11ee