validator

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package validator provides configuration validation functionality. This package wraps cli-kit/validator for backward compatibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateConfigPath

func ValidateConfigPath(path string, allowedDirs []string) (string, error)

ValidateConfigPath validates configuration file path to prevent path traversal attacks

This function validates configuration file path, including: - Checks if path contains path traversal characters (..) - Validates if path is absolute or relative path - Optional: restrict configuration files to be read only from specific directories

This function delegates to cli-kit/validator.ValidatePath.

Parameters:

  • path: file path to validate
  • allowedDirs: list of allowed directories (optional, if empty then no directory restriction)

Returns:

  • string: normalized absolute path
  • error: returns error if path is invalid or has security risks; otherwise returns nil

func ValidateRemoteURL

func ValidateRemoteURL(urlStr string) error

ValidateRemoteURL validates remote configuration URL to prevent SSRF attacks

This function performs strict validation on remote configuration URL, including: - Only allows http:// and https:// protocols - Prohibits access to private IP addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8) - Prohibits access to localhost - Validates URL format validity

This function delegates to cli-kit/validator.ValidateURL with secure defaults.

Parameters:

  • urlStr: URL string to validate

Returns:

  • error: returns error if URL is invalid or has security risks; otherwise returns nil

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL