@@ -77,7 +77,11 @@ module ExternalAPIUsedWithUntrustedData {
77
77
private class DefaultSafeExternalAPIPackage extends SafeExternalAPIPackage {
78
78
DefaultSafeExternalAPIPackage ( ) {
79
79
// Promise libraries are safe and generate too much noise if included
80
- this = [ "bluebird" , "q" , "deferred" , "when" , "promise" , "promises" , "es6-promise" , "promise-polyfill" ]
80
+ this =
81
+ [
82
+ "bluebird" , "q" , "deferred" , "when" , "promise" , "promises" , "es6-promise" ,
83
+ "promise-polyfill"
84
+ ]
81
85
}
82
86
}
83
87
@@ -177,7 +181,9 @@ module ExternalAPIUsedWithUntrustedData {
177
181
private string getSimplifiedName ( API:: Node node ) {
178
182
node = API:: moduleImport ( result )
179
183
or
180
- exists ( API:: Node base , string basename | getDepth ( base ) < getDepth ( node ) and basename = getSimplifiedName ( base ) |
184
+ exists ( API:: Node base , string basename |
185
+ getDepth ( base ) < getDepth ( node ) and basename = getSimplifiedName ( base )
186
+ |
181
187
// In practice there is no need to distinguish between 'new X' and 'X()'
182
188
node = [ base .getInstance ( ) , base .getReturn ( ) ] and
183
189
result = basename + "()"
@@ -215,9 +221,13 @@ module ExternalAPIUsedWithUntrustedData {
215
221
result = basename + ".[callback].[param '" + paramName + "']"
216
222
or
217
223
exists ( string callbackName , string index |
218
- node = getNamedParameter ( base .getASuccessor ( "parameter " + index ) .getMember ( callbackName ) , paramName ) and
224
+ node =
225
+ getNamedParameter ( base .getASuccessor ( "parameter " + index ) .getMember ( callbackName ) ,
226
+ paramName ) and
219
227
index != "-1" and // ignore receiver
220
- result = basename + ".[callback " + index + " '" + callbackName + "'].[param '" + paramName + "']"
228
+ result =
229
+ basename + ".[callback " + index + " '" + callbackName + "'].[param '" + paramName +
230
+ "']"
221
231
)
222
232
)
223
233
)
@@ -251,7 +261,9 @@ module ExternalAPIUsedWithUntrustedData {
251
261
// Ignore arguments to a method such as 'indexOf' that's likely called on a string or array value
252
262
not isCommonBuiltinMethodName ( this .( DataFlow:: CallNode ) .getCalleeName ( ) ) and
253
263
// Not already modeled as a flow/taint step
254
- not exists ( DataFlow:: Node arg | arg = this .getAnArgument ( ) and not arg instanceof DeepObjectSink |
264
+ not exists ( DataFlow:: Node arg |
265
+ arg = this .getAnArgument ( ) and not arg instanceof DeepObjectSink
266
+ |
255
267
any ( TaintTracking:: AdditionalTaintStep s ) .step ( arg , _)
256
268
or
257
269
exists ( DataFlow:: AdditionalFlowStep s |
@@ -305,9 +317,7 @@ module ExternalAPIUsedWithUntrustedData {
305
317
)
306
318
}
307
319
308
- override string getApiName ( ) {
309
- result = invoke .getApiName ( ) + " [param *]"
310
- }
320
+ override string getApiName ( ) { result = invoke .getApiName ( ) + " [param *]" }
311
321
}
312
322
313
323
/** A "named argument" to an external API call, seen as a sink. */
@@ -317,7 +327,7 @@ module ExternalAPIUsedWithUntrustedData {
317
327
string prop ;
318
328
319
329
NamedParameterSink ( ) {
320
- exists ( DataFlow:: ObjectLiteralNode object , DataFlow:: PropWrite write |
330
+ exists ( DataFlow:: ObjectLiteralNode object , DataFlow:: PropWrite write |
321
331
object = invoke .getArgument ( index ) and
322
332
isNamedArgumentObject ( object ) and
323
333
write = object .getAPropertyWrite ( ) and
@@ -331,7 +341,9 @@ module ExternalAPIUsedWithUntrustedData {
331
341
)
332
342
}
333
343
334
- override string getApiName ( ) { result = invoke .getApiName ( ) + " [param " + index + " '" + prop + "']" }
344
+ override string getApiName ( ) {
345
+ result = invoke .getApiName ( ) + " [param " + index + " '" + prop + "']"
346
+ }
335
347
}
336
348
337
349
/** The return value from a direct callback to an external API call, seen as a sink */
@@ -345,7 +357,9 @@ module ExternalAPIUsedWithUntrustedData {
345
357
not invoke .getCalleeName ( ) = [ "then" , "catch" , "finally" ]
346
358
}
347
359
348
- override string getApiName ( ) { result = invoke .getApiName ( ) + " [callback " + index + " result]" }
360
+ override string getApiName ( ) {
361
+ result = invoke .getApiName ( ) + " [callback " + index + " result]"
362
+ }
349
363
}
350
364
351
365
/** The return value from a named callback to an external API call, seen as a sink. */
@@ -355,9 +369,16 @@ module ExternalAPIUsedWithUntrustedData {
355
369
string prop ;
356
370
357
371
NamedCallbackSink ( ) {
358
- this = invoke .getOptionArgument ( index , prop ) .getALocalSource ( ) .( DataFlow:: FunctionNode ) .getAReturn ( )
372
+ this =
373
+ invoke
374
+ .getOptionArgument ( index , prop )
375
+ .getALocalSource ( )
376
+ .( DataFlow:: FunctionNode )
377
+ .getAReturn ( )
359
378
}
360
379
361
- override string getApiName ( ) { result = invoke .getApiName ( ) + " [callback " + index + " '" + prop + "' result]" }
380
+ override string getApiName ( ) {
381
+ result = invoke .getApiName ( ) + " [callback " + index + " '" + prop + "' result]"
382
+ }
362
383
}
363
384
}
0 commit comments