Skip to content

Commit 7002ed5

Browse files
committed
Refactor InsecureRmiJmxEnvironmentConfiguration
1 parent 6e4e1e5 commit 7002ed5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ predicate isRmiOrJmxServerCreateMethod(Method method) {
3232
* `map.put("jmx.remote.rmi.server.credential.types", value)` call
3333
* to an RMI or JMX initialisation call.
3434
*/
35-
class SafeFlow extends DataFlow::Configuration {
36-
SafeFlow() { this = "MapToPutCredentialstypeConfiguration" }
35+
module SafeFlowConfig implements DataFlow::ConfigSig {
36+
predicate isSource(DataFlow::Node source) { putsCredentialtypesKey(source.asExpr()) }
3737

38-
override predicate isSource(DataFlow::Node source) { putsCredentialtypesKey(source.asExpr()) }
39-
40-
override predicate isSink(DataFlow::Node sink) {
38+
predicate isSink(DataFlow::Node sink) {
4139
exists(Call c |
4240
isRmiOrJmxServerCreateConstructor(c.getCallee()) or
4341
isRmiOrJmxServerCreateMethod(c.getCallee())
@@ -71,6 +69,8 @@ class SafeFlow extends DataFlow::Configuration {
7169
}
7270
}
7371

72+
module SafeFlow = DataFlow::Global<SafeFlowConfig>;
73+
7474
/** Gets a string describing why the application is vulnerable, depending on if the vulnerability is present due to a) a null environment b) an insecurely set environment map */
7575
string getRmiResult(Expr e) {
7676
// We got a Map so we have a source and a sink node
@@ -87,5 +87,5 @@ from Call c, Expr envArg
8787
where
8888
(isRmiOrJmxServerCreateConstructor(c.getCallee()) or isRmiOrJmxServerCreateMethod(c.getCallee())) and
8989
envArg = c.getArgument(1) and
90-
not any(SafeFlow conf).hasFlowToExpr(envArg)
90+
not SafeFlow::flowToExpr(envArg)
9191
select c, getRmiResult(envArg), envArg, envArg.toString()

0 commit comments

Comments
 (0)