Documentation
¶
Overview ¶
Package naming validates and sanitizes ToolHive workload names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidWorkloadName = httperr.WithCode( errors.New("invalid workload name"), http.StatusBadRequest, )
ErrInvalidWorkloadName is returned when a workload name fails validation.
Functions ¶
func SanitizeWorkloadName ¶
SanitizeWorkloadName sanitizes a user-provided workload name to ensure it's safe for file paths. It applies the same security analysis as ValidateWorkloadName but transforms invalid characters instead of rejecting them. This provides a more permissive approach for user-facing scenarios where we want to accept user input and make it safe rather than rejecting it. Returns the sanitized name and a boolean indicating whether the name was modified.
func ValidateWorkloadName ¶
ValidateWorkloadName checks if the provided workload name is valid. This function performs strict validation and rejects invalid names.
Types ¶
type WorkloadNameIssue ¶
type WorkloadNameIssue struct {
Type string // "empty", "path_traversal", "absolute_path", "command_injection", "null_bytes", "invalid_chars", "too_long"
Description string
Position int // For character-specific issues
}
WorkloadNameIssue represents a specific issue found in a workload name