maskQueryParams masks (i.e., hashing) specific query parameters in the provided request's URI. Returns the obfuscated URI.
(req *http.Request, maskedQueryParams map[string]struct{})
| 121 | // maskQueryParams masks (i.e., hashing) specific query parameters in the provided request's URI. |
| 122 | // Returns the obfuscated URI. |
| 123 | func maskQueryParams(req *http.Request, maskedQueryParams map[string]struct{}) string { |
| 124 | strippedURI := stripQueryString(req.RequestURI) |
| 125 | |
| 126 | params := req.URL.Query() |
| 127 | for k := range maskedQueryParams { |
| 128 | val := params.Get(k) |
| 129 | if val == "" { |
| 130 | continue |
| 131 | } |
| 132 | params.Set(k, fmt.Sprintf("%d", hash(val))) |
| 133 | } |
| 134 | |
| 135 | return fmt.Sprintf("%s?%s", strippedURI, params.Encode()) |
| 136 | } |
| 137 | |
| 138 | func hash(val string) uint64 { |
| 139 | return xxhash.Sum64String(val) |
no test coverage detected
searching dependent graphs…