mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-22 14:32:35 +00:00
Stop reduction of user agent header (#468)
This commit is contained in:
parent
3e30815fb4
commit
a6ec246dd1
@ -16,6 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const maskedFieldPlaceholderValue = "[REDACTED]"
|
const maskedFieldPlaceholderValue = "[REDACTED]"
|
||||||
|
const userAgent = "user-agent"
|
||||||
|
|
||||||
//these values MUST be all lower case and contain no `-` or `_` characters
|
//these values MUST be all lower case and contain no `-` or `_` characters
|
||||||
var personallyIdentifiableDataFields = []string{"token", "authorization", "authentication", "cookie", "userid", "password",
|
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)
|
request := item.Pair.Request.Payload.(api.HTTPPayload).Data.(*http.Request)
|
||||||
|
|
||||||
for headerKey, headerValues := range request.Header {
|
for headerKey, headerValues := range request.Header {
|
||||||
if strings.ToLower(headerKey) == "user-agent" {
|
if strings.ToLower(headerKey) == userAgent {
|
||||||
for _, userAgent := range options.IgnoredUserAgents {
|
for _, userAgent := range options.IgnoredUserAgents {
|
||||||
for _, headerValue := range headerValues {
|
for _, headerValue := range headerValues {
|
||||||
if strings.Contains(strings.ToLower(headerValue), strings.ToLower(userAgent)) {
|
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) {
|
func filterHeaders(headers *http.Header) {
|
||||||
for key, _ := range *headers {
|
for key, _ := range *headers {
|
||||||
|
if strings.ToLower(key) == userAgent {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if strings.ToLower(key) == "cookie" {
|
if strings.ToLower(key) == "cookie" {
|
||||||
headers.Del(key)
|
headers.Del(key)
|
||||||
} else if isFieldNameSensitive(key) {
|
} else if isFieldNameSensitive(key) {
|
||||||
|
Loading…
Reference in New Issue
Block a user