@@ -23,7 +23,7 @@ private module HttpxModel {
23
23
*
24
24
* See https://www.python-httpx.org/api/
25
25
*/
26
- private class RequestCall extends HTTP:: Client:: Request:: Range , DataFlow :: CallCfgNode {
26
+ private class RequestCall extends HTTP:: Client:: Request:: Range , API :: CallNode {
27
27
string methodName ;
28
28
29
29
RequestCall ( ) {
@@ -44,8 +44,11 @@ private module HttpxModel {
44
44
override predicate disablesCertificateValidation (
45
45
DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
46
46
) {
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
49
52
}
50
53
}
51
54
@@ -60,16 +63,13 @@ private module HttpxModel {
60
63
result = API:: moduleImport ( "httpx" ) .getMember ( [ "Client" , "AsyncClient" ] )
61
64
}
62
65
63
- /** Get a reference to an `httpx.Client` or `httpx.AsyncClient` instance. */
64
- private API:: Node instance ( ) { result = classRef ( ) .getReturn ( ) }
65
-
66
66
/** A method call on a Client that sends off a request */
67
67
private class OutgoingRequestCall extends HTTP:: Client:: Request:: Range , DataFlow:: CallCfgNode {
68
68
string methodName ;
69
69
70
70
OutgoingRequestCall ( ) {
71
71
methodName in [ HTTP:: httpVerbLower ( ) , "request" , "stream" ] and
72
- this = instance ( ) .getMember ( methodName ) .getACall ( )
72
+ this = classRef ( ) . getReturn ( ) .getMember ( methodName ) .getACall ( )
73
73
}
74
74
75
75
override DataFlow:: Node getAUrlPart ( ) {
@@ -85,8 +85,16 @@ private module HttpxModel {
85
85
override predicate disablesCertificateValidation (
86
86
DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
87
87
) {
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
+ )
90
98
}
91
99
}
92
100
}
0 commit comments