A password, secret or token is written in the code
What it finds
val password = "hunter2" puts the credential into the source, the history and every build, where it cannot be rotated without a release. Credentials belong in configuration or a secret store. Reported for properties and variables whose name says password, secret, token or key for an API, initialized with a non-empty literal string that has no spaces; tests often use such values on purpose.
From the rule's source, hardcoded_credential.rs.
object Config { const val DB_PASSWORD = "s3cr3t-Value"tx0 reports: DB_PASSWORD holds a credential written in the code val apiKey = "AKIA1234567890ABCD"tx0 reports: apiKey holds a credential val passwordField = "password" val password = "" val token = System.getenv("TOKEN") val passwordHint = "your-password"} 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/kotlin:hardcoded-credential" = "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/kotlin:hardcoded-credential] reason="..."tx0 explain tx0/kotlin:hardcoded-credential shows the same in the terminal. Found a false positive? Report it.