rspec/rules/S5527/python/rule.adoc

46 lines
1.1 KiB
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
Python https://docs.python.org/3/library/ssl.html[ssl standard] library:
----
import ssl
ctx = ssl._create_unverified_context() # Noncompliant: by default hostname verification is not done
ctx = ssl._create_stdlib_context() # Noncompliant: by default hostname verification is not done
ctx = ssl.create_default_context()
ctx.check_hostname = False # Noncompliant
ctx = ssl._create_default_https_context()
ctx.check_hostname = False # Noncompliant
----
== Compliant Solution
Python https://docs.python.org/3/library/ssl.html[ssl standard] library:
----
import ssl
ctx = ssl._create_unverified_context()
ctx.check_hostname = True # Compliant
ctx = ssl._create_stdlib_context()
ctx.check_hostname = True # Compliant
ctx = ssl.create_default_context() # Compliant: by default hostname verification is enabled
ctx = ssl._create_default_https_context() # Compliant: by default hostname verification is enabled
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]