Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: javascript http insecure rule (#551)
* feat: add description to weak encryption * feat: add jwt rule * feat: add javascript http insecure rule
- Loading branch information
Showing
21 changed files
with
223 additions
and
1 deletion.
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
61 changes: 61 additions & 0 deletions
61
pkg/commands/process/settings/rules/javascript/lang/http_insecure.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,61 @@ | ||
patterns: | ||
- pattern: | | ||
$<LIBRARY>.$<METHOD>($<INSECURE_URL>) | ||
filters: | ||
- variable: INSECURE_URL | ||
detection: insecure_url | ||
- variable: LIBRARY | ||
values: | ||
- axios | ||
- http | ||
- variable: METHOD | ||
values: | ||
- get | ||
- post | ||
- patch | ||
- delete | ||
- pattern: | | ||
fetch($<INSECURE_URL>) | ||
filters: | ||
- variable: INSECURE_URL | ||
detection: insecure_url | ||
- pattern: | | ||
$<REQUEST>.open($<_>, $<INSECURE_URL>); | ||
filters: | ||
- variable: INSECURE_URL | ||
detection: insecure_url | ||
- variable: REQUEST | ||
values: | ||
- req | ||
- request | ||
- xhttp | ||
languages: | ||
- javascript | ||
trigger: presence | ||
severity: | ||
default: low | ||
metadata: | ||
description: "Only communicate using HTTPS connections." | ||
remediation_message: | | ||
## Description | ||
Applications processing sensitive data should only connect using HTTPS connections. This rule checks that all HTTP connections use HTTPS. | ||
❌ Avoid using unsecured outgoing HTTP communication, especially in the context of API calls: | ||
```javascript | ||
const response = axios.get('http://insecure-api.com') | ||
``` | ||
✅ Ensure to always connect though HTTPS: | ||
```javascript | ||
const response = axios.get('https://secure-api.com') | ||
``` | ||
<!-- | ||
## Resources | ||
Coming soon. | ||
--> | ||
dsr_id: "DSR-5" | ||
id: "javascript_http_insecure" |
22 changes: 22 additions & 0 deletions
22
...stJavascriptHTTPInsecureDataflow-dataflow_javascript_lang_http_insecure_axios_insecure.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,22 @@ | ||
risks: | ||
- detector_id: javascript_http_insecure | ||
locations: | ||
- filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/axios_insecure.js | ||
line_number: 2 | ||
parent: | ||
line_number: 2 | ||
content: axios.get(insecure_url) | ||
content: | | ||
$<LIBRARY>.$<METHOD>($<INSECURE_URL>) | ||
components: | ||
- name: http://domain.com/api/movies | ||
type: "" | ||
sub_type: "" | ||
locations: | ||
- detector: javascript | ||
filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/axios_insecure.js | ||
line_number: 1 | ||
|
||
|
||
-- | ||
|
12 changes: 12 additions & 0 deletions
12
...TestJavascriptHTTPInsecureDataflow-dataflow_javascript_lang_http_insecure_axios_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,12 @@ | ||
components: | ||
- name: https://domain.com/api/movies | ||
type: "" | ||
sub_type: "" | ||
locations: | ||
- detector: javascript | ||
filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/axios_secure.js | ||
line_number: 1 | ||
|
||
|
||
-- | ||
|
15 changes: 15 additions & 0 deletions
15
...stJavascriptHTTPInsecureDataflow-dataflow_javascript_lang_http_insecure_fetch_insecure.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,15 @@ | ||
risks: | ||
- detector_id: javascript_http_insecure | ||
locations: | ||
- filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/fetch_insecure.js | ||
line_number: 3 | ||
parent: | ||
line_number: 3 | ||
content: fetch(insecure_url) | ||
content: | | ||
fetch($<INSECURE_URL>) | ||
components: [] | ||
|
||
|
||
-- | ||
|
5 changes: 5 additions & 0 deletions
5
...TestJavascriptHTTPInsecureDataflow-dataflow_javascript_lang_http_insecure_fetch_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,5 @@ | ||
components: [] | ||
|
||
|
||
-- | ||
|
15 changes: 15 additions & 0 deletions
15
...JavascriptHTTPInsecureDataflow-dataflow_javascript_lang_http_insecure_request_insecure.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,15 @@ | ||
risks: | ||
- detector_id: javascript_http_insecure | ||
locations: | ||
- filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/request_insecure.js | ||
line_number: 5 | ||
parent: | ||
line_number: 5 | ||
content: xhttp.open("GET", insecure_url, true) | ||
content: | | ||
$<REQUEST>.open($<_>, $<INSECURE_URL>); | ||
components: [] | ||
|
||
|
||
-- | ||
|
5 changes: 5 additions & 0 deletions
5
...stJavascriptHTTPInsecureDataflow-dataflow_javascript_lang_http_insecure_request_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,5 @@ | ||
components: [] | ||
|
||
|
||
-- | ||
|
13 changes: 13 additions & 0 deletions
13
...TestJavascriptHTTPInsecureSummary-summary_javascript_lang_http_insecure_axios_insecure.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,13 @@ | ||
low: | ||
- rule_dsrid: DSR-5 | ||
rule_display_id: javascript_http_insecure | ||
rule_description: Only communicate using HTTPS connections. | ||
rule_documentation_url: https://curio.sh/reference/rules/javascript_http_insecure | ||
line_number: 2 | ||
filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/axios_insecure.js | ||
parent_line_number: 2 | ||
parent_content: axios.get(insecure_url) | ||
|
||
|
||
-- | ||
|
5 changes: 5 additions & 0 deletions
5
...s/TestJavascriptHTTPInsecureSummary-summary_javascript_lang_http_insecure_axios_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,5 @@ | ||
{} | ||
|
||
|
||
-- | ||
|
13 changes: 13 additions & 0 deletions
13
...TestJavascriptHTTPInsecureSummary-summary_javascript_lang_http_insecure_fetch_insecure.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,13 @@ | ||
low: | ||
- rule_dsrid: DSR-5 | ||
rule_display_id: javascript_http_insecure | ||
rule_description: Only communicate using HTTPS connections. | ||
rule_documentation_url: https://curio.sh/reference/rules/javascript_http_insecure | ||
line_number: 3 | ||
filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/fetch_insecure.js | ||
parent_line_number: 3 | ||
parent_content: fetch(insecure_url) | ||
|
||
|
||
-- | ||
|
5 changes: 5 additions & 0 deletions
5
...s/TestJavascriptHTTPInsecureSummary-summary_javascript_lang_http_insecure_fetch_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,5 @@ | ||
{} | ||
|
||
|
||
-- | ||
|
13 changes: 13 additions & 0 deletions
13
...stJavascriptHTTPInsecureSummary-summary_javascript_lang_http_insecure_request_insecure.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,13 @@ | ||
low: | ||
- rule_dsrid: DSR-5 | ||
rule_display_id: javascript_http_insecure | ||
rule_description: Only communicate using HTTPS connections. | ||
rule_documentation_url: https://curio.sh/reference/rules/javascript_http_insecure | ||
line_number: 5 | ||
filename: pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/request_insecure.js | ||
parent_line_number: 5 | ||
parent_content: xhttp.open("GET", insecure_url, true) | ||
|
||
|
||
-- | ||
|
5 changes: 5 additions & 0 deletions
5
...TestJavascriptHTTPInsecureSummary-summary_javascript_lang_http_insecure_request_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,5 @@ | ||
{} | ||
|
||
|
||
-- | ||
|
2 changes: 2 additions & 0 deletions
2
pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/axios_insecure.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,2 @@ | ||
const insecure_url = "http://domain.com/api/movies"; | ||
axios.get(insecure_url); |
2 changes: 2 additions & 0 deletions
2
pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/axios_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,2 @@ | ||
const secure_url = "https://domain.com/api/movies"; | ||
axios.get(secure_url); |
5 changes: 5 additions & 0 deletions
5
pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/fetch_insecure.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,5 @@ | ||
const insecure_url = "http://example.com/movies.json"; | ||
|
||
fetch(insecure_url) | ||
.then((response) => response.json()) | ||
.then((data) => console.log(data)); |
5 changes: 5 additions & 0 deletions
5
pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/fetch_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,5 @@ | ||
const secure_url = "https://example.com/movies.json"; | ||
|
||
fetch(secure_url) | ||
.then((response) => response.json()) | ||
.then((data) => console.log(data)); |
5 changes: 5 additions & 0 deletions
5
...ommands/process/settings/rules/javascript/lang/http_insecure/testdata/request_insecure.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,5 @@ | ||
var xhttp = new XMLHttpRequest(); | ||
|
||
var insecure_url = "http://domain.com/movie"; | ||
|
||
xhttp.open("GET", insecure_url, true); |
4 changes: 4 additions & 0 deletions
4
pkg/commands/process/settings/rules/javascript/lang/http_insecure/testdata/request_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,4 @@ | ||
var secure_url = "https://domain.com/movie"; | ||
|
||
var xhttp = new XMLHttpRequest(); | ||
xhttp.open("GET", secure_url, true); |
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