Skip to content

Commit aeadad6

Browse files
michaelnebelhvitved
authored andcommitted
C#: Improve implementation.
1 parent 26e2cad commit aeadad6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/FlowSummary.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import csharp
44
private import dotnet
5+
private import internal.FlowSummaryImplSpecific as FlowSummaryImplSpecific
56
private import internal.FlowSummaryImpl as Impl
67
private import internal.DataFlowDispatch as DataFlowDispatch
78

@@ -160,6 +161,13 @@ abstract class SummarizedCallable extends DotNet::Callable {
160161
predicate isAutoGenerated() { none() }
161162
}
162163

164+
private class SourceSinkSummarizedCallable extends SummarizedCallable {
165+
SourceSinkSummarizedCallable() {
166+
FlowSummaryImplSpecific::sourceElement(this, _, _, _) or
167+
FlowSummaryImplSpecific::sinkElement(this, _, _, _)
168+
}
169+
}
170+
163171
private class SummarizedCallableAdapter extends Impl::Public::SummarizedCallable {
164172
private SummarizedCallable sc;
165173

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,16 @@ class InterpretNode extends TInterpretNode {
256256
DataFlowCall asCall() { this = TDataFlowCall_(result) }
257257

258258
/** Gets the callable that this node corresponds to, if any. */
259-
DataFlowCallable asCallable() { result.asCallable() = this.asElement() }
259+
DataFlowCallable asCallable() {
260+
result.asCallable() = this.asElement() or
261+
result.asSummarizedCallable() = this.asElement()
262+
}
260263

261264
/** Gets the target of this call, if any. */
262-
Callable getCallTarget() { result = viableCallable(this.asCall()).asCallable() }
265+
Callable getCallTarget() {
266+
result = viableCallable(this.asCall()).asSummarizedCallable() or
267+
result = viableCallable(this.asCall()).asCallable()
268+
}
263269

264270
/** Gets a textual representation of this node. */
265271
string toString() {

0 commit comments

Comments
 (0)