File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -366,7 +366,7 @@ func (r *QueryTranslate) validate() http.HandlerFunc {
366366 validateMapToShow = append (validateMapToShow , map [string ]interface {}{
367367 "id" : requestID ,
368368 "endpoint" : map [string ]interface {}{
369- "url" : request .URL .String (),
369+ "url" : util . CleanPasswordFromURL ( request .URL .String () ),
370370 "method" : methodUsed ,
371371 "headers" : headersPassed ,
372372 "body" : bodyAsMap ,
Original file line number Diff line number Diff line change @@ -57,16 +57,23 @@ func cleanSenstiveData(vars *[]interface{}) {
5757 continue
5858 }
5959
60- // Check if URL
61- isURL , _ := regexp .MatchString (`^https?://(www.)?.+\..+$` , stringedVar )
62- if ! isURL {
63- continue
64- }
65-
66- // If it is an URL, clean it up
67- cleanerRe := regexp .MustCompile (`\/\/(?P<username>.+):.+@` )
68- cleanedVar := cleanerRe .ReplaceAllString (stringedVar , "//${username}:***@" )
60+ cleanedVar := CleanPasswordFromURL (stringedVar )
6961
7062 (* vars )[index ] = cleanedVar
7163 }
7264}
65+
66+ // CleanPasswordFromURL will clean password from the URL if
67+ // it is present
68+ func CleanPasswordFromURL (URL string ) string {
69+ // Check if URL
70+ isURL , _ := regexp .MatchString (`^https?://(www.)?.+\..+$` , URL )
71+ if ! isURL {
72+ return URL
73+ }
74+
75+ // If it is an URL, clean it up
76+ cleanerRe := regexp .MustCompile (`\/\/(?P<username>.+):.+@` )
77+ cleanedVar := cleanerRe .ReplaceAllString (URL , "//${username}:********@" )
78+ return cleanedVar
79+ }
You can’t perform that action at this time.
0 commit comments