rspec/rules/S5659/python/rule.adoc
2021-02-02 16:54:43 +01:00

47 lines
823 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Examples
For https://github.com/GehirnInc/python-jwt[jwt] module:
----
jwt.decode(token, verify = False) # Noncompliant
----
----
try:
jwt.decode(token, key, algo) # Noncompliant; generic exception catch
except:
pass
----
For https://github.com/davedoesdev/python-jwt[python_jwt] module:
----
jwt.process_jwt(token) # Noncompliant
----
== Compliant Solution
For https://github.com/GehirnInc/python-jwt[jwt] module:
----
jwt.decode(token, key, algo)
----
----
try:
jwt.decode(token, key, algo)
except jwt.InvalidSignatureError:
pass
----
For https://github.com/davedoesdev/python-jwt[python_jwt] module:
----
jwt.process_jwt(token) # Compliant because followed by verify_jwt()
jwt.verify_jwt(token, key, algo)
----
include::../see.adoc[]