Skip to content

Commit e4e9a2e

Browse files
committed
Data flow: Guard against viableImplInCallContext not being a subset ofviableCallable
1 parent f0f4fe7 commit e4e9a2e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ private module Cached {
709709
*/
710710
pragma[nomagic]
711711
private DataFlowCallable viableImplInCallContextExt(DataFlowCall call, DataFlowCall ctx) {
712-
result = viableImplInCallContext(call, ctx)
712+
result = viableImplInCallContext(call, ctx) and
713+
result = viableCallable(call)
713714
or
714715
result = viableCallableLambda(call, TDataFlowCallSome(ctx))
715716
or

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ module Consistency {
3838

3939
/** Holds if `n` should be excluded from the consistency test `uniquePostUpdate`. */
4040
predicate uniquePostUpdateExclude(Node n) { none() }
41+
42+
/** Holds if `(call, ctx)` should be excluded from the consistency test `viableImplInCallContextTooLargeExclude`. */
43+
predicate viableImplInCallContextTooLargeExclude(
44+
DataFlowCall call, DataFlowCall ctx, DataFlowCallable callable
45+
) {
46+
none()
47+
}
4148
}
4249

4350
private class RelevantNode extends Node {
@@ -217,4 +224,12 @@ module Consistency {
217224
not any(ConsistencyConfiguration c).postWithInFlowExclude(n) and
218225
msg = "PostUpdateNode should not be the target of local flow."
219226
}
227+
228+
query predicate viableImplInCallContextTooLarge(
229+
DataFlowCall call, DataFlowCall ctx, DataFlowCallable callable
230+
) {
231+
callable = viableImplInCallContext(call, ctx) and
232+
not callable = viableCallable(call) and
233+
not any(ConsistencyConfiguration c).viableImplInCallContextTooLargeExclude(call, ctx, callable)
234+
}
220235
}

0 commit comments

Comments
 (0)