Python: add flow from methods to calls

This commit is contained in:
Rasmus Lerchedahl Petersen
2021-04-28 17:02:24 +02:00
parent 7cc97836a9
commit 16bde2729d
2 changed files with 11 additions and 4 deletions

View File

@@ -922,7 +922,9 @@ private module Stdlib {
or
// method call
returnsPath.getAttributeName() = pathlibPathMethod() and
nodeTo.(DataFlow::CallCfgNode).getFunction() = returnsPath
returnsPath
.(DataFlow::LocalSourceNode)
.flowsTo(nodeTo.(DataFlow::CallCfgNode).getFunction())
) and
nodeFrom = returnsPath.getObject()
)
@@ -987,7 +989,7 @@ private module Stdlib {
"unlink", "link_to", "write_bytes", "write_text"
] and
pathlibPath().flowsTo(fileAccess.getObject()) and
this.getFunction() = fileAccess
fileAccess.(DataFlow::LocalSourceNode).flowsTo(this.getFunction())
}
override DataFlow::Node getAPathArgument() { result = fileAccess.getObject() }
@@ -1022,7 +1024,9 @@ private module Stdlib {
exists(DataFlow::AttrRead augmentsPath |
augmentsPath.getAttributeName() = pathlibPathInjection()
|
nodeTo.(DataFlow::CallCfgNode).getFunction() = augmentsPath and
augmentsPath
.(DataFlow::LocalSourceNode)
.flowsTo(nodeTo.(DataFlow::CallCfgNode).getFunction()) and
(
// type-preserving call
nodeFrom = augmentsPath.getObject()
@@ -1042,7 +1046,7 @@ private module Stdlib {
or
// exporting method
exportPath.getAttributeName() = pathlibPathMethodExport() and
nodeTo.(DataFlow::CallCfgNode).getFunction() = exportPath
exportPath.(DataFlow::LocalSourceNode).flowsTo(nodeTo.(DataFlow::CallCfgNode).getFunction())
|
nodeFrom = exportPath.getObject()
)

View File

@@ -34,3 +34,6 @@ p.write_bytes(b"hello") # $getAPathArgument=p
name = windows.parent.name
o(name) # $getAPathArgument=name
wb = p.write_bytes
wb(b"hello") # $getAPathArgument=p