Documentation
¶
Overview ¶
Package validation provides validation utilities for config files and other inputs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IsSecurePath = func(path string) error { clean := filepath.Clean(path) parts := strings.Split(clean, string(os.PathSeparator)) for _, part := range parts { if part == ".." { return fmt.Errorf("path contains '..', which is not allowed") } } return nil }
IsSecurePath checks if a given file path is secure and does not contain any path traversal sequences ("../" or "..\\"). This function is crucial for preventing directory traversal attacks, where a malicious actor could otherwise access or manipulate files outside of the intended directory.
path is the file path to be validated. It returns an error if the path is found to be insecure, and nil otherwise. IsSecurePath checks if a given file path is secure. It is a variable to allow mocking in tests.
Functions ¶
func FileExists ¶
FileExists checks if a file exists at the given path.
func IsValidBindAddress ¶
IsValidBindAddress checks if a given string is a valid bind address. A valid bind address is in the format "host:port".
func IsValidURL ¶
IsValidURL checks if a given string is a valid URL. This function performs several checks, including for length, whitespace, the presence of a scheme, and host, considering special cases for schemes like "unix" or "mailto" that do not require a host.
s is the string to be validated. It returns true if the string is a valid URL, and false otherwise.
func ValidateHTTPServiceDefinition ¶
func ValidateHTTPServiceDefinition(def *configv1.HttpCallDefinition) error
ValidateHTTPServiceDefinition checks the validity of an HttpCallDefinition. It ensures that the endpoint path is specified and correctly formatted, and that a valid HTTP method is set.
def is the HttpCallDefinition to be validated. It returns an error if the definition is invalid, and nil otherwise.
Types ¶
This section is empty.