Skip to content

Commit 2543cee

Browse files
Copilotfelickz
andcommitted
Address code review feedback: improve credential validation
- Add proper empty string validation using trim() - Add warning when falling back to default password - Improve security by alerting administrators when secure configuration is missing Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 parent 0bb5df8 commit 2543cee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/owasp/benchmark/helpers/LDAPManager.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,16 @@ protected Hashtable<Object, Object> createEnv() {
6262

6363
// Retrieve credentials from environment variable instead of hardcoding
6464
String ldapPassword = System.getenv("LDAP_ADMIN_PASSWORD");
65-
if (ldapPassword == null || ldapPassword.isEmpty()) {
65+
if (ldapPassword == null || ldapPassword.trim().isEmpty()) {
6666
// Fallback to system property for backward compatibility
67-
ldapPassword = System.getProperty("ldap.admin.password", "secret");
67+
ldapPassword = System.getProperty("ldap.admin.password");
68+
if (ldapPassword == null || ldapPassword.trim().isEmpty()) {
69+
// Last resort fallback for test environments only
70+
System.err.println(
71+
"WARNING: Using default LDAP password. "
72+
+ "Set LDAP_ADMIN_PASSWORD environment variable or ldap.admin.password system property for secure configuration.");
73+
ldapPassword = "secret";
74+
}
6875
}
6976
env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
7077

0 commit comments

Comments
 (0)