@@ -145,7 +145,7 @@ private class TaintStore extends TaintState, TTaintStore {
145
145
*
146
146
* This can be used to generate Flow summaries for APIs from parameter to return.
147
147
*/
148
- module ThroughFlowConfig implements DataFlow:: StateConfigSig {
148
+ module PropagateFlowConfig implements DataFlow:: StateConfigSig {
149
149
class FlowState = TaintState ;
150
150
151
151
predicate isSource ( DataFlow:: Node source , FlowState state ) {
@@ -190,14 +190,14 @@ module ThroughFlowConfig implements DataFlow::StateConfigSig {
190
190
}
191
191
}
192
192
193
- private module ThroughFlow = TaintTracking:: GlobalWithState< ThroughFlowConfig > ;
193
+ private module PropagateFlow = TaintTracking:: GlobalWithState< PropagateFlowConfig > ;
194
194
195
195
/**
196
196
* Gets the summary model(s) of `api`, if there is flow from parameters to return value or parameter.
197
197
*/
198
198
string captureThroughFlow ( DataFlowTargetApi api ) {
199
199
exists ( DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt , string input , string output |
200
- ThroughFlow :: flow ( p , returnNodeExt ) and
200
+ PropagateFlow :: flow ( p , returnNodeExt ) and
201
201
returnNodeExt .( DataFlow:: Node ) .getEnclosingCallable ( ) = api and
202
202
input = parameterNodeAsInput ( p ) and
203
203
output = returnNodeExt .getOutput ( ) and
@@ -213,8 +213,13 @@ string captureThroughFlow(DataFlowTargetApi api) {
213
213
* This can be used to generate Source summaries for an API, if the API expose an already known source
214
214
* via its return (then the API itself becomes a source).
215
215
*/
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
+ }
218
223
219
224
predicate isSink ( DataFlow:: Node sink ) {
220
225
exists ( DataFlowTargetApi c |
@@ -225,22 +230,26 @@ module FromSourceConfig implements DataFlow::ConfigSig {
225
230
226
231
DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSinkCallContext }
227
232
233
+ predicate isBarrier ( DataFlow:: Node n ) {
234
+ exists ( Type t | t = n .getType ( ) and not isRelevantType ( t ) )
235
+ }
236
+
228
237
predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
229
238
isRelevantTaintStep ( node1 , node2 )
230
239
}
231
240
}
232
241
233
- private module FromSource = TaintTracking:: Global< FromSourceConfig > ;
242
+ private module PropagateFromSource = TaintTracking:: Global< PropagateFromSourceConfig > ;
234
243
235
244
/**
236
245
* Gets the source model(s) of `api`, if there is flow from an existing known source to the return of `api`.
237
246
*/
238
247
string captureSource ( DataFlowTargetApi api ) {
239
248
exists ( DataFlow:: Node source , ReturnNodeExt sink , string kind |
240
- FromSource :: flow ( source , sink ) and
249
+ PropagateFromSource :: flow ( source , sink ) and
241
250
ExternalFlow:: sourceNode ( source , kind ) and
242
251
api = sink .getEnclosingCallable ( ) and
243
- isRelevantSourceKind ( kind ) and
252
+ not irrelevantSourceSinkApi ( source . getEnclosingCallable ( ) , api ) and
244
253
result = ModelPrinting:: asSourceModel ( api , sink .getOutput ( ) , kind )
245
254
)
246
255
}
@@ -255,9 +264,15 @@ string captureSource(DataFlowTargetApi api) {
255
264
module PropagateToSinkConfig implements DataFlow:: ConfigSig {
256
265
predicate isSource ( DataFlow:: Node source ) { apiSource ( source ) }
257
266
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
+ }
259
270
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
+ }
261
276
262
277
DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSourceCallContext }
263
278
@@ -276,7 +291,6 @@ string captureSink(DataFlowTargetApi api) {
276
291
PropagateToSink:: flow ( src , sink ) and
277
292
ExternalFlow:: sinkNode ( sink , kind ) and
278
293
api = src .getEnclosingCallable ( ) and
279
- isRelevantSinkKind ( kind ) and
280
294
result = ModelPrinting:: asSinkModel ( api , asInputArgument ( src ) , kind )
281
295
)
282
296
}
0 commit comments