-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url sanitation using regex replaced with parse and redact
- Loading branch information
Showing
4 changed files
with
47 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,19 +353,28 @@ func testDependencyCache(t *testing.T, context spec.G, it spec.S) { | |
ghttp.RespondWith(http.StatusOK, "test-fixture"), | ||
)) | ||
|
||
url, err := url.Parse(dependency.URI) | ||
url, err := url.ParseRequestURI(dependency.URI) | ||
Expect(err).NotTo(HaveOccurred()) | ||
credentials := "basic-username:basic-password" | ||
urlWithBasicCreds := url.Scheme + "://" + credentials + "@" + url.Hostname() + ":" + url.Port() + url.Path | ||
dependency.URI = urlWithBasicCreds | ||
credentials := "username:password" | ||
uriWithBasicCreds := url.Scheme + "://" + credentials + "@" + url.Hostname() + ":" + url.Port() + url.Path | ||
dependency.URI = uriWithBasicCreds | ||
|
||
var logBuffer bytes.Buffer | ||
captureLogger := bard.NewLogger(&logBuffer) | ||
dependencyCache.Logger = captureLogger | ||
a, err := dependencyCache.Artifact(dependency) | ||
Expect(err).NotTo(HaveOccurred()) | ||
dependencyCache.Logger = bard.NewLogger(&logBuffer) | ||
|
||
// Make sure the password is not part of the log output. | ||
a, errA := dependencyCache.Artifact(dependency) | ||
Expect(errA).NotTo(HaveOccurred()) | ||
Expect(a).NotTo(BeNil()) | ||
Expect(logBuffer.String()).NotTo(ContainSubstring(credentials)) | ||
Expect(logBuffer.String()).NotTo(ContainSubstring("password")) | ||
logBuffer.Reset() | ||
|
||
// Make sure the password is not part of the log output when an error occurs. | ||
dependency.URI = "foo://username:[email protected]" | ||
b, errB := dependencyCache.Artifact(dependency) | ||
Expect(errB).To(HaveOccurred()) | ||
Expect(b).To(BeNil()) | ||
Expect(logBuffer.String()).NotTo(ContainSubstring("password")) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters