Skip to content

Commit 0589dd7

Browse files
committed
Move Jndi.qll from experimental
1 parent 0c1fe9b commit 0589dd7

File tree

4 files changed

+39
-42
lines changed

4 files changed

+39
-42
lines changed

java/ql/src/experimental/semmle/code/java/frameworks/Jndi.qll

Lines changed: 0 additions & 33 deletions
This file was deleted.

java/ql/src/semmle/code/java/JMX.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,20 @@ class JMXRegistrationMethod extends Method {
8686
)
8787
}
8888
}
89+
90+
/** The class `javax.management.remote.JMXConnectorFactory`. */
91+
class TypeJMXConnectorFactory extends Class {
92+
TypeJMXConnectorFactory() {
93+
this.hasQualifiedName("javax.management.remote", "JMXConnectorFactory")
94+
}
95+
}
96+
97+
/** The class `javax.management.remote.JMXServiceURL`. */
98+
class TypeJMXServiceURL extends Class {
99+
TypeJMXServiceURL() { this.hasQualifiedName("javax.management.remote", "JMXServiceURL") }
100+
}
101+
102+
/** The class `javax.management.remote.rmi.RMIConnector`. */
103+
class TypeRMIConnector extends Class {
104+
TypeRMIConnector() { this.hasQualifiedName("javax.management.remote.rmi", "RMIConnector") }
105+
}

java/ql/src/semmle/code/java/frameworks/Jndi.qll

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
/**
2-
* Provides classes and predicates for working with the Java JDBC API.
2+
* Provides classes and predicates for working with the Java JNDI API.
33
*/
44

55
import java
66
import semmle.code.java.Type
77
import semmle.code.java.Member
88

99
/*--- Types ---*/
10+
/** The interface `javax.naming.Context`. */
11+
class TypeNamingContext extends Interface {
12+
TypeNamingContext() { this.hasQualifiedName("javax.naming", "Context") }
13+
}
14+
15+
/** The class `javax.naming.CompositeName`. */
16+
class TypeCompositeName extends Class {
17+
TypeCompositeName() { this.hasQualifiedName("javax.naming", "CompositeName") }
18+
}
19+
20+
/** The class `javax.naming.CompoundName`. */
21+
class TypeCompoundName extends Class {
22+
TypeCompoundName() { this.hasQualifiedName("javax.naming", "CompoundName") }
23+
}
24+
1025
/** The interface `javax.naming.directory.DirContext`. */
1126
class TypeDirContext extends Interface {
1227
TypeDirContext() { this.hasQualifiedName("javax.naming.directory", "DirContext") }

java/ql/src/semmle/code/java/security/JndiInjection.qll

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/** Provides classes to reason about JNDI injection vulnerabilities. */
22

33
import java
4+
import semmle.code.java.dataflow.DataFlow
45
import semmle.code.java.dataflow.ExternalFlow
5-
import semmle.code.java.dataflow.FlowSources
6-
import experimental.semmle.code.java.frameworks.Jndi
6+
import semmle.code.java.frameworks.Jndi
77
import semmle.code.java.frameworks.SpringLdap
8-
import DataFlow
98

109
/** A data flow sink for unvalidated user input that is used in JNDI lookup. */
1110
abstract class JndiInjectionSink extends DataFlow::Node { }
@@ -82,7 +81,6 @@ private class DefaultJndiInjectionSinkModel extends SinkModelCsv {
8281
override predicate row(string row) {
8382
row =
8483
[
85-
// JDK
8684
"javax.naming;InitialContext;true;lookup;;;Argument[0];jndi-injection",
8785
"javax.naming;InitialContext;true;lookupLink;;;Argument[0];jndi-injection",
8886
"javax.naming;InitialContext;true;doLookup;;;Argument[0];jndi-injection",
@@ -143,7 +141,7 @@ private class DefaultJndiInjectionAdditionalTaintStep extends JndiInjectionAddit
143141
* Holds if `n1` to `n2` is a dataflow step that converts between `String` and `CompositeName` or
144142
* `CompoundName`, i.e. `new CompositeName(tainted)` or `new CompoundName(tainted)`.
145143
*/
146-
private predicate nameStep(ExprNode n1, ExprNode n2) {
144+
private predicate nameStep(DataFlow::ExprNode n1, DataFlow::ExprNode n2) {
147145
exists(ConstructorCall cc |
148146
cc.getConstructedType() instanceof TypeCompositeName or
149147
cc.getConstructedType() instanceof TypeCompoundName
@@ -157,7 +155,7 @@ private predicate nameStep(ExprNode n1, ExprNode n2) {
157155
* Holds if `n1` to `n2` is a dataflow step that converts between `String` and `JMXServiceURL`,
158156
* i.e. `new JMXServiceURL(tainted)`.
159157
*/
160-
private predicate jmxServiceUrlStep(ExprNode n1, ExprNode n2) {
158+
private predicate jmxServiceUrlStep(DataFlow::ExprNode n1, DataFlow::ExprNode n2) {
161159
exists(ConstructorCall cc | cc.getConstructedType() instanceof TypeJMXServiceURL |
162160
n1.asExpr() = cc.getAnArgument() and
163161
n2.asExpr() = cc
@@ -168,7 +166,7 @@ private predicate jmxServiceUrlStep(ExprNode n1, ExprNode n2) {
168166
* Holds if `n1` to `n2` is a dataflow step that converts between `JMXServiceURL` and
169167
* `JMXConnector`, i.e. `JMXConnectorFactory.newJMXConnector(tainted)`.
170168
*/
171-
private predicate jmxConnectorStep(ExprNode n1, ExprNode n2) {
169+
private predicate jmxConnectorStep(DataFlow::ExprNode n1, DataFlow::ExprNode n2) {
172170
exists(MethodAccess ma, Method m | n1.asExpr() = ma.getArgument(0) and n2.asExpr() = ma |
173171
ma.getMethod() = m and
174172
m.getDeclaringType() instanceof TypeJMXConnectorFactory and
@@ -180,7 +178,7 @@ private predicate jmxConnectorStep(ExprNode n1, ExprNode n2) {
180178
* Holds if `n1` to `n2` is a dataflow step that converts between `JMXServiceURL` and
181179
* `RMIConnector`, i.e. `new RMIConnector(tainted)`.
182180
*/
183-
private predicate rmiConnectorStep(ExprNode n1, ExprNode n2) {
181+
private predicate rmiConnectorStep(DataFlow::ExprNode n1, DataFlow::ExprNode n2) {
184182
exists(ConstructorCall cc | cc.getConstructedType() instanceof TypeRMIConnector |
185183
n1.asExpr() = cc.getAnArgument() and
186184
n2.asExpr() = cc

0 commit comments

Comments
 (0)