diff --git a/pkg/utils/validation/validation_test.go b/pkg/utils/validation/validation_test.go index c802a0df21d..2ba2cd724f1 100644 --- a/pkg/utils/validation/validation_test.go +++ b/pkg/utils/validation/validation_test.go @@ -19,9 +19,23 @@ package validation import ( "fmt" "path/filepath" + "strings" "testing" ) +func FuzzIsSafePath(f *testing.F) { + // f.Add() + f.Fuzz(func(t *testing.T, input string) { + err := IsValidMountRoot(input) + if err == nil { + // valid input must start with "/" + if !strings.HasPrefix(input, string(filepath.Separator)) { + t.Errorf("testcase %s failed, expect the input starts with '/'", input) + } + } + }) +} + func TestIsSafePathWithSafePath(t *testing.T) { type testCase struct {