mirror of
https://github.com/github/codeql.git
synced 2026-04-20 22:44:52 +02:00
Python: Fixup modeling of os.open
This commit is contained in:
@@ -338,7 +338,7 @@ module StdlibPrivate {
|
||||
* Modeling of path related functions in the `os` module.
|
||||
* Wrapped in QL module to make it easy to fold/unfold.
|
||||
*/
|
||||
private module OsFileSystemAccessModeling {
|
||||
module OsFileSystemAccessModeling {
|
||||
/**
|
||||
* A call to the `os.fsencode` function.
|
||||
*
|
||||
@@ -395,7 +395,7 @@ module StdlibPrivate {
|
||||
*
|
||||
* See https://docs.python.org/3/library/os.html#os.open
|
||||
*/
|
||||
private class OsOpenCall extends FileSystemAccess::Range, DataFlow::CallCfgNode {
|
||||
class OsOpenCall extends FileSystemAccess::Range, DataFlow::CallCfgNode {
|
||||
OsOpenCall() { this = os().getMember("open").getACall() }
|
||||
|
||||
override DataFlow::Node getAPathArgument() {
|
||||
@@ -1501,7 +1501,12 @@ module StdlibPrivate {
|
||||
private class OpenCall extends FileSystemAccess::Range, Stdlib::FileLikeObject::InstanceSource,
|
||||
ThreatModelSource::Range, DataFlow::CallCfgNode
|
||||
{
|
||||
OpenCall() { this = getOpenFunctionRef().getACall() }
|
||||
OpenCall() {
|
||||
this = getOpenFunctionRef().getACall() and
|
||||
// when analyzing stdlib code for os.py we wrongly assume that `os.open` is an
|
||||
// alias of the builtins `open` function
|
||||
not this instanceof OsFileSystemAccessModeling::OsOpenCall
|
||||
}
|
||||
|
||||
override DataFlow::Node getAPathArgument() {
|
||||
result in [this.getArg(0), this.getArgByName("file")]
|
||||
|
||||
Reference in New Issue
Block a user