Skip to content

Commit c142495

Browse files
committed
python: simplify code
1 parent 5fe62e2 commit c142495

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

python/ql/src/experimental/Security/CWE-022bis/TarSlipImprov.ql

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,15 @@ class Configuration extends TaintTracking::Configuration {
100100
}
101101

102102
override predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
103-
exists(AttrRead attr, MethodCallNode call |
104-
attr.accesses(nodeFrom, "getmembers") and
105-
nodeFrom = call.getObject() and
106-
nodeFrom instanceof AllTarfileOpens and
107-
nodeTo = call
108-
)
103+
nodeTo.(MethodCallNode).calls(nodeFrom, "getmembers") and
104+
nodeFrom instanceof AllTarfileOpens
109105
or
110106
// To handle the case of `with closing(tarfile.open()) as file:`
111107
// we add a step from the first argument of `closing` to the call to `closing`,
112108
// whenever that first argument is a return of `tarfile.open()`.
113-
exists(API::CallNode closing |
114-
closing = API::moduleImport("contextlib").getMember("closing").getACall() and
115-
nodeFrom = closing.getArg(0) and
116-
nodeFrom = tarfileOpen().getReturn().getAValueReachableFromSource() and
117-
nodeTo = closing
118-
)
109+
nodeTo = API::moduleImport("contextlib").getMember("closing").getACall() and
110+
nodeFrom = nodeTo.(API::CallNode).getArg(0) and
111+
nodeFrom = tarfileOpen().getReturn().getAValueReachableFromSource()
119112
}
120113
}
121114

0 commit comments

Comments
 (0)