@@ -651,7 +651,7 @@ private module Stdlib {
651651 * WARNING: Only holds for a few predefined attributes.
652652 */
653653 private DataFlow:: Node builtins_attr ( DataFlow:: TypeTracker t , string attr_name ) {
654- attr_name in [ "exec" , "eval" , "compile" ] and
654+ attr_name in [ "exec" , "eval" , "compile" , "open" ] and
655655 (
656656 t .start ( ) and
657657 result = DataFlow:: importNode ( [ "builtins" , "__builtin__" ] + "." + attr_name )
@@ -729,6 +729,20 @@ private module Stdlib {
729729 }
730730 }
731731
732+ /**
733+ * A call to the builtin `open` function.
734+ * See https://docs.python.org/3/library/functions.html#open
735+ */
736+ private class OpenCall extends FileSystemAccess:: Range , DataFlow:: CfgNode {
737+ override CallNode node ;
738+
739+ OpenCall ( ) { node .getFunction ( ) = builtins_attr ( "open" ) .asCfgNode ( ) }
740+
741+ override DataFlow:: Node getAPathArgument ( ) {
742+ result .asCfgNode ( ) in [ node .getArg ( 0 ) , node .getArgByName ( "file" ) ]
743+ }
744+ }
745+
732746 /**
733747 * An exec statement (only Python 2).
734748 * Se ehttps://docs.python.org/2/reference/simple_stmts.html#the-exec-statement.
@@ -743,20 +757,6 @@ private module Stdlib {
743757 override DataFlow:: Node getCode ( ) { result = this }
744758 }
745759
746- /**
747- * A call to the builtin `open` function.
748- * See https://docs.python.org/3/library/functions.html#open
749- */
750- private class OpenCall extends FileSystemAccess:: Range , DataFlow:: CfgNode {
751- override CallNode node ;
752-
753- OpenCall ( ) { node .getFunction ( ) .( NameNode ) .getId ( ) = "open" }
754-
755- override DataFlow:: Node getAPathArgument ( ) {
756- result .asCfgNode ( ) in [ node .getArg ( 0 ) , node .getArgByName ( "file" ) ]
757- }
758- }
759-
760760 // ---------------------------------------------------------------------------
761761 // base64
762762 // ---------------------------------------------------------------------------
0 commit comments