@@ -260,6 +260,23 @@ module ClientRequest {
260
260
}
261
261
}
262
262
263
+ /** An expression that is used as a credential in a request. */
264
+ private class AuthorizationHeader extends CredentialsExpr {
265
+ AuthorizationHeader ( ) {
266
+ exists ( DataFlow:: PropWrite write | write .getPropertyName ( ) = "Authorization" |
267
+ this = write .getRhs ( ) .asExpr ( )
268
+ )
269
+ or
270
+ exists ( DataFlow:: MethodCallNode call | call .getMethodName ( ) = [ "append" , "set" ] |
271
+ call .getNumArgument ( ) = 2 and
272
+ call .getArgument ( 0 ) .mayHaveStringValue ( "Authorization" ) and
273
+ this = call .getArgument ( 1 ) .asExpr ( )
274
+ )
275
+ }
276
+
277
+ override string getCredentialsKind ( ) { result = "authorization headers" }
278
+ }
279
+
263
280
/**
264
281
* Provides predicates for working with `fetch` and its platform-specific instances as a single module.
265
282
*/
@@ -273,36 +290,6 @@ module ClientRequest {
273
290
result = DataFlow:: globalVarRef ( "fetch" ) // https://fetch.spec.whatwg.org/#fetch-api
274
291
}
275
292
276
- /**
277
- * Gets an instance of the `Headers` class.
278
- */
279
- private DataFlow:: NewNode header ( ) {
280
- result = moduleImport ( ) .getAConstructorInvocation ( "Headers" )
281
- or
282
- result = DataFlow:: globalVarRef ( "Headers" ) .getAnInstantiation ( ) // https://fetch.spec.whatwg.org/#headers-class
283
- }
284
-
285
- /** An expression that is used as a credential in a fetch-request. */
286
- private class FetchAuthorization extends CredentialsExpr {
287
- FetchAuthorization ( ) {
288
- exists ( DataFlow:: Node headerObject |
289
- headerObject = header ( ) .getArgument ( 0 )
290
- or
291
- headerObject = moduleImport ( ) .getACall ( ) .getOptionArgument ( 1 , "headers" )
292
- |
293
- this = headerObject .getALocalSource ( ) .getAPropertyWrite ( "Authorization" ) .getRhs ( ) .asExpr ( )
294
- )
295
- or
296
- exists ( DataFlow:: MethodCallNode appendCall |
297
- appendCall = header ( ) .getAMethodCall ( [ "append" , "set" ] ) and
298
- appendCall .getArgument ( 0 ) .mayHaveStringValue ( "Authorization" ) and
299
- this = appendCall .getArgument ( 1 ) .asExpr ( )
300
- )
301
- }
302
-
303
- override string getCredentialsKind ( ) { result = "authorization headers" }
304
- }
305
-
306
293
/**
307
294
* A model of a URL request made using an implementation of the `fetch` API.
308
295
*/
0 commit comments