Skip to content

Commit a528db8

Browse files
committed
Use MapMutation instead of MethodCall
1 parent e14be0e commit a528db8

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,14 @@ private import semmle.code.java.dataflow.FlowSources
55
private import semmle.code.java.Maps
66
private import semmle.code.java.JDK
77

8-
private class MapUpdateWithKeyOrValue extends MethodCall {
9-
MapUpdateWithKeyOrValue() {
10-
this.getMethod() instanceof MapMethod and
11-
this.getMethod().getName().matches(["put%", "remove", "replace"])
12-
}
13-
}
14-
158
private module ProcessBuilderEnvironmentConfig implements DataFlow::ConfigSig {
169
predicate isSource(DataFlow::Node source) {
1710
exists(MethodCall mc | mc = source.asExpr() |
1811
mc.getMethod().hasQualifiedName("java.lang", "ProcessBuilder", "environment")
1912
)
2013
}
2114

22-
predicate isSink(DataFlow::Node sink) {
23-
sink.asExpr() = any(MapUpdateWithKeyOrValue mm).getQualifier()
24-
}
15+
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(MapMutation mm).getQualifier() }
2516
}
2617

2718
private module ProcessBuilderEnvironmentFlow = DataFlow::Global<ProcessBuilderEnvironmentConfig>;
@@ -43,7 +34,7 @@ module ExecTaintedEnvironmentConfig implements DataFlow::ConfigSig {
4334
sinkNode(sink, "environment-injection")
4435
or
4536
// sink is a key or value added to a `ProcessBuilder::environment` map.
46-
exists(MapUpdateWithKeyOrValue mm | mm.getAnArgument() = sink.asExpr() |
37+
exists(MapMutation mm | mm.getAnArgument() = sink.asExpr() |
4738
ProcessBuilderEnvironmentFlow::flowToExpr(mm.getQualifier())
4839
)
4940
}

0 commit comments

Comments
 (0)