A database connection is opened with an empty password
What it finds
DriverManager.getConnection(url, "admin", "") connects with an empty password, which means the database accepts anyone who can reach it with that user name (CWE-521).
Reported is DriverManager.getConnection with an empty string literal as the password.
From the rule's source, empty_database_password.rs.
import java.sql.Connection;import java.sql.DriverManager; class Db { Connection open(String url, String secret) throws Exception { Connection a = DriverManager.getConnection(url, "admin", "");tx0 reports: empty password return DriverManager.getConnection(url, "admin", secret); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:empty-database-password" = "off"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/java:empty-database-password] reason="..."tx0 explain tx0/java:empty-database-password shows the same in the terminal. Found a false positive? Report it.