File tree Expand file tree Collapse file tree
main/java/org/sonar/python/checks
python-frontend/typeshed_serializer/resources/custom/OpenSSL Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,7 +69,10 @@ public class RobustCipherAlgorithmCheck extends PythonSubscriptionCheck {
6969 "DEFAULT@SECLEVEL=1"
7070 );
7171
72- public static final String SSL_SET_CIPHERS_FQN = "ssl.SSLContext.set_ciphers" ;
72+ public static final Set <String > SSL_SET_CIPHERS_FQN = Set .of (
73+ "ssl.SSLContext.set_ciphers" ,
74+ "OpenSSL.SSL.Context.set_cipher_list"
75+ );
7376
7477 private static final Set <String > SENSITIVE_CALLEE_FQNS = Set .of (
7578 "Crypto.Cipher.ARC2.new" ,
@@ -110,7 +113,7 @@ private static void checkCallExpression(SubscriptionContext subscriptionContext)
110113 .ifPresent (fullyQualifiedName -> {
111114 if (SENSITIVE_CALLEE_FQNS .contains (fullyQualifiedName ) || INSECURE_CIPHERS_PREFIXES .stream ().anyMatch (fullyQualifiedName ::startsWith )) {
112115 subscriptionContext .addIssue (callExpr .callee (), MESSAGE );
113- } else if (SSL_SET_CIPHERS_FQN .equals (fullyQualifiedName )) {
116+ } else if (SSL_SET_CIPHERS_FQN .contains (fullyQualifiedName )) {
114117 checkForInsecureCiphers (subscriptionContext , callExpr );
115118 }
116119 });
Original file line number Diff line number Diff line change @@ -134,6 +134,19 @@ def pyssl_examples():
134134 ctx .set_ciphers (ciphers6 ) # Noncompliant
135135# ^^^^^^^^^^^^^^^
136136
137+ def py_open_ssl_examples ():
138+ import socket
139+ from OpenSSL import SSL
140+
141+ ctx = SSL .Context (SSL .TLS1_3_VERSION )
142+ ctx .set_cipher_list (b"@SECLEVEL=0" ) # Noncompliant
143+ # ^^^^^^^^^^^^^^^^^^^
144+
145+ ciphers2 = b'ECDHE:RSA:AES256:LOW:ECDHE-RSA-AES256-SHA'
146+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^> {{The following cipher strings are insecure: `LOW`, `SHA`}}
147+ ctx .set_cipher_list (ciphers2 ) # Noncompliant
148+ # ^^^^^^^^^^^^^^^^^^^
149+
137150def pycryptodome_compliant ():
138151 from Crypto .Cipher import AES
139152 key = b'Sixteen byte key'
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ VERIFY_NONE: int
66
77class Context (CustomStubBase ):
88 def set_verify (self , * args , ** kwargs ) -> None : ...
9-
9+ def set_cipher_list ( self , * args , ** kwargs ) -> None : ...
1010
1111class Connection (CustomStubBase ):
1212 ...
You can’t perform that action at this time.
0 commit comments