@@ -18,7 +18,12 @@ private import semmle.python.ApiGraphs
1818 * - https://www.python-httpx.org/
1919 */
2020private module HttpxModel {
21- private class RequestCall extends HTTP:: Client:: Request:: Range , DataFlow:: CallCfgNode {
21+ /**
22+ * An outgoing HTTP request, from the `httpx` library.
23+ *
24+ * See https://www.python-httpx.org/api/
25+ */
26+ private class RequestCall extends HTTP:: Client:: Request:: Range , API:: CallNode {
2227 string methodName ;
2328
2429 RequestCall ( ) {
@@ -39,32 +44,32 @@ private module HttpxModel {
3944 override predicate disablesCertificateValidation (
4045 DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
4146 ) {
42- // TODO: Look into disabling certificate validation
43- 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
4452 }
4553 }
4654
4755 /**
4856 * Provides models for the `httpx.[Async]Client` class
4957 *
50- * See https://www.python-httpx.org/async/
58+ * See https://www.python-httpx.org/api/#client
5159 */
5260 module Client {
5361 /** Get a reference to the `httpx.Client` or `httpx.AsyncClient` class. */
5462 private API:: Node classRef ( ) {
5563 result = API:: moduleImport ( "httpx" ) .getMember ( [ "Client" , "AsyncClient" ] )
5664 }
5765
58- /** Get a reference to an `httpx.Client` or `httpx.AsyncClient` instance. */
59- private API:: Node instance ( ) { result = classRef ( ) .getReturn ( ) }
60-
6166 /** A method call on a Client that sends off a request */
6267 private class OutgoingRequestCall extends HTTP:: Client:: Request:: Range , DataFlow:: CallCfgNode {
6368 string methodName ;
6469
6570 OutgoingRequestCall ( ) {
6671 methodName in [ HTTP:: httpVerbLower ( ) , "request" , "stream" ] and
67- this = instance ( ) .getMember ( methodName ) .getACall ( )
72+ this = classRef ( ) . getReturn ( ) .getMember ( methodName ) .getACall ( )
6873 }
6974
7075 override DataFlow:: Node getAUrlPart ( ) {
@@ -80,8 +85,16 @@ private module HttpxModel {
8085 override predicate disablesCertificateValidation (
8186 DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
8287 ) {
83- // TODO: Look into disabling certificate validation
84- 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+ )
8598 }
8699 }
87100 }
0 commit comments