Skip to content

Commit

Permalink
Modify rule S5659: Add python-jose (APPSEC-1262) (#3399)
Browse files Browse the repository at this point in the history
## Review

A dedicated reviewer checked the rule description successfully for:

- [ ] logical errors and incorrect information
- [ ] information gaps and missing content
- [ ] text style and tone
- [ ] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
  • Loading branch information
daniel-teuchert-sonarsource authored Nov 3, 2023
1 parent 0aa9e9e commit 18dd843
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/header_names/allowed_framework_names.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
* pyDes
* PyJWT
* python-jwt
* python-jose
// Docker
* Wget
// Cloudformation
Expand Down
36 changes: 36 additions & 0 deletions rules/S5659/python/how-to-fix-it/python-jose.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
== How to fix it in python-jose

=== Code examples

include::../../common/fix/code-rationale-decode.adoc[]

==== Noncompliant code example

[source,python,diff-id=111,diff-type=noncompliant]
----
from jose import jwt
jwt.decode(token, None, options={"verify_signature": False}) # Noncompliant
----

==== Compliant solution

By default, verification is enabled for the methods `decode` and `verify`.

[source,python,diff-id=111,diff-type=compliant]
----
from jose import jwt
jwt.decode(token, key, algorithms=["HS256"])
----

=== How does this work?

include::../../common/fix/decode.adoc[]

=== Going the extra mile

include::../../common/extra-mile/key-storage.adoc[]

include::../../common/extra-mile/key-rotation.adoc[]

2 changes: 2 additions & 0 deletions rules/S5659/python/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ include::how-to-fix-it/pyjwt.adoc[]

include::how-to-fix-it/python-jwt.adoc[]

include::how-to-fix-it/python-jose.adoc[]

== Resources

include::../common/resources/standards.adoc[]
Expand Down

0 comments on commit 18dd843

Please sign in to comment.