@@ -468,6 +468,27 @@ module AiohttpWebModel {
468468 override string getSourceType ( ) { result = "aiohttp.web.Request" }
469469 }
470470
471+ /**
472+ * A parameter that has a type annotation of `aiohttp.web.Request`, so with all
473+ * likelihood will receive an `aiohttp.web.Request` instance at some point when a
474+ * request handler is invoked.
475+ */
476+ class AiohttpRequestParamFromTypeAnnotation extends Request:: InstanceSource ,
477+ DataFlow:: ParameterNode , RemoteFlowSource:: Range
478+ {
479+ AiohttpRequestParamFromTypeAnnotation ( ) {
480+ not this instanceof AiohttpRequestHandlerRequestParam and
481+ this .getParameter ( ) .getAnnotation ( ) =
482+ API:: moduleImport ( "aiohttp" )
483+ .getMember ( "web" )
484+ .getMember ( "Request" )
485+ .getAValueReachableFromSource ( )
486+ .asExpr ( )
487+ }
488+
489+ override string getSourceType ( ) { result = "aiohttp.web.Request from type-annotation" }
490+ }
491+
471492 /**
472493 * A read of the `request` attribute on an instance of an aiohttp.web View class,
473494 * which is the request being processed currently.
@@ -498,14 +519,17 @@ module AiohttpWebModel {
498519 * - https://docs.aiohttp.org/en/stable/web_quickstart.html#aiohttp-web-exceptions
499520 */
500521 class AiohttpWebResponseInstantiation extends Http:: Server:: HttpResponse:: Range ,
501- Response:: InstanceSource , DataFlow :: CallCfgNode
522+ Response:: InstanceSource , API :: CallNode
502523 {
503524 API:: Node apiNode ;
504525
505526 AiohttpWebResponseInstantiation ( ) {
506527 this = apiNode .getACall ( ) and
507528 (
508- apiNode = API:: moduleImport ( "aiohttp" ) .getMember ( "web" ) .getMember ( "Response" )
529+ apiNode =
530+ API:: moduleImport ( "aiohttp" )
531+ .getMember ( "web" )
532+ .getMember ( [ "FileResponse" , "Response" , "StreamResponse" ] )
509533 or
510534 exists ( string httpExceptionClassName |
511535 httpExceptionClassName in [
@@ -545,6 +569,10 @@ module AiohttpWebModel {
545569
546570 override DataFlow:: Node getMimetypeOrContentTypeArg ( ) {
547571 result = this .getArgByName ( "content_type" )
572+ or
573+ exists ( string key | key .toLowerCase ( ) = "content-type" |
574+ result = this .getKeywordParameter ( "headers" ) .getSubscript ( key ) .getAValueReachingSink ( )
575+ )
548576 }
549577
550578 override string getMimetypeDefault ( ) {
@@ -556,6 +584,37 @@ module AiohttpWebModel {
556584 }
557585 }
558586
587+ /**
588+ * A call to the `aiohttp.web.FileResponse` constructor as a sink for Filesystem access.
589+ */
590+ class FileResponseCall extends FileSystemAccess:: Range , API:: CallNode {
591+ FileResponseCall ( ) {
592+ this = API:: moduleImport ( "aiohttp" ) .getMember ( "web" ) .getMember ( "FileResponse" ) .getACall ( )
593+ }
594+
595+ override DataFlow:: Node getAPathArgument ( ) { result = this .getParameter ( 0 , "path" ) .asSink ( ) }
596+ }
597+
598+ /**
599+ * An instantiation of `aiohttp.web.StreamResponse`.
600+ *
601+ * See https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.StreamResponse
602+ */
603+ class StreamResponse extends AiohttpWebResponseInstantiation {
604+ StreamResponse ( ) {
605+ this = API:: moduleImport ( "aiohttp" ) .getMember ( "web" ) .getMember ( "StreamResponse" ) .getACall ( )
606+ }
607+
608+ override DataFlow:: Node getBody ( ) {
609+ result =
610+ this .getReturn ( )
611+ .getMember ( [ "write" , "write_eof" ] )
612+ .getACall ( )
613+ .getParameter ( 0 , "data" )
614+ .asSink ( )
615+ }
616+ }
617+
559618 /** Gets an HTTP response instance. */
560619 private API:: Node aiohttpResponseInstance ( ) {
561620 result = any ( AiohttpWebResponseInstantiation call ) .getApiNode ( ) .getReturn ( )
@@ -670,14 +729,14 @@ private module AiohttpClientModel {
670729 string methodName ;
671730
672731 OutgoingRequestCall ( ) {
673- methodName in [ Http:: httpVerbLower ( ) , "request" ] and
732+ methodName in [ Http:: httpVerbLower ( ) , "request" , "ws_connect" ] and
674733 this = instance ( ) .getMember ( methodName ) .getACall ( )
675734 }
676735
677736 override DataFlow:: Node getAUrlPart ( ) {
678737 result = this .getArgByName ( "url" )
679738 or
680- not methodName = "request" and
739+ methodName in [ Http :: httpVerbLower ( ) , "ws_connect" ] and
681740 result = this .getArg ( 0 )
682741 or
683742 methodName = "request" and
0 commit comments