
Improvement identified in #2790. Add a prefix to the diff-id when it is used multiple times in different "how to fix it in XYZ" sections to avoid ambiguity and pedantically follow the spec: > A single and unique diff-id should be used only once for each type of code example as shown in the description of a rule. Obvious typos around `diff-type` were fixed. An obvious extra use of diff blocks was removed.
35 lines
701 B
Plaintext
35 lines
701 B
Plaintext
== How to fix it in Requests
|
|
|
|
=== Code examples
|
|
|
|
include::../../common/fix/code-rationale.adoc[]
|
|
|
|
:cert_variable_name: verify
|
|
:cert_variable_unsafe_value: False
|
|
:cert_variable_safe_value: True
|
|
|
|
include::../../common/fix/code-rationale-setting.adoc[]
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,python,diff-id=11,diff-type=noncompliant]
|
|
----
|
|
import requests
|
|
|
|
requests.request('GET', 'https://example.com', verify=False) # Noncompliant
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,python,diff-id=11,diff-type=compliant]
|
|
----
|
|
import requests
|
|
|
|
# By default, certificate validation is enabled
|
|
requests.request('GET', 'https://example.com')
|
|
----
|
|
|
|
=== How does this work?
|
|
|
|
include::../../common/fix/validation.adoc[]
|