File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
lib/semmle/python/frameworks
test/library-tests/frameworks/aiohttp Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -662,7 +662,7 @@ private module AiohttpClientModel {
662
662
private API:: Node instance ( ) { result = classRef ( ) .getReturn ( ) }
663
663
664
664
/** A method call on a ClientSession that sends off a request */
665
- private class OutgoingRequestCall extends HTTP:: Client:: Request:: Range , DataFlow :: CallCfgNode {
665
+ private class OutgoingRequestCall extends HTTP:: Client:: Request:: Range , API :: CallNode {
666
666
string methodName ;
667
667
668
668
OutgoingRequestCall ( ) {
@@ -685,8 +685,14 @@ private module AiohttpClientModel {
685
685
override predicate disablesCertificateValidation (
686
686
DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
687
687
) {
688
- // TODO: Look into disabling certificate validation
689
- none ( )
688
+ exists ( API:: Node param | param = this .getKeywordParameter ( [ "ssl" , "verify_ssl" ] ) |
689
+ disablingNode = param .getARhs ( ) and
690
+ argumentOrigin = param .getAValueReachingRhs ( ) and
691
+ // aiohttp.client treats `None` as the default and all other "falsey" values as `False`.
692
+ argumentOrigin .asExpr ( ) .( ImmutableLiteral ) .booleanValue ( ) = false and
693
+ not argumentOrigin .asExpr ( ) instanceof None
694
+ )
695
+ // TODO: Handling of SSLContext passed as ssl/ssl_context arguments
690
696
}
691
697
}
692
698
}
Original file line number Diff line number Diff line change 1
1
import aiohttp
2
2
import asyncio
3
+ import ssl
3
4
4
5
s = aiohttp .ClientSession ()
5
6
resp = s .request ("method" , "url" ) # $ clientRequestUrlPart="url"
13
14
s = aiohttp .ClientSession ()
14
15
resp = s .post ("url" ) # $ clientRequestUrlPart="url"
15
16
resp = s .patch ("url" ) # $ clientRequestUrlPart="url"
16
- resp = s .options ("url" ) # $ clientRequestUrlPart="url"
17
+ resp = s .options ("url" ) # $ clientRequestUrlPart="url"
18
+
19
+ # disabling of SSL validation
20
+ # see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession.request
21
+ s .get ("url" , ssl = False ) # $ clientRequestUrlPart="url" clientRequestCertValidationDisabled
22
+ s .get ("url" , ssl = 0 ) # $ clientRequestUrlPart="url" clientRequestCertValidationDisabled
23
+
24
+ # deprecated since 3.0, but still supported
25
+ s .get ("url" , verify_ssl = False ) # $ clientRequestUrlPart="url" clientRequestCertValidationDisabled
26
+
27
+ # A manually constructed SSLContext does not have safe defaults, so is effectively the
28
+ # same as turning off SSL validation
29
+ context = ssl .SSLContext ()
30
+ assert context .check_hostname == False
31
+ assert context .verify_mode == ssl .VerifyMode .CERT_NONE
32
+
33
+ s .get ("url" , ssl = context ) # $ clientRequestUrlPart="url" MISSING: clientRequestCertValidationDisabled
You can’t perform that action at this time.
0 commit comments