@@ -651,7 +651,7 @@ private module Stdlib {
651
651
* WARNING: Only holds for a few predefined attributes.
652
652
*/
653
653
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
655
655
(
656
656
t .start ( ) and
657
657
result = DataFlow:: importNode ( [ "builtins" , "__builtin__" ] + "." + attr_name )
@@ -729,6 +729,20 @@ private module Stdlib {
729
729
}
730
730
}
731
731
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
+
732
746
/**
733
747
* An exec statement (only Python 2).
734
748
* Se ehttps://docs.python.org/2/reference/simple_stmts.html#the-exec-statement.
@@ -743,20 +757,6 @@ private module Stdlib {
743
757
override DataFlow:: Node getCode ( ) { result = this }
744
758
}
745
759
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
-
760
760
// ---------------------------------------------------------------------------
761
761
// base64
762
762
// ---------------------------------------------------------------------------
0 commit comments