| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package jwt_test.jwt_test_1; | ||
|
|
||
| import com.auth0.jwt.JWT; | ||
| import com.auth0.jwt.algorithms.Algorithm; | ||
| import com.auth0.jwt.exceptions.JWTCreationException; | ||
|
|
||
| public class App | ||
| { | ||
|
|
||
| static String secret = "secret"; | ||
|
|
||
| private static void bad1() { | ||
| try { | ||
| // ruleid: java-jwt-hardcoded-secret | ||
| Algorithm algorithm = Algorithm.HMAC256("secret"); | ||
| String token = JWT.create() | ||
| .withIssuer("auth0") | ||
| .sign(algorithm); | ||
| } catch (JWTCreationException exception){ | ||
| //Invalid Signing configuration / Couldn't convert Claims. | ||
| } | ||
| } | ||
|
|
||
| private static void ok1(String secretKey) { | ||
| try { | ||
| // ok: java-jwt-hardcoded-secret | ||
| Algorithm algorithm = Algorithm.HMAC256(secretKey); | ||
| String token = JWT.create() | ||
| .withIssuer("auth0") | ||
| .sign(algorithm); | ||
| } catch (JWTCreationException exception){ | ||
| //Invalid Signing configuration / Couldn't convert Claims. | ||
| } | ||
| } | ||
|
|
||
| public static void main( String[] args ) | ||
| { | ||
| bad1(); | ||
| ok1(args[0]); | ||
| } | ||
| } | ||
|
|
||
| abstract class App2 | ||
| { | ||
| // ruleid: java-jwt-hardcoded-secret | ||
| static String secret = "secret"; | ||
|
Comment thread
Copy link
Copy Markdown
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityA hard-coded credential was detected. It is not recommended to store credentials in source-code, as this risks secrets being leaked and used by either an internal or external malicious adversary. It is recommended to use environment variables to securely provide credentials or retrieve credentials from a secure vault or HSM (Hardware Security Module). Ignore this finding from java-jwt-hardcoded-secret.
Sorry, something went wrong.
All reactions
|
||
|
|
||
| public void bad2() { | ||
| try { | ||
| Algorithm algorithm = Algorithm.HMAC256(secret); | ||
| String token = JWT.create() | ||
| .withIssuer("auth0") | ||
| .sign(algorithm); | ||
| } catch (JWTCreationException exception){ | ||
| //Invalid Signing configuration / Couldn't convert Claims. | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityA hard-coded credential was detected. It is not recommended to store credentials in source-code, as this risks secrets being leaked and used by either an internal or external malicious adversary. It is recommended to use environment variables to securely provide credentials or retrieve credentials from a secure vault or HSM (Hardware Security Module).
Ignore this finding from java-jwt-hardcoded-secret.Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.