@@ -10,7 +10,6 @@ class ArgumentPosition = DataFlowDispatch::ArgumentPosition;
1010
1111// import all instances below
1212private module Summaries {
13- private import semmle.code.csharp.dataflow.LibraryTypeDataFlow
1413 private import semmle.code.csharp.frameworks.EntityFramework
1514}
1615
@@ -111,6 +110,29 @@ module SummaryComponentStack {
111110
112111class SummarizedCallable = Impl:: Public:: SummarizedCallable ;
113112
113+ private predicate recordConstructorFlow ( Constructor c , int i , Property p ) {
114+ c = any ( Record r ) .getAMember ( ) and
115+ exists ( string name |
116+ c .getParameter ( i ) .getName ( ) = name and
117+ c .getDeclaringType ( ) .getAMember ( name ) = p
118+ )
119+ }
120+
121+ private class RecordConstructorFlow extends SummarizedCallable {
122+ RecordConstructorFlow ( ) { recordConstructorFlow ( this , _, _) }
123+
124+ override predicate propagatesFlow (
125+ SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue
126+ ) {
127+ exists ( int i , Property p |
128+ recordConstructorFlow ( this , i , p ) and
129+ input = SummaryComponentStack:: argument ( i ) and
130+ output = SummaryComponentStack:: propertyOf ( p , SummaryComponentStack:: return ( ) ) and
131+ preservesValue = true
132+ )
133+ }
134+ }
135+
114136private class SummarizedCallableDefaultClearsContent extends Impl:: Public:: SummarizedCallable {
115137 SummarizedCallableDefaultClearsContent ( ) {
116138 this instanceof Impl:: Public:: SummarizedCallable or none ( )
@@ -129,3 +151,17 @@ private class SummarizedCallableDefaultClearsContent extends Impl::Public::Summa
129151}
130152
131153class RequiredSummaryComponentStack = Impl:: Public:: RequiredSummaryComponentStack ;
154+
155+ private class RecordConstructorFlowRequiredSummaryComponentStack extends RequiredSummaryComponentStack {
156+ private SummaryComponent head ;
157+
158+ RecordConstructorFlowRequiredSummaryComponentStack ( ) {
159+ exists ( Property p |
160+ recordConstructorFlow ( _, _, p ) and
161+ head = SummaryComponent:: property ( p ) and
162+ this = SummaryComponentStack:: return ( )
163+ )
164+ }
165+
166+ override predicate required ( SummaryComponent c ) { c = head }
167+ }
0 commit comments