Skip to content

Commit

Permalink
remove path for deduping URI
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker committed Nov 6, 2022
1 parent 2898303 commit 5f0964a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions pkg/detectors/uri/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}

redact := strings.TrimSpace(strings.Replace(urlMatch, password, strings.Repeat("*", len(password)), -1))
rawURL, _ := url.Parse(urlMatch)
rawURL.Path = ""

redact := strings.TrimSpace(strings.Replace(rawURL.String(), password, strings.Repeat("*", len(password)), -1))

s := detectors.Result{
DetectorType: detectorspb.DetectorType_URI,
Raw: []byte(urlMatch),
Raw: []byte(rawURL.String()),
Redacted: redact,
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/detectors/uri/uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestURI_FromChunk(t *testing.T) {
{
DetectorType: detectorspb.DetectorType_URI,
Verified: false,
Redacted: "https://user:****@www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx",
Redacted: "https://user:****@www.httpwatch.com",
},
},
wantErr: false,
Expand All @@ -55,7 +55,7 @@ func TestURI_FromChunk(t *testing.T) {
{
DetectorType: detectorspb.DetectorType_URI,
Verified: true,
Redacted: "https://httpwatch:****@www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx",
Redacted: "https://httpwatch:****@www.httpwatch.com",
},
},
wantErr: false,
Expand All @@ -72,7 +72,7 @@ func TestURI_FromChunk(t *testing.T) {
{
DetectorType: detectorspb.DetectorType_URI,
Verified: true,
Redacted: "https://httpwatch:****@www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx",
Redacted: "https://httpwatch:****@www.httpwatch.com",
},
},
wantErr: false,
Expand Down

0 comments on commit 5f0964a

Please sign in to comment.