@@ -5,6 +5,7 @@ private import DataFlowPublic
5
5
private import semmle.code.powershell.typetracking.internal.TypeTrackingImpl
6
6
private import FlowSummaryImpl as FlowSummaryImpl
7
7
private import semmle.code.powershell.dataflow.FlowSummary
8
+ private import SsaImpl as SsaImpl
8
9
private import codeql.util.Boolean
9
10
private import codeql.util.Unit
10
11
@@ -39,10 +40,10 @@ abstract class LibraryCallable extends string {
39
40
LibraryCallable ( ) { any ( ) }
40
41
41
42
/** Gets a call to this library callable. */
42
- Call getACall ( ) { none ( ) }
43
+ CallExpr getACall ( ) { none ( ) }
43
44
44
45
/** Same as `getACall()` except this does not depend on the call graph or API graph. */
45
- Call getACallSimple ( ) { none ( ) }
46
+ CallExpr getACallSimple ( ) { none ( ) }
46
47
}
47
48
48
49
/** A callable defined in library code, which should be taken into account in type tracking. */
@@ -90,7 +91,7 @@ abstract class DataFlowCall extends TDataFlowCall {
90
91
abstract DataFlowCallable getEnclosingCallable ( ) ;
91
92
92
93
/** Gets the underlying source code call, if any. */
93
- abstract CfgNodes:: CallCfgNode asCall ( ) ;
94
+ abstract CfgNodes:: ExprNodes :: CallExprCfgNode asCall ( ) ;
94
95
95
96
/** Gets a textual representation of this call. */
96
97
abstract string toString ( ) ;
@@ -130,19 +131,19 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
130
131
131
132
override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = c }
132
133
133
- override CfgNodes:: CallCfgNode asCall ( ) { none ( ) }
134
+ override CfgNodes:: ExprNodes :: CallExprCfgNode asCall ( ) { none ( ) }
134
135
135
136
override string toString ( ) { result = "[summary] call to " + receiver + " in " + c }
136
137
137
138
override EmptyLocation getLocation ( ) { any ( ) }
138
139
}
139
140
140
141
class NormalCall extends DataFlowCall , TNormalCall {
141
- private CfgNodes:: CallCfgNode c ;
142
+ private CfgNodes:: ExprNodes :: CallExprCfgNode c ;
142
143
143
144
NormalCall ( ) { this = TNormalCall ( c ) }
144
145
145
- override CfgNodes:: CallCfgNode asCall ( ) { result = c }
146
+ override CfgNodes:: ExprNodes :: CallExprCfgNode asCall ( ) { result = c }
146
147
147
148
override DataFlowCallable getEnclosingCallable ( ) { result = TCfgScope ( c .getScope ( ) ) }
148
149
@@ -161,7 +162,7 @@ private module TrackInstanceInput implements CallGraphConstruction::InputSig {
161
162
start .( ObjectCreationNode ) .getObjectCreationNode ( ) .getConstructedTypeName ( ) = typename and
162
163
exact = true
163
164
or
164
- start .asExpr ( ) .( CfgNodes:: ExprNodes:: TypeNameCfgNode ) . getTypeName ( ) = typename and
165
+ start .asExpr ( ) .( CfgNodes:: ExprNodes:: TypeNameExprCfgNode ) . getName ( ) = typename and
165
166
exact = true
166
167
or
167
168
start .asParameter ( ) .getStaticType ( ) = typename and
@@ -195,7 +196,9 @@ private module TrackInstanceInput implements CallGraphConstruction::InputSig {
195
196
predicate filter ( Node n , Unit u ) { none ( ) }
196
197
}
197
198
198
- private predicate qualifiedCall ( CfgNodes:: CallCfgNode call , Node receiver , string method ) {
199
+ private predicate qualifiedCall (
200
+ CfgNodes:: ExprNodes:: CallExprCfgNode call , Node receiver , string method
201
+ ) {
199
202
call .getQualifier ( ) = receiver .asExpr ( ) and
200
203
call .getName ( ) = method
201
204
}
@@ -214,7 +217,7 @@ private Type getTypeWithName(string s, boolean exact) {
214
217
exact = false
215
218
}
216
219
217
- private CfgScope getTargetInstance ( CfgNodes:: CallCfgNode call ) {
220
+ private CfgScope getTargetInstance ( CfgNodes:: ExprNodes :: CallExprCfgNode call ) {
218
221
// TODO: Also match argument/parameter types
219
222
exists ( Node receiver , string method , string typename , Type t , boolean exact |
220
223
qualifiedCall ( call , receiver , method ) and
@@ -236,7 +239,7 @@ class AdditionalCallTarget extends Unit {
236
239
/**
237
240
* Gets a viable target for `call`.
238
241
*/
239
- abstract DataFlowCallable viableTarget ( CfgNodes:: CallCfgNode call ) ;
242
+ abstract DataFlowCallable viableTarget ( CfgNodes:: ExprNodes :: CallExprCfgNode call ) ;
240
243
}
241
244
242
245
/** Holds if `call` may resolve to the returned summarized library method. */
@@ -256,7 +259,7 @@ private module Cached {
256
259
257
260
cached
258
261
newtype TDataFlowCall =
259
- TNormalCall ( CfgNodes:: CallCfgNode c ) or
262
+ TNormalCall ( CfgNodes:: ExprNodes :: CallExprCfgNode c ) or
260
263
TSummaryCall (
261
264
FlowSummaryImpl:: Public:: SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNode receiver
262
265
) {
@@ -283,7 +286,7 @@ private module Cached {
283
286
FlowSummaryImpl:: ParsePositions:: isParsedKeywordParameterPosition ( _, name )
284
287
} or
285
288
TPositionalArgumentPosition ( int pos , NamedSet ns ) {
286
- exists ( CfgNodes:: CallCfgNode call |
289
+ exists ( CfgNodes:: ExprNodes :: CallExprCfgNode call |
287
290
call = ns .getABindingCall ( ) and
288
291
exists ( call .getArgument ( pos ) )
289
292
)
@@ -297,7 +300,7 @@ private module Cached {
297
300
TThisParameterPosition ( ) or
298
301
TKeywordParameter ( string name ) { name = any ( Argument p ) .getName ( ) } or
299
302
TPositionalParameter ( int pos , NamedSet ns ) {
300
- exists ( CfgNodes:: CallCfgNode call |
303
+ exists ( CfgNodes:: ExprNodes :: CallExprCfgNode call |
301
304
call = ns .getABindingCall ( ) and
302
305
exists ( call .getArgument ( pos ) )
303
306
)
@@ -306,7 +309,7 @@ private module Cached {
306
309
// `ns.getABindingCall()`, but those parameters should still have
307
310
// positions since SSA depends on this.
308
311
// In particular, global scope is also an uncalled function.
309
- any ( Parameter p ) .getIndexExcludingPipelines ( ) = pos and
312
+ any ( SsaImpl :: NormalParameter p ) .getIndexExcludingPipelines ( ) = pos and
310
313
ns .isEmpty ( )
311
314
} or
312
315
TPipelineParameter ( )
0 commit comments