Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: buildkite/agent
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4668e2ba1b8c44a89c87ccd824424453f79a8865
Choose a base ref
..
head repository: buildkite/agent
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8b42a7cd38a6eb36abe9dc08e9d2d8a04066f92b
Choose a head ref
Showing with 24 additions and 0 deletions.
  1. +24 −0 internal/replacer/replacer_test.go
24 changes: 24 additions & 0 deletions internal/replacer/replacer_test.go
Original file line number Diff line number Diff line change
@@ -256,6 +256,30 @@ func TestReplacerMultiLineCrLf(t *testing.T) {
}
}

func TestReplacerMultiLineCrCrLf(t *testing.T) {
t.Parallel()

var buf strings.Builder

replacer := replacer.New(&buf, []string{"-----BEGIN OPENSSH PRIVATE KEY-----\nasdf\n-----END OPENSSH PRIVATE KEY-----\n"}, redact.Redact)

// Thanks to some combination of baked-mode PTY and other processing, log
// output linebreaks often look like \r\r\n, which is annoying both when
// redacting secrets and when opening them in a text editor.
fmt.Fprint(replacer, "lalalala\r\r\n")
fmt.Fprint(replacer, "-----BEGIN OPENSSH PRIVATE KEY-----\r\r\n")
fmt.Fprint(replacer, "asdf\r\r\n")
fmt.Fprint(replacer, "-----END OPENSSH PRIVATE KEY-----\r\r\n")
fmt.Fprint(replacer, "lalalala\r\r\n")
replacer.Flush()

want := "lalalala\r\r\n[REDACTED]lalalala\r\r\n"

if diff := cmp.Diff(buf.String(), want); diff != "" {
t.Errorf("post-redaction diff (-got +want):\n%s", diff)
}
}

func TestAddingNeedles(t *testing.T) {
t.Parallel()