@@ -23,7 +23,7 @@ private module HttpxModel {
2323 *
2424 * See https://www.python-httpx.org/api/
2525 */
26- private class RequestCall extends HTTP:: Client:: Request:: Range , DataFlow :: CallCfgNode {
26+ private class RequestCall extends HTTP:: Client:: Request:: Range , API :: CallNode {
2727 string methodName ;
2828
2929 RequestCall ( ) {
@@ -44,8 +44,11 @@ private module HttpxModel {
4444 override predicate disablesCertificateValidation (
4545 DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
4646 ) {
47- // TODO: Look into disabling certificate validation
48- none ( )
47+ disablingNode = this .getKeywordParameter ( "verify" ) .getARhs ( ) and
48+ argumentOrigin = this .getKeywordParameter ( "verify" ) .getAValueReachingRhs ( ) and
49+ // unlike `requests`, httpx treats `None` as turning off verify (and not as the default)
50+ argumentOrigin .asExpr ( ) .( ImmutableLiteral ) .booleanValue ( ) = false
51+ // TODO: Handling of insecure SSLContext passed to verify argument
4952 }
5053 }
5154
@@ -60,16 +63,13 @@ private module HttpxModel {
6063 result = API:: moduleImport ( "httpx" ) .getMember ( [ "Client" , "AsyncClient" ] )
6164 }
6265
63- /** Get a reference to an `httpx.Client` or `httpx.AsyncClient` instance. */
64- private API:: Node instance ( ) { result = classRef ( ) .getReturn ( ) }
65-
6666 /** A method call on a Client that sends off a request */
6767 private class OutgoingRequestCall extends HTTP:: Client:: Request:: Range , DataFlow:: CallCfgNode {
6868 string methodName ;
6969
7070 OutgoingRequestCall ( ) {
7171 methodName in [ HTTP:: httpVerbLower ( ) , "request" , "stream" ] and
72- this = instance ( ) .getMember ( methodName ) .getACall ( )
72+ this = classRef ( ) . getReturn ( ) .getMember ( methodName ) .getACall ( )
7373 }
7474
7575 override DataFlow:: Node getAUrlPart ( ) {
@@ -85,8 +85,16 @@ private module HttpxModel {
8585 override predicate disablesCertificateValidation (
8686 DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
8787 ) {
88- // TODO: Look into disabling certificate validation
89- none ( )
88+ exists ( API:: CallNode constructor |
89+ constructor = classRef ( ) .getACall ( ) and
90+ this = constructor .getReturn ( ) .getMember ( methodName ) .getACall ( )
91+ |
92+ disablingNode = constructor .getKeywordParameter ( "verify" ) .getARhs ( ) and
93+ argumentOrigin = constructor .getKeywordParameter ( "verify" ) .getAValueReachingRhs ( ) and
94+ // unlike `requests`, httpx treats `None` as turning off verify (and not as the default)
95+ argumentOrigin .asExpr ( ) .( ImmutableLiteral ) .booleanValue ( ) = false
96+ // TODO: Handling of insecure SSLContext passed to verify argument
97+ )
9098 }
9199 }
92100 }
0 commit comments