@@ -29,12 +29,16 @@ private class ReturnNodeExt extends DataFlow::Node {
2929 }
3030}
3131
32- class DataFlowTargetApi extends TargetApiSpecific {
33- DataFlowTargetApi ( ) { not isUninterestingForDataFlowModels ( this ) }
32+ class DataFlowSummaryTargetApi extends SummaryTargetApi {
33+ DataFlowSummaryTargetApi ( ) { not isUninterestingForDataFlowModels ( this ) }
3434}
3535
36+ class DataFlowSourceTargetApi = SourceTargetApi ;
37+
38+ class DataFlowSinkTargetApi = SinkTargetApi ;
39+
3640private module ModelPrintingInput implements ModelPrintingSig {
37- class Api = DataFlowTargetApi ;
41+ class Api = TargetApiBase ;
3842
3943 string getProvenance ( ) { result = "df-generated" }
4044}
@@ -89,7 +93,7 @@ string asInputArgument(DataFlow::Node source) { result = asInputArgumentSpecific
8993/**
9094 * Gets the summary model of `api`, if it follows the `fluent` programming pattern (returns `this`).
9195 */
92- string captureQualifierFlow ( TargetApiSpecific api ) {
96+ string captureQualifierFlow ( DataFlowSummaryTargetApi api ) {
9397 exists ( ReturnNodeExt ret |
9498 api = returnNodeEnclosingCallable ( ret ) and
9599 isOwnInstanceAccessNode ( ret )
@@ -150,7 +154,7 @@ module PropagateFlowConfig implements DataFlow::StateConfigSig {
150154
151155 predicate isSource ( DataFlow:: Node source , FlowState state ) {
152156 source instanceof DataFlow:: ParameterNode and
153- source .getEnclosingCallable ( ) instanceof DataFlowTargetApi and
157+ source .getEnclosingCallable ( ) instanceof DataFlowSummaryTargetApi and
154158 state .( TaintRead ) .getStep ( ) = 0
155159 }
156160
@@ -195,7 +199,7 @@ private module PropagateFlow = TaintTracking::GlobalWithState<PropagateFlowConfi
195199/**
196200 * Gets the summary model(s) of `api`, if there is flow from parameters to return value or parameter.
197201 */
198- string captureThroughFlow ( DataFlowTargetApi api ) {
202+ string captureThroughFlow ( DataFlowSummaryTargetApi api ) {
199203 exists ( DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt , string input , string output |
200204 PropagateFlow:: flow ( p , returnNodeExt ) and
201205 returnNodeExt .( DataFlow:: Node ) .getEnclosingCallable ( ) = api and
@@ -222,10 +226,8 @@ module PropagateFromSourceConfig implements DataFlow::ConfigSig {
222226 }
223227
224228 predicate isSink ( DataFlow:: Node sink ) {
225- exists ( DataFlowTargetApi c |
226- sink instanceof ReturnNodeExt and
227- sink .getEnclosingCallable ( ) = c
228- )
229+ sink instanceof ReturnNodeExt and
230+ sink .getEnclosingCallable ( ) instanceof DataFlowSourceTargetApi
229231 }
230232
231233 DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSinkCallContext }
@@ -244,7 +246,7 @@ private module PropagateFromSource = TaintTracking::Global<PropagateFromSourceCo
244246/**
245247 * Gets the source model(s) of `api`, if there is flow from an existing known source to the return of `api`.
246248 */
247- string captureSource ( DataFlowTargetApi api ) {
249+ string captureSource ( DataFlowSourceTargetApi api ) {
248250 exists ( DataFlow:: Node source , ReturnNodeExt sink , string kind |
249251 PropagateFromSource:: flow ( source , sink ) and
250252 ExternalFlow:: sourceNode ( source , kind ) and
@@ -262,7 +264,9 @@ string captureSource(DataFlowTargetApi api) {
262264 * into an existing known sink (then the API itself becomes a sink).
263265 */
264266module PropagateToSinkConfig implements DataFlow:: ConfigSig {
265- predicate isSource ( DataFlow:: Node source ) { apiSource ( source ) }
267+ predicate isSource ( DataFlow:: Node source ) {
268+ apiSource ( source ) and source .getEnclosingCallable ( ) instanceof DataFlowSinkTargetApi
269+ }
266270
267271 predicate isSink ( DataFlow:: Node sink ) {
268272 exists ( string kind | isRelevantSinkKind ( kind ) and ExternalFlow:: sinkNode ( sink , kind ) )
@@ -286,7 +290,7 @@ private module PropagateToSink = TaintTracking::Global<PropagateToSinkConfig>;
286290/**
287291 * Gets the sink model(s) of `api`, if there is flow from a parameter to an existing known sink.
288292 */
289- string captureSink ( DataFlowTargetApi api ) {
293+ string captureSink ( DataFlowSinkTargetApi api ) {
290294 exists ( DataFlow:: Node src , DataFlow:: Node sink , string kind |
291295 PropagateToSink:: flow ( src , sink ) and
292296 ExternalFlow:: sinkNode ( sink , kind ) and
0 commit comments