Skip to content

Commit ec82d61

Browse files
committed
Add another frequently used step
1 parent a015084 commit ec82d61

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

python/ql/src/experimental/Security/UnsafeUnpackQuery.qll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
190190
or
191191
// Go through an Open for a Tarfile
192192
nodeTo = tarfileOpen().getACall() and nodeFrom = nodeTo.(MethodCallNode).getArg(0)
193-
or
193+
or
194194
// Handle the case where the getmembers is used.
195195
nodeTo.(MethodCallNode).calls(nodeFrom, "getmembers") and
196196
nodeFrom instanceof AllTarfileOpens
@@ -201,5 +201,17 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
201201
nodeTo = API::moduleImport("contextlib").getMember("closing").getACall() and
202202
nodeFrom = nodeTo.(API::CallNode).getArg(0) and
203203
nodeFrom = tarfileOpen().getReturn().getAValueReachableFromSource()
204+
or
205+
// see Path : https://docs.python.org/3/library/pathlib.html#pathlib.Path
206+
nodeTo = API::moduleImport("pathlib").getMember("Path").getACall() and
207+
nodeFrom = nodeTo.(API::CallNode).getArg(0)
208+
or
209+
// Use of absolutepath
210+
// see absolute : https://docs.python.org/3/library/pathlib.html#pathlib.Path.absolute
211+
exists(API::CallNode mcn |
212+
mcn = API::moduleImport("pathlib").getMember("Path").getACall() and
213+
nodeTo = mcn.getAMethodCall("absolute") and
214+
nodeFrom = mcn.getArg(0)
215+
)
204216
}
205217
}

0 commit comments

Comments
 (0)