From 357fd32e82c7b85c80ee08d72492277d38b3b39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CHitesh?= Date: Thu, 12 Oct 2023 11:45:12 +0530 Subject: [PATCH 1/3] go: API Tagger --- .gitignore | 3 +++ config/systemConfig/go.yaml | 9 +++++++++ rules/sinks/third_parties/api/go.yaml | 8 ++++++++ 3 files changed, 20 insertions(+) create mode 100644 config/systemConfig/go.yaml create mode 100644 rules/sinks/third_parties/api/go.yaml diff --git a/.gitignore b/.gitignore index f5e2afc9..379e8018 100644 --- a/.gitignore +++ b/.gitignore @@ -246,3 +246,6 @@ dist # files privado notes.md + +#Directory created by IDE +workspace \ No newline at end of file diff --git a/config/systemConfig/go.yaml b/config/systemConfig/go.yaml new file mode 100644 index 00000000..736ee471 --- /dev/null +++ b/config/systemConfig/go.yaml @@ -0,0 +1,9 @@ +systemConfig: + - key: apiHttpLibraries + value: ^(?i)(net/http|github.com/parnurzeal/gorequest|gopkg.in/resty|github.com/gojektech/heimdall/v\\d/httpclient|github.com/levigross/grequests|github.com/PuerkitoBio/rehttp|github.com/machinebox/graphql).* + + - key: apiSinks + value: (?i)(?:url|client|open|request|execute|newCall|load|host|access|list|set|put|post|proceed|trace|patch|Path|send|remove|delete|write|read|postForEntity|call|createCall|createEndpoint|dispatch|invoke|getInput|getOutput|getResponse) + + - key: apiIdentifier + value: (?i).*((hook|base|auth|prov|endp|install|request|service|gateway|route|resource)(.){0,12}url|(slack|web)(.){0,4}hook|(rest|api|request|service)(.){0,4}(endpoint|gateway|route)).* \ No newline at end of file diff --git a/rules/sinks/third_parties/api/go.yaml b/rules/sinks/third_parties/api/go.yaml new file mode 100644 index 00000000..fbfd0570 --- /dev/null +++ b/rules/sinks/third_parties/api/go.yaml @@ -0,0 +1,8 @@ +sinks: + + - id: Sinks.ThirdParties.API + name: Third Party API + patterns: + - "(?i)((?:http|https):\\/\\/[a-zA-Z0-9_-][^)\\/(#|,!>\\s]{1,50}\\.(?:com|net|org|de|in|uk|us|io|gov|cn|ml|ai|ly|dev|cloud|me|icu|ru|info|top|tk|tr|cn|ga|cf|nl)).*(? Date: Thu, 12 Oct 2023 12:44:35 +0530 Subject: [PATCH 2/3] added internal api rule --- rules/sinks/internal_apis/api/go.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 rules/sinks/internal_apis/api/go.yaml diff --git a/rules/sinks/internal_apis/api/go.yaml b/rules/sinks/internal_apis/api/go.yaml new file mode 100644 index 00000000..3c5363a5 --- /dev/null +++ b/rules/sinks/internal_apis/api/go.yaml @@ -0,0 +1,6 @@ +sinks: + - id: Sinks.API.InternalAPI + name: Internal APIs + patterns: + - "((http|https|ftp|ssh):\\/\\/){0,1}(((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}|(localhost))(:[0-9]{2,4}){0,1}(\\/([a-z]){0,1}){0,1}.*" + tags: From 33e5486bbdbf5746f29333e18d73896933aacae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CHitesh?= Date: Thu, 12 Oct 2023 14:05:32 +0530 Subject: [PATCH 3/3] added do method --- config/systemConfig/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/systemConfig/go.yaml b/config/systemConfig/go.yaml index 736ee471..e773a593 100644 --- a/config/systemConfig/go.yaml +++ b/config/systemConfig/go.yaml @@ -3,7 +3,7 @@ systemConfig: value: ^(?i)(net/http|github.com/parnurzeal/gorequest|gopkg.in/resty|github.com/gojektech/heimdall/v\\d/httpclient|github.com/levigross/grequests|github.com/PuerkitoBio/rehttp|github.com/machinebox/graphql).* - key: apiSinks - value: (?i)(?:url|client|open|request|execute|newCall|load|host|access|list|set|put|post|proceed|trace|patch|Path|send|remove|delete|write|read|postForEntity|call|createCall|createEndpoint|dispatch|invoke|getInput|getOutput|getResponse) + value: (?i)(?:url|client|open|request|execute|newCall|load|host|access|list|set|put|post|proceed|trace|patch|Path|send|remove|delete|write|read|postForEntity|call|createCall|createEndpoint|dispatch|invoke|getInput|getOutput|getResponse|do) - key: apiIdentifier value: (?i).*((hook|base|auth|prov|endp|install|request|service|gateway|route|resource)(.){0,12}url|(slack|web)(.){0,4}hook|(rest|api|request|service)(.){0,4}(endpoint|gateway|route)).* \ No newline at end of file