mirror of
https://github.com/github/codeql.git
synced 2026-04-17 21:14:02 +02:00
Python: Update hasUnsafeFilter to use API graph
This will probably break the tests in the short run. I'll fix the remaining issues in a follow-up commit. Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
This commit is contained in:
@@ -74,7 +74,7 @@ module TarSlip {
|
||||
* Holds if `call` has an unsafe extraction filter, either by default (as the default is unsafe),
|
||||
* or by being set to an explicitly unsafe value, such as `"fully_trusted"`, or `None`.
|
||||
*/
|
||||
private predicate hasUnsafeFilter(DataFlow::CallCfgNode call) {
|
||||
private predicate hasUnsafeFilter(API::CallNode call) {
|
||||
call =
|
||||
API::moduleImport("tarfile")
|
||||
.getMember("open")
|
||||
@@ -82,11 +82,16 @@ module TarSlip {
|
||||
.getMember(["extract", "extractall"])
|
||||
.getACall() and
|
||||
(
|
||||
call.getArg(4) = unsafeFilter()
|
||||
exists(Expr filterValue |
|
||||
filterValue = call.getParameter(4, "filter").getAValueReachingSink().asExpr() and
|
||||
(
|
||||
filterValue.(StrConst).getText() = "fully_trusted"
|
||||
or
|
||||
filterValue instanceof None
|
||||
)
|
||||
)
|
||||
or
|
||||
call.getArgByName("filter") = unsafeFilter()
|
||||
or
|
||||
not exists(call.getArg(4)) and not exists(call.getArgByName("filter"))
|
||||
not exists(call.getParameter(4, "filter"))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user