@@ -7,6 +7,7 @@ private import codeql.ruby.DataFlow
7
7
private import codeql.ruby.dataflow.FlowSummary
8
8
private import codeql.ruby.dataflow.internal.DataFlowDispatch
9
9
private import codeql.ruby.frameworks.data.ModelsAsData
10
+ private import codeql.ruby.typetracking.TypeTracker
10
11
11
12
/**
12
13
* Modeling of the `Pathname` class from the Ruby standard library.
@@ -31,29 +32,31 @@ module Pathname {
31
32
PathnameInstance ( ) { this = pathnameInstance ( ) }
32
33
}
33
34
34
- private DataFlow:: Node pathnameInstance ( ) {
35
- // A call to `Pathname.new`.
36
- result = API:: getTopLevelMember ( "Pathname" ) .getAnInstantiation ( )
37
- or
38
- // Class methods on `Pathname` that return a new `Pathname`.
39
- result = API:: getTopLevelMember ( "Pathname" ) .getAMethodCall ( [ "getwd" , "pwd" , ] )
40
- or
41
- // Instance methods on `Pathname` that return a new `Pathname`.
42
- exists ( DataFlow:: CallNode c | result = c |
43
- c .getReceiver ( ) = pathnameInstance ( ) and
44
- c .getMethodName ( ) =
45
- [
46
- "+" , "/" , "basename" , "cleanpath" , "expand_path" , "join" , "realpath" ,
47
- "relative_path_from" , "sub" , "sub_ext" , "to_path"
48
- ]
35
+ private DataFlow:: LocalSourceNode pathnameInstance ( TypeTracker t ) {
36
+ t .start ( ) and
37
+ (
38
+ // A call to `Pathname.new`.
39
+ result = API:: getTopLevelMember ( "Pathname" ) .getAnInstantiation ( )
40
+ or
41
+ // Class methods on `Pathname` that return a new `Pathname`.
42
+ result = API:: getTopLevelMember ( "Pathname" ) .getAMethodCall ( [ "getwd" , "pwd" , ] )
43
+ or
44
+ // Instance methods on `Pathname` that return a new `Pathname`.
45
+ exists ( DataFlow:: CallNode c | result = c |
46
+ c .getReceiver ( ) = pathnameInstance ( ) and
47
+ c .getMethodName ( ) =
48
+ [
49
+ "+" , "/" , "basename" , "cleanpath" , "expand_path" , "join" , "realpath" ,
50
+ "relative_path_from" , "sub" , "sub_ext" , "to_path"
51
+ ]
52
+ )
49
53
)
50
54
or
51
- exists ( DataFlow:: Node inst |
52
- inst = pathnameInstance ( ) and
53
- inst .( DataFlow:: LocalSourceNode ) .flowsTo ( result )
54
- )
55
+ exists ( TypeTracker t2 | result = pathnameInstance ( t2 ) .track ( t2 , t ) )
55
56
}
56
57
58
+ private DataFlow:: Node pathnameInstance ( ) { pathnameInstance ( TypeTracker:: end ( ) ) .flowsTo ( result ) }
59
+
57
60
/** A call where the receiver is a `Pathname`. */
58
61
class PathnameCall extends DataFlow:: CallNode {
59
62
PathnameCall ( ) { this .getReceiver ( ) instanceof PathnameInstance }
0 commit comments