@@ -4,7 +4,7 @@ import semmle.python.pointsto.Filters
44
55/** Holds if `open` is a call that returns a newly opened file */
66predicate call_to_open ( ControlFlowNode open ) {
7- exists ( FunctionObject f |
7+ exists ( FunctionValue f |
88 function_opens_file ( f ) and
99 f .getACall ( ) = open
1010 ) and
@@ -28,7 +28,7 @@ predicate expr_is_open(ControlFlowNode n, ControlFlowNode open) {
2828
2929/** Holds if `call` wraps the object referred to by `v` and returns it */
3030private predicate wraps_file ( CallNode call , EssaVariable v ) {
31- exists ( ClassObject cls |
31+ exists ( ClassValue cls |
3232 call = cls .getACall ( ) and
3333 call .getAnArg ( ) = v .getAUse ( )
3434 )
@@ -99,7 +99,7 @@ predicate closes_file(EssaNodeRefinement call) {
9999predicate closes_arg ( CallNode call , Variable v ) {
100100 call .getAnArg ( ) = v .getAUse ( ) and
101101 (
102- exists ( FunctionObject close | call = close .getACall ( ) and function_closes_file ( close ) )
102+ exists ( FunctionValue close | call = close .getACall ( ) and function_closes_file ( close ) )
103103 or
104104 call .getFunction ( ) .( NameNode ) .getId ( ) = "close"
105105 )
@@ -108,15 +108,15 @@ predicate closes_arg(CallNode call, Variable v) {
108108/** Holds if `call` closes its 'self' argument, which is an open file referred to by `v` */
109109predicate close_method_call ( CallNode call , ControlFlowNode self ) {
110110 call .getFunction ( ) .( AttrNode ) .getObject ( ) = self and
111- exists ( FunctionObject close | call = close .getACall ( ) and function_closes_file ( close ) )
111+ exists ( FunctionValue close | call = close .getACall ( ) and function_closes_file ( close ) )
112112 or
113113 call .getFunction ( ) .( AttrNode ) .getObject ( "close" ) = self
114114}
115115
116- predicate function_closes_file ( FunctionObject close ) {
117- close . hasLongName ( "os.close" )
116+ predicate function_closes_file ( FunctionValue close ) {
117+ close = Value :: named ( "os.close" )
118118 or
119- function_should_close_parameter ( close .getFunction ( ) )
119+ function_should_close_parameter ( close .getScope ( ) )
120120}
121121
122122predicate function_should_close_parameter ( Function func ) {
@@ -126,15 +126,15 @@ predicate function_should_close_parameter(Function func) {
126126 )
127127}
128128
129- predicate function_opens_file ( FunctionObject f ) {
130- f = Object :: builtin ( "open" )
129+ predicate function_opens_file ( FunctionValue f ) {
130+ f = Value :: named ( "open" )
131131 or
132- exists ( EssaVariable v , Return ret | ret .getScope ( ) = f .getFunction ( ) |
132+ exists ( EssaVariable v , Return ret | ret .getScope ( ) = f .getScope ( ) |
133133 ret .getValue ( ) .getAFlowNode ( ) = v .getAUse ( ) and
134134 var_is_open ( v , _)
135135 )
136136 or
137- exists ( Return ret , FunctionObject callee | ret .getScope ( ) = f .getFunction ( ) |
137+ exists ( Return ret , FunctionValue callee | ret .getScope ( ) = f .getScope ( ) |
138138 ret .getValue ( ) .getAFlowNode ( ) = callee .getACall ( ) and
139139 function_opens_file ( callee )
140140 )
0 commit comments