@@ -145,7 +145,7 @@ private class TaintStore extends TaintState, TTaintStore {
145145 *
146146 * This can be used to generate Flow summaries for APIs from parameter to return.
147147 */
148- module ThroughFlowConfig implements DataFlow:: StateConfigSig {
148+ module PropagateFlowConfig implements DataFlow:: StateConfigSig {
149149 class FlowState = TaintState ;
150150
151151 predicate isSource ( DataFlow:: Node source , FlowState state ) {
@@ -190,14 +190,14 @@ module ThroughFlowConfig implements DataFlow::StateConfigSig {
190190 }
191191}
192192
193- private module ThroughFlow = TaintTracking:: GlobalWithState< ThroughFlowConfig > ;
193+ private module PropagateFlow = TaintTracking:: GlobalWithState< PropagateFlowConfig > ;
194194
195195/**
196196 * Gets the summary model(s) of `api`, if there is flow from parameters to return value or parameter.
197197 */
198198string captureThroughFlow ( DataFlowTargetApi api ) {
199199 exists ( DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt , string input , string output |
200- ThroughFlow :: flow ( p , returnNodeExt ) and
200+ PropagateFlow :: flow ( p , returnNodeExt ) and
201201 returnNodeExt .( DataFlow:: Node ) .getEnclosingCallable ( ) = api and
202202 input = parameterNodeAsInput ( p ) and
203203 output = returnNodeExt .getOutput ( ) and
@@ -213,8 +213,13 @@ string captureThroughFlow(DataFlowTargetApi api) {
213213 * This can be used to generate Source summaries for an API, if the API expose an already known source
214214 * via its return (then the API itself becomes a source).
215215 */
216- module FromSourceConfig implements DataFlow:: ConfigSig {
217- predicate isSource ( DataFlow:: Node source ) { ExternalFlow:: sourceNode ( source , _) }
216+ module PropagateFromSourceConfig implements DataFlow:: ConfigSig {
217+ predicate isSource ( DataFlow:: Node source ) {
218+ exists ( string kind |
219+ isRelevantSourceKind ( kind ) and
220+ ExternalFlow:: sourceNode ( source , kind )
221+ )
222+ }
218223
219224 predicate isSink ( DataFlow:: Node sink ) {
220225 exists ( DataFlowTargetApi c |
@@ -225,22 +230,26 @@ module FromSourceConfig implements DataFlow::ConfigSig {
225230
226231 DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSinkCallContext }
227232
233+ predicate isBarrier ( DataFlow:: Node n ) {
234+ exists ( Type t | t = n .getType ( ) and not isRelevantType ( t ) )
235+ }
236+
228237 predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
229238 isRelevantTaintStep ( node1 , node2 )
230239 }
231240}
232241
233- private module FromSource = TaintTracking:: Global< FromSourceConfig > ;
242+ private module PropagateFromSource = TaintTracking:: Global< PropagateFromSourceConfig > ;
234243
235244/**
236245 * Gets the source model(s) of `api`, if there is flow from an existing known source to the return of `api`.
237246 */
238247string captureSource ( DataFlowTargetApi api ) {
239248 exists ( DataFlow:: Node source , ReturnNodeExt sink , string kind |
240- FromSource :: flow ( source , sink ) and
249+ PropagateFromSource :: flow ( source , sink ) and
241250 ExternalFlow:: sourceNode ( source , kind ) and
242251 api = sink .getEnclosingCallable ( ) and
243- isRelevantSourceKind ( kind ) and
252+ not irrelevantSourceSinkApi ( source . getEnclosingCallable ( ) , api ) and
244253 result = ModelPrinting:: asSourceModel ( api , sink .getOutput ( ) , kind )
245254 )
246255}
@@ -255,9 +264,15 @@ string captureSource(DataFlowTargetApi api) {
255264module PropagateToSinkConfig implements DataFlow:: ConfigSig {
256265 predicate isSource ( DataFlow:: Node source ) { apiSource ( source ) }
257266
258- predicate isSink ( DataFlow:: Node sink ) { ExternalFlow:: sinkNode ( sink , _) }
267+ predicate isSink ( DataFlow:: Node sink ) {
268+ exists ( string kind | isRelevantSinkKind ( kind ) and ExternalFlow:: sinkNode ( sink , kind ) )
269+ }
259270
260- predicate isBarrier ( DataFlow:: Node node ) { sinkModelSanitizer ( node ) }
271+ predicate isBarrier ( DataFlow:: Node node ) {
272+ exists ( Type t | t = node .getType ( ) and not isRelevantType ( t ) )
273+ or
274+ sinkModelSanitizer ( node )
275+ }
261276
262277 DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSourceCallContext }
263278
@@ -276,7 +291,6 @@ string captureSink(DataFlowTargetApi api) {
276291 PropagateToSink:: flow ( src , sink ) and
277292 ExternalFlow:: sinkNode ( sink , kind ) and
278293 api = src .getEnclosingCallable ( ) and
279- isRelevantSinkKind ( kind ) and
280294 result = ModelPrinting:: asSinkModel ( api , asInputArgument ( src ) , kind )
281295 )
282296}
0 commit comments