MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / sanitizeRequestURLQueryParams

Function sanitizeRequestURLQueryParams

base/util.go:826–848  ·  view source on GitHub ↗

sanitizeRequestURLQueryParams replaces sensitive data from the URL query string with ******.

(urlStr string, values url.Values)

Source from the content-addressed store, hash-verified

824
825// sanitizeRequestURLQueryParams replaces sensitive data from the URL query string with ******.
826func sanitizeRequestURLQueryParams(urlStr string, values url.Values) string {
827
828 if urlStr == "" || len(values) == 0 {
829 return urlStr
830 }
831
832 // Do a basic contains for the values we care about, to minimize performance impact on other requests.
833 if strings.Contains(urlStr, "code=") || strings.Contains(urlStr, "token=") {
834 // Iterate over the URL values looking for matches, and then do a string replacement of the found value
835 // into urlString. Need to unescapte the urlString, as the values returned by URL.Query() get unescaped.
836 urlStr, _ = url.QueryUnescape(urlStr)
837 for key, vals := range values {
838 if key == "code" || strings.Contains(key, "token") {
839 // In case there are multiple entries
840 for _, val := range vals {
841 urlStr = strings.Replace(urlStr, fmt.Sprintf("%s=%s", key, val), fmt.Sprintf("%s=******", key), -1)
842 }
843 }
844 }
845 }
846
847 return urlStr
848}
849
850// Ptr returns a pointer to the given literal.
851// This is useful for wrapping around function calls that return a value, where you can't just use `&`.

Callers 1

SanitizeRequestURLFunction · 0.85

Calls 1

ContainsMethod · 0.65

Tested by

no test coverage detected