mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Move tests under test/
This commit is contained in:
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE-347/JWTEmptyKeyOrAlgorithm.ql
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
|
||||
@@ -0,0 +1,27 @@
|
||||
import jwt
|
||||
|
||||
# Encoding
|
||||
|
||||
# good - key and algorithm supplied
|
||||
jwt.encode({"foo": "bar"}, "key", "HS256")
|
||||
jwt.encode({"foo": "bar"}, key="key", algorithm="HS256")
|
||||
|
||||
# bad - both key and algorithm set to None
|
||||
jwt.encode({"foo": "bar"}, None, None)
|
||||
|
||||
# bad - empty key
|
||||
jwt.encode({"foo": "bar"}, "", algorithm="HS256")
|
||||
jwt.encode({"foo": "bar"}, key="", algorithm="HS256")
|
||||
|
||||
# Decoding
|
||||
|
||||
# good
|
||||
jwt.decode(token, "key", "HS256")
|
||||
|
||||
# bad - unverified decoding
|
||||
jwt.decode(token, verify=False)
|
||||
jwt.decode(token, key, options={"verify_signature": False})
|
||||
|
||||
# good - verified decoding
|
||||
jwt.decode(token, verify=True)
|
||||
jwt.decode(token, key, options={"verify_signature": True})
|
||||
Reference in New Issue
Block a user