package bundle import ( "fmt" "path" "strings" ) const distributorStateName = ".distributor.json" func ValidateSourcePath(value string) error { if value == "" { return fmt.Errorf("source path is required") } if strings.Contains(value, "\\") || strings.HasPrefix(value, "/") { return fmt.Errorf("source path %q must be a clean relative slash-separated path", value) } if path.Clean(value) != value { return fmt.Errorf("source path %q must be a clean relative slash-separated path", value) } for _, segment := range strings.Split(value, "/") { if segment == "" || segment == "." || segment == ".." { return fmt.Errorf("source path %q must be a clean relative slash-separated path", value) } } switch value { case ManifestName, distributorStateName: return fmt.Errorf("%q is reserved", value) } return nil }