@@ -7,8 +7,15 @@ class SSLContextCreation extends ContextCreation {
77
88 SSLContextCreation ( ) { this = API:: moduleImport ( "ssl" ) .getMember ( "SSLContext" ) .getACall ( ) }
99
10- override DataFlow:: CfgNode getProtocol ( ) {
11- result .getNode ( ) in [ node .getArg ( 0 ) , node .getArgByName ( "protocol" ) ]
10+ override string getProtocol ( ) {
11+ exists ( ControlFlowNode protocolArg , Ssl ssl |
12+ protocolArg in [ node .getArg ( 0 ) , node .getArgByName ( "protocol" ) ]
13+ |
14+ protocolArg = [ ssl .specific_version ( result ) , ssl .unspecific_version ( result ) ] .asCfgNode ( )
15+ )
16+ or
17+ not exists ( node .getAnArg ( ) ) and
18+ result = "TLS"
1219 }
1320}
1421
@@ -19,7 +26,7 @@ class SSLDefaultContextCreation extends ContextCreation {
1926
2027 // Allowed insecure versions are "TLSv1" and "TLSv1_1"
2128 // see https://docs.python.org/3/library/ssl.html#context-creation
22- override DataFlow :: CfgNode getProtocol ( ) { none ( ) }
29+ override string getProtocol ( ) { result = "TLS" }
2330}
2431
2532/** Gets a reference to an `ssl.Context` instance. */
@@ -141,17 +148,10 @@ class UnspecificSSLContextCreation extends SSLContextCreation, UnspecificContext
141148 UnspecificSSLContextCreation ( ) { library = "ssl" }
142149
143150 override ProtocolVersion getUnrestriction ( ) {
144- // Case: A protocol argument is present.
145151 result = UnspecificContextCreation .super .getUnrestriction ( ) and
146152 // These are turned off by default
147153 // see https://docs.python.org/3/library/ssl.html#ssl-contexts
148154 not result in [ "SSLv2" , "SSLv3" ]
149- or
150- // Case: No protocol arguemnt is present.
151- not exists ( this .getProtocol ( ) ) and
152- // The default argument is TLS and the SSL versions are turned off by default since Python 3.6
153- // see https://docs.python.org/3.6/library/ssl.html#ssl.SSLContext
154- result in [ "TLSv1" , "TLSv1_1" , "TLSv1_2" , "TLSv1_3" ]
155155 }
156156}
157157
@@ -185,8 +185,9 @@ class Ssl extends TlsLibrary {
185185
186186 override DataFlow:: CfgNode insecure_connection_creation ( ProtocolVersion version ) {
187187 result = API:: moduleImport ( "ssl" ) .getMember ( "wrap_socket" ) .getACall ( ) and
188- insecure_version ( version ) .asCfgNode ( ) =
189- result .asCfgNode ( ) .( CallNode ) .getArgByName ( "ssl_version" )
188+ specific_version ( version ) .asCfgNode ( ) =
189+ result .asCfgNode ( ) .( CallNode ) .getArgByName ( "ssl_version" ) and
190+ version .isInsecure ( )
190191 }
191192
192193 override ConnectionCreation connection_creation ( ) { result instanceof WrapSocketCall }
0 commit comments