mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
Python: slightly improve tarslip logic
This commit is contained in:
@@ -84,26 +84,19 @@ module TarSlip {
|
|||||||
* A sink capturing method calls to `extractall`.
|
* A sink capturing method calls to `extractall`.
|
||||||
*
|
*
|
||||||
* For a call to `file.extractall`, `file` is considered a sink if
|
* For a call to `file.extractall`, `file` is considered a sink if
|
||||||
*
|
* there is no `members` argument and the extraction filter is unsafe.
|
||||||
* - there are no other arguments, or
|
|
||||||
* - there are other arguments (except `members`), and the extraction filter is unsafe.
|
|
||||||
*/
|
*/
|
||||||
class ExtractAllSink extends Sink {
|
class ExtractAllSink extends Sink {
|
||||||
ExtractAllSink() {
|
ExtractAllSink() {
|
||||||
exists(DataFlow::CallCfgNode call |
|
exists(API::CallNode call |
|
||||||
call =
|
call =
|
||||||
API::moduleImport("tarfile")
|
API::moduleImport("tarfile")
|
||||||
.getMember("open")
|
.getMember("open")
|
||||||
.getReturn()
|
.getReturn()
|
||||||
.getMember("extractall")
|
.getMember("extractall")
|
||||||
.getACall() and
|
.getACall() and
|
||||||
(
|
hasUnsafeFilter(call) and
|
||||||
not exists(call.getArg(_)) and
|
not exists(call.getParameter(2, "members")) and
|
||||||
not exists(call.getArgByName(_))
|
|
||||||
or
|
|
||||||
hasUnsafeFilter(call)
|
|
||||||
) and
|
|
||||||
not exists(call.getArgByName("members")) and
|
|
||||||
this = call.(DataFlow::MethodCallNode).getObject()
|
this = call.(DataFlow::MethodCallNode).getObject()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user