A password or secret is written into the source as a string literal
What it finds
const char *password = "hunter2";: a secret in the source is in every copy of the code and the binary, cannot be changed without a release, and is the same for every installation. Read it from the environment, a file or a secret store.
The variable or field must be named for a password or secret, and the literal look like one: at least four characters, without spaces, format directives or a trailing colon, which prompts and labels have.
From the rule's source, hardcoded_password.rs.
struct login { const char *user; const char *password; }; void fill(struct login *l){ const char *db_password = "hunter22";tx0 reports: db_password is given a literal secret const char *password_prompt = "Password:"; l->password = "s3cr3t!x";tx0 reports: password is given a literal secret l->user = "admin"; (void)db_password; (void)password_prompt;} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:hardcoded-password" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/c:hardcoded-password] reason="..."tx0 explain tx0/c:hardcoded-password shows the same in the terminal. Found a false positive? Report it.