Skip to content

Commit 5fe62e2

Browse files
committed
python: fix bug, add clarifying comment
1 parent 664fdc3 commit 5fe62e2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ class Configuration extends TaintTracking::Configuration {
107107
nodeTo = call
108108
)
109109
or
110+
// To handle the case of `with closing(tarfile.open()) as file:`
111+
// we add a step from the first argument of `closing` to the call to `closing`,
112+
// whenever that first argument is a return of `tarfile.open()`.
110113
exists(API::CallNode closing |
111114
closing = API::moduleImport("contextlib").getMember("closing").getACall() and
112115
nodeFrom = closing.getArg(0) and
113-
nodeFrom = tarfileOpen().getReturn().getAValueReachingSink() and
116+
nodeFrom = tarfileOpen().getReturn().getAValueReachableFromSource() and
114117
nodeTo = closing
115118
)
116119
}

0 commit comments

Comments
 (0)