Skip to content

Commit e698ee7

Browse files
committed
Update qldoc and test method
1 parent 5ce3af0 commit e698ee7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

java/ql/src/experimental/Security/CWE/CWE-297/InsecureLdapEndpoint.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
<overview>
77
<p>Java versions 8u181 or greater have enabled LDAPS endpoint identification by default. Nowadays infrastructure services like LDAP are commonly deployed behind load balancers therefore the LDAP server name can be different from the FQDN of the LDAPS endpoint. If a service certificate does not properly contain a matching DNS name as part of the certificate, Java will reject it by default.</p>
8-
<p>Instead of addressing the issue properly by having a compliant certificate deployed, frequently developers simply disable LDAPS endpoint check.</p>
9-
<p>Failing to validate the certificate makes the SSL session susceptible to a man-in-the-middle attack. This query checks whether LDAPS endpoint check is disabled in system properties.</p>
8+
<p>Instead of addressing the issue properly by having a compliant certificate deployed, frequently developers simply disable the LDAPS endpoint check.</p>
9+
<p>Failing to validate the certificate makes the SSL session susceptible to a man-in-the-middle attack. This query checks whether the LDAPS endpoint check is disabled in system properties.</p>
1010
</overview>
1111

1212
<recommendation>

java/ql/src/experimental/Security/CWE/CWE-297/InsecureLdapEndpoint.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ class SetPropertyMethod extends Method {
3232
}
3333
}
3434

35-
/** The method to set system properties. */
35+
/** The `setProperties` method declared in `java.lang.System`. */
3636
class SetSystemPropertiesMethod extends Method {
3737
SetSystemPropertiesMethod() {
3838
this.hasName("setProperties") and
3939
this.getDeclaringType().hasQualifiedName("java.lang", "System")
4040
}
4141
}
4242

43-
/** Holds if an expression is evaluated to the string literal `com.sun.jndi.ldap.object.disableEndpointIdentification`. */
43+
/** Holds if `expr` is evaluated to the string literal `com.sun.jndi.ldap.object.disableEndpointIdentification`. */
4444
predicate isPropertyDisableLdapEndpointId(Expr expr) {
4545
expr.(CompileTimeConstantExpr).getStringValue() =
4646
"com.sun.jndi.ldap.object.disableEndpointIdentification"
@@ -72,7 +72,8 @@ predicate isBooleanTrue(Expr expr) {
7272

7373
/** Holds if `ma` is in a test class or method. */
7474
predicate isTestMethod(MethodAccess ma) {
75-
ma.getMethod() instanceof TestMethod or
75+
ma.getEnclosingCallable() instanceof TestMethod or
76+
ma.getEnclosingCallable().getDeclaringType() instanceof TestClass or
7677
ma.getEnclosingCallable().getDeclaringType().getPackage().getName().matches("%test%") or
7778
ma.getEnclosingCallable().getDeclaringType().getName().toLowerCase().matches("%test%")
7879
}

0 commit comments

Comments
 (0)