Documentation
¶
Overview ¶
Package validator provides struct validation utilities with custom validators.
Package validator provides struct validation utilities with custom validators.
Package validator provides struct validation utilities with custom validators.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PropertiesValidator ¶
type PropertiesValidator struct {
// contains filtered or unexported fields
}
PropertiesValidator validates asset properties based on asset type.
func NewPropertiesValidator ¶
func NewPropertiesValidator() *PropertiesValidator
NewPropertiesValidator creates a new properties validator with default limits.
func (*PropertiesValidator) ValidateProperties ¶
func (v *PropertiesValidator) ValidateProperties(assetType string, properties map[string]any) PropertyErrors
ValidateProperties validates properties based on asset type.
type PropertyError ¶
PropertyError represents a property validation error.
type PropertyErrors ¶
type PropertyErrors []PropertyError
PropertyErrors is a collection of property validation errors.
func (PropertyErrors) Error ¶
func (e PropertyErrors) Error() string
Error implements the error interface.
type TargetType ¶
type TargetType string
TargetType represents the type of scan target.
const ( TargetTypeDomain TargetType = "domain" TargetTypeIPv4 TargetType = "ipv4" TargetTypeIPv6 TargetType = "ipv6" TargetTypeCIDR TargetType = "cidr" TargetTypeURL TargetType = "url" TargetTypeHostPort TargetType = "host_port" TargetTypeUnknown TargetType = "unknown" )
type TargetValidationResult ¶
type TargetValidationResult struct {
Valid []ValidatedTarget `json:"valid"`
Invalid []ValidatedTarget `json:"invalid"`
TotalCount int `json:"total_count"`
ValidCount int `json:"valid_count"`
HasErrors bool `json:"has_errors"`
BlockedIPs []string `json:"blocked_ips,omitempty"`
}
TargetValidationResult contains the results of validating multiple targets.
func (*TargetValidationResult) GetTargetsByType ¶
func (r *TargetValidationResult) GetTargetsByType(targetType TargetType) []ValidatedTarget
GetTargetsByType returns targets filtered by type.
func (*TargetValidationResult) GetValidTargetStrings ¶
func (r *TargetValidationResult) GetValidTargetStrings() []string
GetValidTargetStrings returns only the valid target strings.
type TargetValidator ¶
type TargetValidator struct {
// contains filtered or unexported fields
}
TargetValidator validates and classifies scan targets.
func NewTargetValidator ¶
func NewTargetValidator(opts ...TargetValidatorOption) *TargetValidator
NewTargetValidator creates a new TargetValidator with options.
func (*TargetValidator) ValidateSingleTarget ¶
func (v *TargetValidator) ValidateSingleTarget(target string) ValidatedTarget
ValidateSingleTarget validates and classifies a single target.
func (*TargetValidator) ValidateTargets ¶
func (v *TargetValidator) ValidateTargets(targets []string) *TargetValidationResult
ValidateTargets validates a list of targets and returns classified results.
type TargetValidatorOption ¶
type TargetValidatorOption func(*TargetValidator)
TargetValidatorOption is a functional option for TargetValidator.
func WithAllowInternalIPs ¶
func WithAllowInternalIPs(allow bool) TargetValidatorOption
WithAllowInternalIPs allows internal IP addresses (10.x, 172.16.x, 192.168.x).
func WithAllowLocalhost ¶
func WithAllowLocalhost(allow bool) TargetValidatorOption
WithAllowLocalhost allows localhost addresses.
func WithMaxTargets ¶
func WithMaxTargets(max int) TargetValidatorOption
WithMaxTargets sets the maximum number of targets allowed.
type ValidatedTarget ¶
type ValidatedTarget struct {
Original string `json:"original"`
Type TargetType `json:"type"`
Value string `json:"value"`
Port int `json:"port,omitempty"`
IsValid bool `json:"is_valid"`
Error string `json:"error,omitempty"`
}
ValidatedTarget represents a validated and classified target.
type ValidationError ¶
ValidationError represents a single field validation error.
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is a collection of validation errors.
func (ValidationErrors) Error ¶
func (v ValidationErrors) Error() string
Error implements the error interface.