java-db-empty-password-mining
Read-only mining codemod for SonarSource rule java:S2115 — A secure password should be used when connecting to a database.
It scans Java source and emits metrics only; it never modifies code (return null).
Findings are high-signal review candidates surfaced by AST pattern matching — they are
not proven vulnerabilities. A static mining pass cannot prove an end-to-end taint flow
from an untrusted source to the sink, so confirm data flow before remediating.
| Field | Value |
|---|---|
| Rule key | java:S2115 |
| Type | Vulnerability |
| Severity | Blocker |
| Primary CWE | CWE-521 (Weak Password Requirements) |
| Tags | cwe |
What it detects
Database connection APIs invoked with an empty or blank password literal.
Sinks:
DriverManager.getConnection(url, user, "")(andDataSource/Hikari/pool variants)setPassword("")/password("")
Emission rule: Emits when the password argument is an empty or whitespace-only string literal.
Metric: java-db-empty-password-mining
| dimension | meaning |
|---|---|
rule | SonarSource rule key |
cwe | primary CWE identifier |
severity | always blocker |
sink | the detected sink (method/constructor) |
package_name | enclosing Java package |
class_name | enclosing class/interface/enum/record |
method_name | enclosing method/constructor (or <none>) |
file | file path (relative to scan target) |
line | 1-based line of the finding |
arg_kind | always empty_password |
Security standards
- CWE-521 (Weak Password Requirements)
- OWASP ASVS 4.0: 9.2.2, 9.2.3
- OWASP Top 10 2021: A7
- OWASP Top 10: A2, A3
- PCI DSS 3.2: 6.5.10
- PCI DSS 4.0: 6.2.4
Run locally
bash
Part of the java-security-blocker-mining suite covering 19 blocker-severity
Java vulnerability rules. Each codemod is read-only and emits a single named metric.