@@ -11,6 +11,7 @@ private import semmle.code.csharp.frameworks.system.io.Compression
1111private import semmle.code.csharp.frameworks.system.linq.Expressions
1212private import semmle.code.csharp.frameworks.system.Net
1313private import semmle.code.csharp.frameworks.system.Text
14+ private import semmle.code.csharp.frameworks.system.runtime.CompilerServices
1415private import semmle.code.csharp.frameworks.system.threading.Tasks
1516private import semmle.code.csharp.frameworks.system.Web
1617private import semmle.code.csharp.frameworks.system.web.ui.WebControls
@@ -95,6 +96,11 @@ module AccessPath {
9596 result = singleton ( any ( PropertyContent c | c .getProperty ( ) = p .getSourceDeclaration ( ) ) )
9697 }
9798
99+ /** Gets a singleton field access path. */
100+ AccessPath field ( Field f ) {
101+ result = singleton ( any ( FieldContent c | c .getField ( ) = f .getSourceDeclaration ( ) ) )
102+ }
103+
98104 /** Gets an access path representing a property inside a collection. */
99105 AccessPath properties ( Property p ) { result = TConsAccessPath ( any ( ElementContent c ) , property ( p ) ) }
100106}
@@ -1714,9 +1720,7 @@ class SystemThreadingTasksTaskFlow extends LibraryTypeDataFlow, SystemThreadingT
17141720}
17151721
17161722/** Data flow for `System.Threading.Tasks.Task<>`. */
1717- class SystemThreadingTasksTaskTFlow extends LibraryTypeDataFlow {
1718- SystemThreadingTasksTaskTFlow ( ) { this instanceof SystemThreadingTasksTaskTClass }
1719-
1723+ class SystemThreadingTasksTaskTFlow extends LibraryTypeDataFlow , SystemThreadingTasksTaskTClass {
17201724 override predicate callableFlow (
17211725 CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
17221726 SourceDeclarationCallable c , boolean preservesValue
@@ -1807,6 +1811,14 @@ class SystemThreadingTasksTaskTFlow extends LibraryTypeDataFlow {
18071811 sinkAp = AccessPath:: property ( this .( SystemThreadingTasksTaskTClass ) .getResultProperty ( ) )
18081812 )
18091813 )
1814+ or
1815+ m = this .getGetAwaiterMethod ( ) and
1816+ source = TCallableFlowSourceQualifier ( ) and
1817+ sourceAp = AccessPath:: empty ( ) and
1818+ sink = TCallableFlowSinkReturn ( ) and
1819+ sinkAp =
1820+ AccessPath:: field ( any ( SystemRuntimeCompilerServicesTaskAwaiterStruct s )
1821+ .getUnderlyingTaskField ( ) )
18101822 }
18111823}
18121824
@@ -1891,6 +1903,29 @@ class SystemThreadingTasksFactoryFlow extends LibraryTypeDataFlow {
18911903 }
18921904}
18931905
1906+ /** Data flow for `System.Runtime.CompilerServices.TaskAwaiter<>`. */
1907+ class SystemRuntimeCompilerServicesTaskAwaiterFlow extends LibraryTypeDataFlow ,
1908+ SystemRuntimeCompilerServicesTaskAwaiterStruct {
1909+ override predicate callableFlow (
1910+ CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
1911+ SourceDeclarationCallable c , boolean preservesValue
1912+ ) {
1913+ preservesValue = true and
1914+ c = this .getGetResultMethod ( ) and
1915+ source = TCallableFlowSourceQualifier ( ) and
1916+ sourceAp =
1917+ AccessPath:: cons ( any ( FieldContent fc | fc .getField ( ) = this .getUnderlyingTaskField ( ) ) ,
1918+ AccessPath:: property ( any ( SystemThreadingTasksTaskTClass t ) .getResultProperty ( ) ) ) and
1919+ sink = TCallableFlowSinkReturn ( ) and
1920+ sinkAp = AccessPath:: empty ( )
1921+ }
1922+
1923+ override predicate requiresAccessPath ( Content head , AccessPath tail ) {
1924+ head .( FieldContent ) .getField ( ) = this .getUnderlyingTaskField ( ) and
1925+ tail = AccessPath:: property ( any ( SystemThreadingTasksTaskTClass t ) .getResultProperty ( ) )
1926+ }
1927+ }
1928+
18941929/** Data flow for `System.Text.Encoding`. */
18951930library class SystemTextEncodingFlow extends LibraryTypeDataFlow , SystemTextEncodingClass {
18961931 override predicate callableFlow (
0 commit comments