feat(logs): webhook sanitization (#809)

* feat: sanitize passwords from json payload

* add webhook sanitization

* update comments

Co-authored-by: soup <soup@r4tio.dev>

* sanitize RED apikeys from webhook payloads

* added an optional whitespace token between field name and data

---------

Co-authored-by: soup <soup@r4tio.dev>
This commit is contained in:
martylukyy 2023-04-10 14:32:19 +02:00 committed by GitHub
parent 69f6acbc4d
commit 169863dded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -138,6 +138,18 @@ func TestSanitizeLogFile(t *testing.T) {
input: "\"module\":\"irc\" PRIVMSG NickServ IDENTIFY zAPEJEA8ryYnpj3AiE3KJ",
expected: "\"module\":\"irc\" PRIVMSG NickServ IDENTIFY REDACTED",
},
{
input: "\"module\":\"action\" \\\"host\\\":\\\"subdomain.domain.com:42069/subfolder\\\", \\n \\\"user\\\":\\\"AUserName\\\", \\n \\\"password\\\":\\\"p4ssw0!rd\\\", \\n",
expected: "\"module\":\"action\" \\\"host\\\":\\\"REDACTED\\\", \\n \\\"user\\\":\\\"REDACTED\\\", \\n \\\"password\\\":\\\"REDACTED\\\", \\n",
},
{
input: "\"module\":\"action\" ExternalWebhookHost:http://127.0.0.1:6940/api/upgrade ExternalWebhookData:",
expected: "\"module\":\"action\" ExternalWebhookHost:REDACTED ExternalWebhookData:",
},
{
input: "\"module\":\"filter\" \\\"id\\\": 3855,\\n \\\"apikey\\\": \\\"ad789a9s8d.asdpoiasdpojads09sad809\\\",\\n \\\"minratio\\\": 10.0\\n",
expected: "\"module\":\"filter\" \\\"id\\\": 3855,\\n \\\"apikey\\\": \\\"REDACTED\\\",\\n \\\"minratio\\\": 10.0\\n",
},
}
for _, testCase := range testCases {