-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify rule S5659: Add python-jose (APPSEC-1262) (#3399)
## 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
1 parent
0aa9e9e
commit 18dd843
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ | |
* pyDes | ||
* PyJWT | ||
* python-jwt | ||
* python-jose | ||
// Docker | ||
* Wget | ||
// Cloudformation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters