@@ -468,6 +468,30 @@ module AiohttpWebModel {
468
468
override string getSourceType ( ) { result = "aiohttp.web.Request" }
469
469
}
470
470
471
+ /**
472
+ * Heuristic source that considers a method parameter with a type hint of `aiohttp.web.Request`
473
+ * as a parameter that will receive an `aiohttp.web.Request` instance when a request
474
+ * handler is invoked.
475
+ */
476
+ class AiohttpHeuristicRequestHandlerRequestParam extends Request:: InstanceSource ,
477
+ DataFlow:: ParameterNode , RemoteFlowSource:: Range
478
+ {
479
+ AiohttpHeuristicRequestHandlerRequestParam ( ) {
480
+ exists ( FunctionExpr fe , int i |
481
+ // the API::Node is the annotation (type hint), we need to get the annotated parameter
482
+ fe .getArgs ( ) .getAnnotation ( i ) =
483
+ API:: moduleImport ( "aiohttp" )
484
+ .getMember ( "web" )
485
+ .getMember ( "Request" )
486
+ .getAValueReachableFromSource ( )
487
+ .asExpr ( ) and
488
+ fe .getInnerScope ( ) .getArg ( i ) = this .getParameter ( )
489
+ )
490
+ }
491
+
492
+ override string getSourceType ( ) { result = "aiohttp web request parameter" }
493
+ }
494
+
471
495
/**
472
496
* A read of the `request` attribute on an instance of an aiohttp.web View class,
473
497
* which is the request being processed currently.
@@ -505,7 +529,10 @@ module AiohttpWebModel {
505
529
AiohttpWebResponseInstantiation ( ) {
506
530
this = apiNode .getACall ( ) and
507
531
(
508
- apiNode = API:: moduleImport ( "aiohttp" ) .getMember ( "web" ) .getMember ( "Response" )
532
+ apiNode =
533
+ API:: moduleImport ( "aiohttp" )
534
+ .getMember ( "web" )
535
+ .getMember ( [ "FileResponse" , "Response" , "StreamResponse" ] )
509
536
or
510
537
exists ( string httpExceptionClassName |
511
538
httpExceptionClassName in [
@@ -545,6 +572,14 @@ module AiohttpWebModel {
545
572
546
573
override DataFlow:: Node getMimetypeOrContentTypeArg ( ) {
547
574
result = this .getArgByName ( "content_type" )
575
+ or
576
+ exists ( DataFlow:: Node headers , Dict d |
577
+ headers = this .getArgByName ( "headers" ) .getALocalSource ( )
578
+ |
579
+ headers .asExpr ( ) = d and
580
+ d .getAKey ( ) .( StrConst ) .getText ( ) .toLowerCase ( ) = "content-type" and
581
+ d .getAValue ( ) = result .asExpr ( )
582
+ )
548
583
}
549
584
550
585
override string getMimetypeDefault ( ) {
@@ -556,6 +591,17 @@ module AiohttpWebModel {
556
591
}
557
592
}
558
593
594
+ /**
595
+ * A call to the `aiohttp.web.FileResponse` constructor as a sink for Filesystem access.
596
+ */
597
+ class FileResponseCall extends FileSystemAccess:: Range , DataFlow:: CallCfgNode {
598
+ FileResponseCall ( ) {
599
+ this = API:: moduleImport ( "aiohttp" ) .getMember ( "web" ) .getMember ( "FileResponse" ) .getACall ( )
600
+ }
601
+
602
+ override DataFlow:: Node getAPathArgument ( ) { result = this .getArg ( 0 ) }
603
+ }
604
+
559
605
/** Gets an HTTP response instance. */
560
606
private API:: Node aiohttpResponseInstance ( ) {
561
607
result = any ( AiohttpWebResponseInstantiation call ) .getApiNode ( ) .getReturn ( )
@@ -670,7 +716,7 @@ private module AiohttpClientModel {
670
716
string methodName ;
671
717
672
718
OutgoingRequestCall ( ) {
673
- methodName in [ Http:: httpVerbLower ( ) , "request" ] and
719
+ methodName in [ Http:: httpVerbLower ( ) , "request" , "ws_connect" ] and
674
720
this = instance ( ) .getMember ( methodName ) .getACall ( )
675
721
}
676
722
0 commit comments