rspec/rules/S5527/python/rule.adoc

57 lines
1.3 KiB
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
Python https://docs.python.org/3/library/ssl.html[ssl standard] library:
[source,python]
----
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:
[source,python]
----
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[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]