Skip to content

Commit 9d30be9

Browse files
authored
Merge pull request #3448 from buildkite/replacer-fuzz-test-corpus
Add replacer fuzz test corpus to repo, with fix
2 parents 7c01a33 + 34d2a1f commit 9d30be9

228 files changed

Lines changed: 1587 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

internal/replacer/replacer_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ func TestAddingNeedles(t *testing.T) {
354354
}
355355

356356
func BenchmarkReplacer(b *testing.B) {
357-
b.ResetTimer()
357+
358358
r := replacer.New(io.Discard, bigLipsumSecrets, redact.Redacted)
359-
for range b.N {
359+
for b.Loop() {
360360
if _, err := fmt.Fprintln(r, bigLipsum); err != nil {
361361
b.Errorf("fmt.Fprintln(r, bigLipsum) error = %v", err)
362362
}
@@ -376,14 +376,15 @@ func FuzzReplacer(f *testing.F) {
376376
f.Add(lipsum, 10, "ipsum", "dolor", "sit", "amet")
377377
f.Add(lipsum, 10, "a", "e", "i", "o")
378378
f.Fuzz(func(t *testing.T, plaintext string, split int, a, b, c, d string) {
379-
// Don't allow empty secrets, or secrets containing a character from
380-
// the redaction substitution.
379+
// Don't allow empty secrets, whitespace only secrets, or secrets
380+
// containing a character from the redaction substitution.
381381
// - Replacing a secret with '[REDACTED]' may create text that happens
382382
// to be another secret.
383383
// - Unless disallowed, the fuzzer tends to rapidly find secrets like
384384
// "A" (one of the characters in REDACTED).
385385
secrets := make([]string, 0, 4)
386386
for _, s := range []string{a, b, c, d} {
387+
s = strings.TrimSpace(s)
387388
if s == "" || strings.ContainsAny(s, "[REDACTED]") {
388389
continue
389390
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("000000000000000000000000000000000000000000000")
3+
int(-8)
4+
string("00")
5+
string("0")
6+
string("0")
7+
string("000")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("0")
3+
int(10)
4+
string("0")
5+
string("0")
6+
string("\xc6 ")
7+
string("0")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("0")
3+
int(10)
4+
string("0")
5+
string("0")
6+
string("0\u0085")
7+
string("")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
3+
int(-19)
4+
string("0")
5+
string("0")
6+
string("0")
7+
string("0")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("0000000000000000000000000000000000000000000000000000000000000000")
3+
int(10)
4+
string("0")
5+
string("0")
6+
string("0")
7+
string("0")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("0")
3+
int(10)
4+
string("")
5+
string("")
6+
string("0A")
7+
string(" ")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("0")
3+
int(10)
4+
string("\xc3\xdc")
5+
string("0")
6+
string("")
7+
string("0")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("0")
3+
int(10)
4+
string("")
5+
string("A")
6+
string("")
7+
string("")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go test fuzz v1
2+
string("00000000000000000")
3+
int(28)
4+
string("0")
5+
string("00")
6+
string("0")
7+
string("")

0 commit comments

Comments
 (0)