11/** Provides classes and predicates for defining flow summaries. */
22
33import csharp
4+ private import dotnet
45private import internal.FlowSummaryImpl as Impl
56private import internal.DataFlowDispatch as DataFlowDispatch
67
@@ -113,7 +114,41 @@ module SummaryComponentStack {
113114 SummaryComponentStack jump ( Callable c ) { result = singleton ( SummaryComponent:: jump ( c ) ) }
114115}
115116
116- class SummarizedCallable = Impl:: Public:: SummarizedCallable ;
117+ abstract class SummarizedCallable extends DotNet:: Callable {
118+ /**
119+ * Holds if data may flow from `input` to `output` through this callable.
120+ *
121+ * `preservesValue` indicates whether this is a value-preserving step
122+ * or a taint-step.
123+ *
124+ * Input specifications are restricted to stacks that end with
125+ * `SummaryComponent::argument(_)`, preceded by zero or more
126+ * `SummaryComponent::return(_)` or `SummaryComponent::content(_)` components.
127+ *
128+ * Output specifications are restricted to stacks that end with
129+ * `SummaryComponent::return(_)` or `SummaryComponent::argument(_)`.
130+ *
131+ * Output stacks ending with `SummaryComponent::return(_)` can be preceded by zero
132+ * or more `SummaryComponent::content(_)` components.
133+ *
134+ * Output stacks ending with `SummaryComponent::argument(_)` can be preceded by an
135+ * optional `SummaryComponent::parameter(_)` component, which in turn can be preceded
136+ * by zero or more `SummaryComponent::content(_)` components.
137+ */
138+ pragma [ nomagic]
139+ predicate propagatesFlow (
140+ SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue
141+ ) {
142+ none ( )
143+ }
144+
145+ /**
146+ * Holds if values stored inside `content` are cleared on objects passed as
147+ * arguments at position `pos` to this callable.
148+ */
149+ pragma [ nomagic]
150+ predicate clearsContent ( ParameterPosition pos , DataFlow:: ContentSet content ) { none ( ) }
151+ }
117152
118153private predicate recordConstructorFlow ( Constructor c , int i , Property p ) {
119154 c = any ( RecordType r ) .getAMember ( ) and
@@ -123,6 +158,22 @@ private predicate recordConstructorFlow(Constructor c, int i, Property p) {
123158 )
124159}
125160
161+ private class SummarizedCallableAdapter extends Impl:: Public:: SummarizedCallable {
162+ private SummarizedCallable sc ;
163+
164+ SummarizedCallableAdapter ( ) { this = DataFlowDispatch:: TSummarizedCallable ( sc ) }
165+
166+ final override predicate propagatesFlow (
167+ SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue
168+ ) {
169+ sc .propagatesFlow ( input , output , preservesValue )
170+ }
171+
172+ final override predicate clearsContent ( ParameterPosition pos , DataFlow:: ContentSet content ) {
173+ sc .clearsContent ( pos , content )
174+ }
175+ }
176+
126177private class RecordConstructorFlow extends SummarizedCallable {
127178 RecordConstructorFlow ( ) { recordConstructorFlow ( this , _, _) }
128179
0 commit comments