@@ -1618,6 +1618,9 @@ abstract class PathNode extends TPathNode {
1618
1618
/** Gets a successor of this node, if any. */
1619
1619
abstract PathNode getASuccessor ( ) ;
1620
1620
1621
+ /** Holds if this node is a source. */
1622
+ abstract predicate isSource ( ) ;
1623
+
1621
1624
private string ppAp ( ) {
1622
1625
this instanceof PathNodeSink and result = ""
1623
1626
or
@@ -1683,12 +1686,6 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
1683
1686
// an intermediate step to another intermediate node
1684
1687
result = getSuccMid ( )
1685
1688
or
1686
- // a final step to a sink via one or more local steps
1687
- localFlowStepPlus ( node , result .getNode ( ) , _, config ) and
1688
- ap instanceof AccessPathNil and
1689
- result instanceof PathNodeSink and
1690
- result .getConfiguration ( ) = unbind ( this .getConfiguration ( ) )
1691
- or
1692
1689
// a final step to a sink via zero steps means we merge the last two steps to prevent trivial-looking edges
1693
1690
exists ( PathNodeMid mid |
1694
1691
mid = getSuccMid ( ) and
@@ -1697,23 +1694,12 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
1697
1694
result instanceof PathNodeSink and
1698
1695
result .getConfiguration ( ) = unbind ( mid .getConfiguration ( ) )
1699
1696
)
1700
- or
1701
- // a direct step from a source to a sink if a node is both
1702
- this instanceof PathNodeSource and
1703
- result instanceof PathNodeSink and
1704
- this .getNode ( ) = result .getNode ( ) and
1705
- result .getConfiguration ( ) = unbind ( this .getConfiguration ( ) )
1706
1697
}
1707
- }
1708
1698
1709
- /**
1710
- * A flow graph node corresponding to a source.
1711
- */
1712
- private class PathNodeSource extends PathNodeMid {
1713
- PathNodeSource ( ) {
1714
- getConfiguration ( ) .isSource ( getNode ( ) ) and
1715
- getCallContext ( ) instanceof CallContextAny and
1716
- getAp ( ) instanceof AccessPathNil
1699
+ override predicate isSource ( ) {
1700
+ config .isSource ( node ) and
1701
+ cc instanceof CallContextAny and
1702
+ ap instanceof AccessPathNil
1717
1703
}
1718
1704
}
1719
1705
@@ -1733,6 +1719,8 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
1733
1719
override Configuration getConfiguration ( ) { result = config }
1734
1720
1735
1721
override PathNode getASuccessor ( ) { none ( ) }
1722
+
1723
+ override predicate isSource ( ) { config .isSource ( node ) }
1736
1724
}
1737
1725
1738
1726
/**
@@ -1967,12 +1955,12 @@ private predicate valuePathThroughCallable(PathNodeMid mid, OutNode out, CallCon
1967
1955
* sinks.
1968
1956
*/
1969
1957
private predicate flowsTo (
1970
- PathNodeSource flowsource , PathNodeSink flowsink , Node source , Node sink ,
1971
- Configuration configuration
1958
+ PathNode flowsource , PathNodeSink flowsink , Node source , Node sink , Configuration configuration
1972
1959
) {
1960
+ flowsource .isSource ( ) and
1973
1961
flowsource .getConfiguration ( ) = configuration and
1974
1962
flowsource .getNode ( ) = source and
1975
- pathSuccPlus ( flowsource , flowsink ) and
1963
+ ( flowsource = flowsink or pathSuccPlus ( flowsource , flowsink ) ) and
1976
1964
flowsink .getNode ( ) = sink
1977
1965
}
1978
1966
0 commit comments