Skip to content

Commit 6a0167f

Browse files
committed
Convert to using the new DataFlow modules
1 parent 05da1dc commit 6a0167f

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

java/ql/lib/semmle/code/java/security/InsecureLdapAuthQuery.qll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@ import semmle.code.java.security.InsecureLdapAuth
99
/**
1010
* A taint-tracking configuration for `ldap://` URL in LDAP authentication.
1111
*/
12-
class InsecureUrlFlowConfig extends TaintTracking::Configuration {
13-
InsecureUrlFlowConfig() { this = "InsecureLdapAuth:InsecureUrlFlowConfig" }
14-
12+
private module InsecureUrlFlowConfig implements DataFlow::ConfigSig {
1513
/** Source of `ldap://` connection string. */
16-
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof InsecureLdapUrl }
14+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof InsecureLdapUrl }
1715

1816
/** Sink of directory context creation. */
19-
override predicate isSink(DataFlow::Node sink) {
17+
predicate isSink(DataFlow::Node sink) {
2018
exists(ConstructorCall cc |
2119
cc.getConstructedType().getAnAncestor() instanceof TypeDirContext and
2220
sink.asExpr() = cc.getArgument(0)
2321
)
2422
}
2523

2624
/** Method call of `env.put()`. */
27-
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
25+
predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
2826
exists(MethodAccess ma |
2927
pred.asExpr() = ma.getArgument(1) and
3028
isProviderUrlSetter(ma) and
@@ -33,46 +31,48 @@ class InsecureUrlFlowConfig extends TaintTracking::Configuration {
3331
}
3432
}
3533

34+
module InsecureUrlFlowConfiguration = TaintTracking::Make<InsecureUrlFlowConfig>;
35+
3636
/**
3737
* A taint-tracking configuration for `simple` basic-authentication in LDAP configuration.
3838
*/
39-
class BasicAuthFlowConfig extends DataFlow::Configuration {
40-
BasicAuthFlowConfig() { this = "InsecureLdapAuth:BasicAuthFlowConfig" }
41-
39+
private module BasicAuthFlowConfig implements DataFlow::ConfigSig {
4240
/** Source of `simple` configuration. */
43-
override predicate isSource(DataFlow::Node src) {
41+
predicate isSource(DataFlow::Node src) {
4442
exists(MethodAccess ma |
4543
isBasicAuthEnv(ma) and ma.getQualifier() = src.(PostUpdateNode).getPreUpdateNode().asExpr()
4644
)
4745
}
4846

4947
/** Sink of directory context creation. */
50-
override predicate isSink(DataFlow::Node sink) {
48+
predicate isSink(DataFlow::Node sink) {
5149
exists(ConstructorCall cc |
5250
cc.getConstructedType().getAnAncestor() instanceof TypeDirContext and
5351
sink.asExpr() = cc.getArgument(0)
5452
)
5553
}
5654
}
5755

56+
module BasicAuthFlowConfiguration = DataFlow::Make<BasicAuthFlowConfig>;
57+
5858
/**
5959
* A taint-tracking configuration for `ssl` configuration in LDAP authentication.
6060
*/
61-
class SslFlowConfig extends DataFlow::Configuration {
62-
SslFlowConfig() { this = "InsecureLdapAuth:SSLFlowConfig" }
63-
61+
private module SslFlowConfig implements DataFlow::ConfigSig {
6462
/** Source of `ssl` configuration. */
65-
override predicate isSource(DataFlow::Node src) {
63+
predicate isSource(DataFlow::Node src) {
6664
exists(MethodAccess ma |
6765
isSslEnv(ma) and ma.getQualifier() = src.(PostUpdateNode).getPreUpdateNode().asExpr()
6866
)
6967
}
7068

7169
/** Sink of directory context creation. */
72-
override predicate isSink(DataFlow::Node sink) {
70+
predicate isSink(DataFlow::Node sink) {
7371
exists(ConstructorCall cc |
7472
cc.getConstructedType().getAnAncestor() instanceof TypeDirContext and
7573
sink.asExpr() = cc.getArgument(0)
7674
)
7775
}
7876
}
77+
78+
module SslFlowConfiguration = DataFlow::Make<SslFlowConfig>;

java/ql/src/Security/CWE/CWE-522/InsecureLdapAuth.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import java
1515
import semmle.code.java.security.InsecureLdapAuthQuery
1616
import DataFlow::PathGraph
1717

18-
from DataFlow::PathNode source, DataFlow::PathNode sink, InsecureUrlFlowConfig config
18+
from InsecureUrlFlowConfiguration::PathNode source, InsecureUrlFlowConfiguration::PathNode sink
1919
where
20-
config.hasFlowPath(source, sink) and
21-
any(BasicAuthFlowConfig bc).hasFlowTo(sink.getNode()) and
22-
not any(SslFlowConfig sc).hasFlowTo(sink.getNode())
20+
InsecureUrlFlowConfiguration::hasFlowPath(source, sink) and
21+
BasicAuthFlowConfiguration::hasFlowTo(sink.getNode()) and
22+
not SslFlowConfiguration::hasFlowTo(sink.getNode())
2323
select sink.getNode(), source, sink, "Insecure LDAP authentication from $@.", source.getNode(),
2424
"LDAP connection string"

java/ql/test/query-tests/security/CWE-522/InsecureLdapAuthTest.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class InsecureLdapAuthenticationTest extends InlineExpectationsTest {
99

1010
override predicate hasActualResult(Location location, string element, string tag, string value) {
1111
tag = "hasInsecureLdapAuth" and
12-
exists(DataFlow::Node sink, InsecureUrlFlowConfig conf | conf.hasFlowTo(sink) |
13-
any(BasicAuthFlowConfig bc).hasFlowTo(sink) and
14-
not any(SslFlowConfig sc).hasFlowTo(sink) and
12+
exists(DataFlow::Node sink | InsecureUrlFlowConfiguration::hasFlowTo(sink) |
13+
BasicAuthFlowConfiguration::hasFlowTo(sink) and
14+
not SslFlowConfiguration::hasFlowTo(sink) and
1515
sink.getLocation() = location and
1616
element = sink.toString() and
1717
value = ""

0 commit comments

Comments
 (0)