Skip to content

Commit

Permalink
eskip: ParsePredicates does not fail on invalid input
Browse files Browse the repository at this point in the history
Test case from #2755 discovered by fuzzing fails.

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov committed Jan 12, 2024
1 parent d238294 commit 51e73f2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions eskip/eskip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,22 @@ func TestPredicateParsing(t *testing.T) {
}, {
title: "star notation",
input: `*`,
}, {
title: "invalid fuzz 1",
input: `///`,
fail: true,
}, {
title: "invalid fuzz 2",
input: "\x2f\x2f\x00\x00\x00\xe6\xfe\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\xe6\xfe\x00\x00\x2f\x00\x00\x00\x00",
fail: true,
}} {
t.Run(test.title, func(t *testing.T) {
p, err := ParsePredicates(test.input)

if err == nil && test.fail {
t.Error("failed to fail")
return
t.Fatalf("failed to fail: %#v", p)
} else if err != nil && !test.fail {
t.Error(err)
return
t.Fatal(err)
}

if !cmp.Equal(p, test.expected) {
Expand Down

0 comments on commit 51e73f2

Please sign in to comment.