Skip to content

Commit 2a0721b

Browse files
committed
Optimize the sink and update method name
1 parent e652d87 commit 2a0721b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

java/ql/src/experimental/Security/CWE/CWE-094/JythonInjection.ql

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BytecodeLoader extends RefType {
3333
}
3434

3535
/** Holds if a Jython expression if evaluated, compiled or executed. */
36-
predicate runCode(MethodAccess ma, Expr sink) {
36+
predicate runsCode(MethodAccess ma, Expr sink) {
3737
exists(Method m | m = ma.getMethod() |
3838
m instanceof InterpretExprMethod and
3939
sink = ma.getArgument(0)
@@ -83,17 +83,15 @@ predicate compile(MethodAccess ma, Expr sink) {
8383

8484
/** An expression loaded by Jython. */
8585
class CodeInjectionSink extends DataFlow::ExprNode {
86+
MethodAccess methodAccess;
87+
8688
CodeInjectionSink() {
87-
runCode(_, this.getExpr()) or
88-
loadsClass(_, this.getExpr()) or
89-
compile(_, this.getExpr())
89+
runsCode(methodAccess, this.getExpr()) or
90+
loadsClass(methodAccess, this.getExpr()) or
91+
compile(methodAccess, this.getExpr())
9092
}
9193

92-
MethodAccess getMethodAccess() {
93-
runCode(result, this.getExpr()) or
94-
loadsClass(result, this.getExpr()) or
95-
compile(result, this.getExpr())
96-
}
94+
MethodAccess getMethodAccess() { result = methodAccess }
9795
}
9896

9997
/**

0 commit comments

Comments
 (0)