From a6ec246dd184b223f6489f51e363be5616c99ed2 Mon Sep 17 00:00:00 2001 From: Igor Gov Date: Tue, 16 Nov 2021 11:33:31 +0200 Subject: [PATCH] Stop reduction of user agent header (#468) --- tap/extensions/http/sensitive_data_cleaner.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tap/extensions/http/sensitive_data_cleaner.go b/tap/extensions/http/sensitive_data_cleaner.go index 4d4487333..8dcf3c2cc 100644 --- a/tap/extensions/http/sensitive_data_cleaner.go +++ b/tap/extensions/http/sensitive_data_cleaner.go @@ -16,6 +16,7 @@ import ( ) const maskedFieldPlaceholderValue = "[REDACTED]" +const userAgent = "user-agent" //these values MUST be all lower case and contain no `-` or `_` characters var personallyIdentifiableDataFields = []string{"token", "authorization", "authentication", "cookie", "userid", "password", @@ -32,7 +33,7 @@ func IsIgnoredUserAgent(item *api.OutputChannelItem, options *api.TrafficFilteri request := item.Pair.Request.Payload.(api.HTTPPayload).Data.(*http.Request) for headerKey, headerValues := range request.Header { - if strings.ToLower(headerKey) == "user-agent" { + if strings.ToLower(headerKey) == userAgent { for _, userAgent := range options.IgnoredUserAgents { for _, headerValue := range headerValues { if strings.Contains(strings.ToLower(headerValue), strings.ToLower(userAgent)) { @@ -89,6 +90,10 @@ func filterResponseBody(response *http.Response, options *api.TrafficFilteringOp func filterHeaders(headers *http.Header) { for key, _ := range *headers { + if strings.ToLower(key) == userAgent { + continue + } + if strings.ToLower(key) == "cookie" { headers.Del(key) } else if isFieldNameSensitive(key) {