-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: update jwt cwe * feat: add jwt hardcoded secret * fix: remove debug log * feat: update severity * fix: typo * chore: update test
- Loading branch information
Showing
10 changed files
with
64 additions
and
5 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
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
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
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
5 changes: 4 additions & 1 deletion
5
pkg/commands/process/settings/rules/javascript/lang/jwt/testdata/unsecure.js
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
var jwt = require("jsonwebtoken"); | ||
var token = jwt.sign({ user: { email: "jhon@gmail.com" } }, "shhhhh"); | ||
var token = jwt.sign( | ||
{ user: { email: "jhon@gmail.com" } }, | ||
process.env.JWT_SECRET | ||
); |
3 changes: 3 additions & 0 deletions
3
...ascript/lang/jwt_hardcoded_secret/.snapshots/TestJavascriptJWTHardcodedSecret--secure.yml
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,3 @@ | ||
{} | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
...cript/lang/jwt_hardcoded_secret/.snapshots/TestJavascriptJWTHardcodedSecret--unsecure.yml
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,11 @@ | ||
medium: | ||
- rule_dsrid: DSR-5 | ||
rule_display_id: javascript_jwt_hardcoded_secret | ||
rule_description: Hardocded jwt secret deteted | ||
rule_documentation_url: https://docs.bearer.com/reference/rules/javascript_jwt_hardcoded_secret | ||
line_number: 3 | ||
filename: unsecure.js | ||
parent_line_number: 3 | ||
parent_content: 'jwt.sign({ foo: "bar" }, "someSecret")' | ||
|
||
|
3 changes: 3 additions & 0 deletions
3
pkg/commands/process/settings/rules/javascript/lang/jwt_hardcoded_secret/testdata/secure.js
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,3 @@ | ||
var jwt = require("jsonwebtoken"); | ||
|
||
var token = jwt.sign({ foo: "bar" }, process.env.JWT_SECRET); |
3 changes: 3 additions & 0 deletions
3
...commands/process/settings/rules/javascript/lang/jwt_hardcoded_secret/testdata/unsecure.js
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,3 @@ | ||
var jwt = require("jsonwebtoken"); | ||
|
||
var token = jwt.sign({ foo: "bar" }, "someSecret"); |
27 changes: 27 additions & 0 deletions
27
pkg/commands/process/settings/rules/javascript/lang/jwt_hardocoded_secret.yml
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,27 @@ | ||
type: risk | ||
patterns: | ||
- pattern: | | ||
jwt.sign($<_>, $<SECRET:string>) | ||
languages: | ||
- javascript | ||
trigger: presence | ||
severity: | ||
default: medium | ||
skip_data_types: | ||
- "Unique Identifier" | ||
metadata: | ||
description: "Hardocded jwt secret deteted" | ||
remediation_message: | | ||
## Description | ||
Code is not a secure place to store secrets, use env variable. | ||
<!-- | ||
## Resources | ||
Coming soon. | ||
--> | ||
dsr_id: "DSR-5" | ||
cwe_id: | ||
- 798 | ||
id: "javascript_jwt_hardcoded_secret" |