forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDelegateFlow.ql
More file actions
34 lines (29 loc) · 975 Bytes
/
DelegateFlow.ql
File metadata and controls
34 lines (29 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import csharp
import semmle.code.csharp.dataflow.internal.DataFlowImplCommon
import semmle.code.csharp.dataflow.internal.DataFlowDispatch
query predicate delegateCall(DelegateLikeCall dc, Callable c) { c = dc.getARuntimeTarget() }
private class LocatableCallOption extends CallOption {
Location getLocation() {
this = TCallNone() and
result instanceof EmptyLocation
or
exists(DataFlowCall call |
this = TCallSome(call) and
result = call.getLocation()
)
}
}
private class LocatableCall extends TDataFlowCall {
string toString() { result = this.(DataFlowCall).toString() }
Location getLocation() {
exists(Location l |
l = this.(DataFlowCall).getLocation() and
if l instanceof SourceLocation then result = l else result instanceof EmptyLocation
)
}
}
query predicate viableLambda(
LocatableCall call, LocatableCallOption lastCall, DataFlowCallable target
) {
target = viableCallableLambda(call, lastCall)
}