Query to detect LDAP injections in Java

Cleanup
This commit is contained in:
Grzegorz Golawski
2020-01-18 20:21:38 +01:00
parent 95723b08e1
commit 00ee3d2549
5 changed files with 18 additions and 22 deletions

View File

@@ -6,7 +6,6 @@ import semmle.code.java.frameworks.UnboundId
import semmle.code.java.frameworks.SpringLdap
import semmle.code.java.frameworks.ApacheLdap
/** Holds if the parameter of `c` at index `paramIndex` is varargs. */
bindingset[paramIndex]
predicate isVarargs(Callable c, int paramIndex) {
@@ -129,18 +128,15 @@ class SpringLdapInjectionSink extends LdapInjectionSink {
) and
(
// Parameter index is 1 (DN or query) or 2 (filter) if method is not authenticate
(
index in [0 .. 1] and
not m instanceof MethodSpringLdapTemplateAuthenticate
) or
or
// But it's not the last parameter in case of authenticate method (last param is password)
(
index in [0 .. 1] and
index < m.getNumberOfParameters() - 1 and
m instanceof MethodSpringLdapTemplateAuthenticate
)
)
)
}
}

View File

@@ -23,7 +23,5 @@ class TypeApacheSearchRequest extends Interface {
/** The class `org.apache.directory.api.ldap.model.name.Dn`. */
class TypeApacheDn extends Class {
TypeApacheDn() {
this.hasQualifiedName("org.apache.directory.api.ldap.model.name", "Dn")
}
TypeApacheDn() { this.hasQualifiedName("org.apache.directory.api.ldap.model.name", "Dn") }
}

View File

@@ -9,7 +9,9 @@ import semmle.code.java.Member
/*--- Types ---*/
/** The class `org.springframework.ldap.core.LdapTemplate`. */
class TypeSpringLdapTemplate extends Class {
TypeSpringLdapTemplate() { this.hasQualifiedName("org.springframework.ldap.core", "LdapTemplate") }
TypeSpringLdapTemplate() {
this.hasQualifiedName("org.springframework.ldap.core", "LdapTemplate")
}
}
/** The class `org.springframework.ldap.query.LdapQueryBuilder`. */