@@ -34,6 +34,8 @@ private newtype TAccessPath =
3434 or
3535 tail = AccessPath:: singleton ( _) and
3636 head instanceof ElementContent
37+ or
38+ tail = AccessPath:: element ( )
3739 }
3840
3941/** An access path. */
@@ -1658,7 +1660,6 @@ class SystemThreadingTasksTaskFlow extends LibraryTypeDataFlow, SystemThreadingT
16581660 (
16591661 m .hasName ( "ContinueWith" ) and
16601662 sourceAp = AccessPath:: empty ( ) and
1661- sinkAp = AccessPath:: empty ( ) and
16621663 (
16631664 // flow from supplied state to supplied delegate
16641665 exists ( ConstructedDelegateType delegate , int i , int j , int k |
@@ -1670,44 +1671,44 @@ class SystemThreadingTasksTaskFlow extends LibraryTypeDataFlow, SystemThreadingT
16701671 ) and
16711672 delegate .getTypeArgument ( k ) instanceof ObjectType and
16721673 source = TCallableFlowSourceArg ( i ) and
1673- sink = getDelegateFlowSinkArg ( m , j , k )
1674+ sink = getDelegateFlowSinkArg ( m , j , k ) and
1675+ sinkAp = AccessPath:: empty ( )
16741676 )
16751677 or
16761678 // flow out of supplied function
16771679 exists ( ConstructedDelegateType func , int i |
16781680 m .getParameter ( i ) .getType ( ) = func and
16791681 func .getUnboundGeneric ( ) instanceof SystemFuncDelegateType and
16801682 source = getDelegateFlowSourceArg ( m , i ) and
1681- sink = TCallableFlowSinkReturn ( )
1683+ sink = TCallableFlowSinkReturn ( ) and
1684+ sinkAp = AccessPath:: property ( any ( SystemThreadingTasksTaskTClass c ) .getResultProperty ( ) )
16821685 )
16831686 )
16841687 or
16851688 m .hasName ( "FromResult" ) and
1689+ source = TCallableFlowSourceArg ( 0 ) and
16861690 sourceAp = AccessPath:: empty ( ) and
1687- sinkAp = AccessPath:: empty ( ) and
1688- (
1689- source = TCallableFlowSourceArg ( 0 ) and
1690- sink = TCallableFlowSinkReturn ( )
1691- )
1691+ sink = TCallableFlowSinkReturn ( ) and
1692+ sinkAp = AccessPath:: property ( any ( SystemThreadingTasksTaskTClass c ) .getResultProperty ( ) )
16921693 or
16931694 m .hasName ( "Run" ) and
1695+ m .getReturnType ( ) = any ( SystemThreadingTasksTaskTClass c ) .getAConstructedGeneric ( ) and
1696+ m .( UnboundGenericMethod ) .getNumberOfTypeParameters ( ) = 1 and
1697+ source = TCallableFlowSourceDelegateArg ( 0 ) and
16941698 sourceAp = AccessPath:: empty ( ) and
1695- sinkAp = AccessPath:: empty ( ) and
1696- (
1697- m .getReturnType ( ) = any ( SystemThreadingTasksTaskTClass c ) .getAConstructedGeneric ( ) and
1698- m .( UnboundGenericMethod ) .getNumberOfTypeParameters ( ) = 1 and
1699- source = TCallableFlowSourceDelegateArg ( 0 ) and
1700- sink = TCallableFlowSinkReturn ( )
1701- )
1699+ sink = TCallableFlowSinkReturn ( ) and
1700+ sinkAp = AccessPath:: property ( any ( SystemThreadingTasksTaskTClass c ) .getResultProperty ( ) )
17021701 or
17031702 m .getName ( ) .regexpMatch ( "WhenAll|WhenAny" ) and
1704- sinkAp = AccessPath:: empty ( ) and
1705- (
1706- m .getReturnType ( ) = any ( SystemThreadingTasksTaskTClass c ) .getAConstructedGeneric ( ) and
1707- m .( UnboundGenericMethod ) .getNumberOfTypeParameters ( ) = 1 and
1708- source = getFlowSourceArg ( m , _, sourceAp ) and
1709- sink = TCallableFlowSinkReturn ( )
1710- )
1703+ m .getReturnType ( ) = any ( SystemThreadingTasksTaskTClass c ) .getAConstructedGeneric ( ) and
1704+ m .( UnboundGenericMethod ) .getNumberOfTypeParameters ( ) = 1 and
1705+ source = getFlowSourceArg ( m , _, _) and
1706+ sourceAp = AccessPath:: properties ( any ( SystemThreadingTasksTaskTClass c ) .getResultProperty ( ) ) and
1707+ sink = TCallableFlowSinkReturn ( ) and
1708+ sinkAp =
1709+ AccessPath:: cons ( any ( PropertyContent c |
1710+ c .getProperty ( ) = any ( SystemThreadingTasksTaskTClass tc ) .getResultProperty ( )
1711+ ) , AccessPath:: element ( ) )
17111712 )
17121713 }
17131714}
@@ -1717,32 +1718,38 @@ class SystemThreadingTasksTaskTFlow extends LibraryTypeDataFlow {
17171718 SystemThreadingTasksTaskTFlow ( ) { this instanceof SystemThreadingTasksTaskTClass }
17181719
17191720 override predicate callableFlow (
1720- CallableFlowSource source , CallableFlowSink sink , SourceDeclarationCallable c ,
1721- boolean preservesValue
1721+ CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
1722+ SourceDeclarationCallable c , boolean preservesValue
17221723 ) {
17231724 (
1724- constructorFlow ( source , sink , c )
1725+ constructorFlow ( source , sourceAp , sink , sinkAp , c )
17251726 or
1726- methodFlow ( source , sink , c )
1727- or
1728- exists ( Property p |
1729- propertyFlow ( p ) and
1730- source = TCallableFlowSourceQualifier ( ) and
1731- sink = TCallableFlowSinkReturn ( ) and
1732- c = p .getGetter ( )
1733- )
1727+ methodFlow ( source , sourceAp , sink , sinkAp , c )
17341728 ) and
17351729 preservesValue = true
1730+ or
1731+ exists ( Property p |
1732+ p = this .( SystemThreadingTasksTaskTClass ) .getResultProperty ( ) and
1733+ source = TCallableFlowSourceQualifier ( ) and
1734+ sourceAp = AccessPath:: empty ( ) and
1735+ sink = TCallableFlowSinkReturn ( ) and
1736+ sinkAp = AccessPath:: empty ( ) and
1737+ c = p .getGetter ( ) and
1738+ preservesValue = false
1739+ )
17361740 }
17371741
1738- private predicate constructorFlow ( CallableFlowSource source , CallableFlowSink sink , Constructor c ) {
1742+ private predicate constructorFlow (
1743+ CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
1744+ Constructor c
1745+ ) {
17391746 // flow from supplied function into constructed Task
17401747 c .getDeclaringType ( ) = this and
1741- (
1742- c . getParameter ( 0 ) . getType ( ) = any ( SystemFuncDelegateType t ) . getAConstructedGeneric ( ) and
1743- source = TCallableFlowSourceDelegateArg ( 0 ) and
1744- sink = TCallableFlowSinkReturn ( )
1745- )
1748+ c . getParameter ( 0 ) . getType ( ) = any ( SystemFuncDelegateType t ) . getAConstructedGeneric ( ) and
1749+ source = TCallableFlowSourceDelegateArg ( 0 ) and
1750+ sourceAp = AccessPath :: empty ( ) and
1751+ sink = TCallableFlowSinkReturn ( ) and
1752+ sinkAp = AccessPath :: property ( this . ( SystemThreadingTasksTaskTClass ) . getResultProperty ( ) )
17461753 or
17471754 // flow from supplied state to supplied delegate
17481755 c .getDeclaringType ( ) = this and
@@ -1752,12 +1759,15 @@ class SystemThreadingTasksTaskTFlow extends LibraryTypeDataFlow {
17521759 func .getUnboundGeneric ( ) .( SystemFuncDelegateType ) .getNumberOfTypeParameters ( ) = 2 and
17531760 func .getTypeArgument ( 0 ) instanceof ObjectType and
17541761 source = TCallableFlowSourceArg ( 1 ) and
1755- sink = getDelegateFlowSinkArg ( c , 0 , 0 )
1762+ sourceAp = AccessPath:: empty ( ) and
1763+ sink = getDelegateFlowSinkArg ( c , 0 , 0 ) and
1764+ sinkAp = AccessPath:: empty ( )
17561765 )
17571766 }
17581767
17591768 private predicate methodFlow (
1760- CallableFlowSource source , CallableFlowSink sink , SourceDeclarationMethod m
1769+ CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
1770+ SourceDeclarationMethod m
17611771 ) {
17621772 m .getDeclaringType ( ) = this and
17631773 m .hasName ( "ContinueWith" ) and
@@ -1774,28 +1784,30 @@ class SystemThreadingTasksTaskTFlow extends LibraryTypeDataFlow {
17741784 delegate .getTypeArgument ( j ) instanceof ObjectType and
17751785 m .getParameter ( k ) .getType ( ) instanceof ObjectType and
17761786 source = TCallableFlowSourceArg ( k ) and
1777- sink = getDelegateFlowSinkArg ( m , i , j )
1787+ sourceAp = AccessPath:: empty ( ) and
1788+ sink = getDelegateFlowSinkArg ( m , i , j ) and
1789+ sinkAp = AccessPath:: empty ( )
17781790 )
17791791 or
17801792 // flow from this task to supplied delegate
17811793 delegate .getTypeArgument ( j ) = this and
17821794 source = TCallableFlowSourceQualifier ( ) and
1783- sink = getDelegateFlowSinkArg ( m , i , j )
1795+ sourceAp = AccessPath:: empty ( ) and
1796+ sink = getDelegateFlowSinkArg ( m , i , j ) and
1797+ sinkAp = AccessPath:: empty ( )
17841798 )
17851799 or
17861800 // flow out of supplied function
17871801 exists ( ConstructedDelegateType func , int i |
17881802 m .getParameter ( i ) .getType ( ) = func and
17891803 func .getUnboundGeneric ( ) instanceof SystemFuncDelegateType and
17901804 source = getDelegateFlowSourceArg ( m , i ) and
1791- sink = TCallableFlowSinkReturn ( )
1805+ sourceAp = AccessPath:: empty ( ) and
1806+ sink = TCallableFlowSinkReturn ( ) and
1807+ sinkAp = AccessPath:: property ( this .( SystemThreadingTasksTaskTClass ) .getResultProperty ( ) )
17921808 )
17931809 )
17941810 }
1795-
1796- private predicate propertyFlow ( Property p ) {
1797- p = this .( SystemThreadingTasksTaskTClass ) .getResultProperty ( )
1798- }
17991811}
18001812
18011813/** Data flow for `System.Threading.Tasks.TaskFactory`(`<TResult>`). */
@@ -1806,15 +1818,16 @@ class SystemThreadingTasksFactoryFlow extends LibraryTypeDataFlow {
18061818 }
18071819
18081820 override predicate callableFlow (
1809- CallableFlowSource source , CallableFlowSink sink , SourceDeclarationCallable c ,
1810- boolean preservesValue
1821+ CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
1822+ SourceDeclarationCallable c , boolean preservesValue
18111823 ) {
1812- methodFlow ( source , sink , c ) and
1824+ methodFlow ( source , sourceAp , sink , sinkAp , c ) and
18131825 preservesValue = true
18141826 }
18151827
18161828 private predicate methodFlow (
1817- CallableFlowSource source , CallableFlowSink sink , SourceDeclarationMethod m
1829+ CallableFlowSource source , AccessPath sourceAp , CallableFlowSink sink , AccessPath sinkAp ,
1830+ SourceDeclarationMethod m
18181831 ) {
18191832 m .getDeclaringType ( ) = this and
18201833 (
@@ -1831,15 +1844,19 @@ class SystemThreadingTasksFactoryFlow extends LibraryTypeDataFlow {
18311844 delegate .getUnboundGeneric ( ) instanceof SystemFuncDelegateType
18321845 ) and
18331846 source = TCallableFlowSourceArg ( i ) and
1834- sink = getDelegateFlowSinkArg ( m , j , k )
1847+ sourceAp = AccessPath:: empty ( ) and
1848+ sink = getDelegateFlowSinkArg ( m , j , k ) and
1849+ sinkAp = AccessPath:: empty ( )
18351850 )
18361851 or
18371852 // flow out of supplied function
18381853 exists ( ConstructedDelegateType func , int i |
18391854 m .getParameter ( i ) .getType ( ) = func and
18401855 func .getUnboundGeneric ( ) instanceof SystemFuncDelegateType and
18411856 source = getDelegateFlowSourceArg ( m , i ) and
1842- sink = TCallableFlowSinkReturn ( )
1857+ sourceAp = AccessPath:: empty ( ) and
1858+ sink = TCallableFlowSinkReturn ( ) and
1859+ sinkAp = AccessPath:: property ( any ( SystemThreadingTasksTaskTClass c ) .getResultProperty ( ) )
18431860 )
18441861 )
18451862 or
@@ -1855,15 +1872,19 @@ class SystemThreadingTasksFactoryFlow extends LibraryTypeDataFlow {
18551872 ) and
18561873 delegate .getTypeArgument ( k ) instanceof ObjectType and
18571874 source = TCallableFlowSourceArg ( i ) and
1858- sink = getDelegateFlowSinkArg ( m , j , k )
1875+ sourceAp = AccessPath:: empty ( ) and
1876+ sink = getDelegateFlowSinkArg ( m , j , k ) and
1877+ sinkAp = AccessPath:: empty ( )
18591878 )
18601879 or
18611880 // flow out of supplied function
18621881 exists ( ConstructedDelegateType func , int i |
18631882 m .getParameter ( i ) .getType ( ) = func and
18641883 func .getUnboundGeneric ( ) instanceof SystemFuncDelegateType and
18651884 source = getDelegateFlowSourceArg ( m , i ) and
1866- sink = TCallableFlowSinkReturn ( )
1885+ sourceAp = AccessPath:: empty ( ) and
1886+ sink = TCallableFlowSinkReturn ( ) and
1887+ sinkAp = AccessPath:: property ( any ( SystemThreadingTasksTaskTClass c ) .getResultProperty ( ) )
18671888 )
18681889 )
18691890 )
0 commit comments