Documentation
¶
Index ¶
- Variables
- func ExtractVersionFromShorthand(shorthand string) string
- func FormatGitHubShorthand(org, repo, path, version string) string
- func InitNotificationDedup(cooldown time.Duration)
- func IsBranch(version string) bool
- func IsEmpty(i interface{}) bool
- func IsGitHubShorthand(s string) bool
- func IsSemanticVersion(version string) bool
- func IsVersioned(shorthand string) bool
- func NewMail(c *MailConfig) core.Middleware
- func NewOverlap(c *OverlapConfig) core.Middleware
- func NewSafeTransport() *http.Transport
- func NewSave(c *SaveConfig) core.Middleware
- func NewSlack(c *SlackConfig) core.Middlewaredeprecated
- func NewWebhook(config *WebhookConfig, loader *PresetLoader) (core.Middleware, error)
- func NewWebhookMiddleware(webhooks []core.Middleware) core.Middleware
- func ParseGitHubShorthand(shorthand string) (string, error)
- func ParseWebhookNames(s string) []string
- func SanitizeFilename(filename string) string
- func SanitizeJobName(jobName string) string
- func SanitizePath(path string) string
- func StripVersionFromShorthand(shorthand string) string
- func ValidateGitHubShorthand(shorthand string) error
- func ValidateWebhookURLImpl(rawURL string) error
- type CacheStats
- type GitHubShorthand
- type Mail
- type MailConfig
- type NotificationDedup
- type Overlap
- type OverlapConfig
- type PathSanitizer
- type Preset
- type PresetCache
- type PresetDataForTemplate
- type PresetLoader
- type PresetVariable
- type Save
- type SaveConfig
- type Slack
- type SlackConfig
- type TriggerType
- type Webhook
- type WebhookConfig
- type WebhookData
- type WebhookExecutionData
- type WebhookGlobalConfig
- type WebhookHostData
- type WebhookJobData
- type WebhookManager
- type WebhookMiddleware
- type WebhookOfeliaData
- type WebhookSecurityConfig
- type WebhookSecurityValidator
Constants ¶
This section is empty.
Variables ¶
var DefaultSanitizer = NewPathSanitizer()
Default sanitizer instance
var TransportFactory = NewSafeTransport
TransportFactory creates HTTP transports for webhook requests. This can be overridden in tests to bypass DNS rebinding protection.
var ValidateWebhookURL func(rawURL string) error
ValidateWebhookURL validates a URL is safe for webhook requests (SSRF protection) This is a forward declaration - implementation in webhook_security.go
var Version = "dev"
Version is set during build and used in webhook templates
Functions ¶
func ExtractVersionFromShorthand ¶ added in v0.16.0
ExtractVersionFromShorthand extracts the version from a shorthand
func FormatGitHubShorthand ¶ added in v0.16.0
FormatGitHubShorthand creates a shorthand string from components
func InitNotificationDedup ¶ added in v0.16.0
InitNotificationDedup initializes the global deduplicator with the specified cooldown period. Call this during configuration loading.
func IsGitHubShorthand ¶ added in v0.16.0
IsGitHubShorthand checks if a string is a GitHub shorthand
func IsSemanticVersion ¶ added in v0.16.0
IsSemanticVersion checks if a version string looks like a semantic version
func IsVersioned ¶ added in v0.16.0
IsVersioned checks if the shorthand includes an explicit version
func NewMail ¶
func NewMail(c *MailConfig) core.Middleware
NewMail returns a Mail middleware if the given configuration is not empty
func NewOverlap ¶
func NewOverlap(c *OverlapConfig) core.Middleware
NewOverlap returns a Overlap middleware if the given configuration is not empty
func NewSafeTransport ¶ added in v0.16.0
NewSafeTransport creates an HTTP transport with DNS rebinding protection. It validates that resolved IP addresses are not private or loopback addresses, preventing DNS rebinding attacks where a domain initially resolves to a public IP but later resolves to a private/internal IP.
func NewSave ¶
func NewSave(c *SaveConfig) core.Middleware
NewSave returns a Save middleware if the given configuration is not empty
func NewSlack
deprecated
func NewSlack(c *SlackConfig) core.Middleware
NewSlack returns a Slack middleware if the given configuration is not empty
Deprecated: The Slack middleware is deprecated and will be removed in v0.8.0. Please migrate to the generic webhook notification system with the "slack" preset:
[webhook "slack-alerts"] preset = slack id = T00000000/B00000000 secret = XXXXXXXXXXXXXXXXXXXXXXXX trigger = error
The new webhook system provides retry logic, multiple webhooks, and support for other services (Discord, Teams, ntfy, Pushover, PagerDuty, Gotify, etc.)
func NewWebhook ¶ added in v0.16.0
func NewWebhook(config *WebhookConfig, loader *PresetLoader) (core.Middleware, error)
NewWebhook creates a new Webhook middleware from configuration. Returns (nil, nil) when config is nil, indicating no middleware should be created.
func NewWebhookMiddleware ¶ added in v0.16.0
func NewWebhookMiddleware(webhooks []core.Middleware) core.Middleware
NewWebhookMiddleware creates a composite middleware from multiple webhook middlewares
func ParseGitHubShorthand ¶ added in v0.16.0
ParseGitHubShorthand parses a GitHub shorthand URL and returns the raw URL Format: gh:org/repo/path/to/file.yaml@version Examples:
- gh:netresearch/ofelia-presets/slack.yaml
- gh:netresearch/ofelia-presets/notifications/slack.yaml@v1.0.0
- gh:myorg/my-presets/custom@main
func ParseWebhookNames ¶ added in v0.16.0
ParseWebhookNames parses a comma-separated list of webhook names
func SanitizeFilename ¶ added in v0.10.1
SanitizeFilename is a convenience function using the default sanitizer
func SanitizeJobName ¶ added in v0.10.1
SanitizeJobName is a convenience function using the default sanitizer
func SanitizePath ¶ added in v0.10.1
SanitizePath is a convenience function using the default sanitizer
func StripVersionFromShorthand ¶ added in v0.16.0
StripVersionFromShorthand removes the version from a shorthand
func ValidateGitHubShorthand ¶ added in v0.16.0
ValidateGitHubShorthand validates that a GitHub shorthand is well-formed
func ValidateWebhookURLImpl ¶ added in v0.16.0
ValidateWebhookURLImpl validates a URL for SSRF protection
Types ¶
type CacheStats ¶ added in v0.16.0
CacheStats holds cache statistics
type GitHubShorthand ¶ added in v0.16.0
type GitHubShorthand struct {
Org string
Repo string
Path string
Version string // Can be tag, branch, or commit
}
GitHubShorthand represents a parsed GitHub shorthand URL
func ParseGitHubShorthandDetails ¶ added in v0.16.0
func ParseGitHubShorthandDetails(shorthand string) (*GitHubShorthand, error)
ParseGitHubShorthandDetails parses and returns the structured details
type Mail ¶
type Mail struct {
MailConfig
}
Mail middleware delivers a email just after an execution finishes
func (*Mail) ContinueOnStop ¶
ContinueOnStop always returns true; we always want to report the final status
type MailConfig ¶
type MailConfig struct {
SMTPHost string `gcfg:"smtp-host" mapstructure:"smtp-host"`
SMTPPort int `gcfg:"smtp-port" mapstructure:"smtp-port"`
SMTPUser string `gcfg:"smtp-user" mapstructure:"smtp-user" json:"-"`
SMTPPassword string `gcfg:"smtp-password" mapstructure:"smtp-password" json:"-"`
SMTPTLSSkipVerify bool `gcfg:"smtp-tls-skip-verify" mapstructure:"smtp-tls-skip-verify"`
EmailTo string `gcfg:"email-to" mapstructure:"email-to"`
EmailFrom string `gcfg:"email-from" mapstructure:"email-from"`
EmailSubject string `gcfg:"email-subject" mapstructure:"email-subject"`
MailOnlyOnError bool `gcfg:"mail-only-on-error" mapstructure:"mail-only-on-error"`
// Dedup is the notification deduplicator (set by config loader, not INI)
Dedup *NotificationDedup `mapstructure:"-" json:"-"`
// contains filtered or unexported fields
}
MailConfig configuration for the Mail middleware
type NotificationDedup ¶ added in v0.16.0
type NotificationDedup struct {
// contains filtered or unexported fields
}
NotificationDedup provides deduplication of error notifications. It tracks recent error notifications and suppresses duplicates within a configurable cooldown period to prevent notification spam.
var DefaultNotificationDedup *NotificationDedup
DefaultNotificationDedup is the global deduplicator instance used by notification middlewares. It's initialized when configuration is loaded.
func NewNotificationDedup ¶ added in v0.16.0
func NewNotificationDedup(cooldown time.Duration) *NotificationDedup
NewNotificationDedup creates a new notification deduplicator with the specified cooldown period. If cooldown is 0, deduplication is disabled and all notifications are allowed.
func (*NotificationDedup) Cleanup ¶ added in v0.16.0
func (d *NotificationDedup) Cleanup()
Cleanup removes expired entries from the deduplication map. This should be called periodically to prevent memory leaks for jobs that no longer fail.
func (*NotificationDedup) Len ¶ added in v0.16.0
func (d *NotificationDedup) Len() int
Len returns the number of entries in the deduplication map. Useful for testing and monitoring.
func (*NotificationDedup) ShouldNotify ¶ added in v0.16.0
func (d *NotificationDedup) ShouldNotify(ctx *core.Context) bool
ShouldNotify returns true if the notification should be sent, false if it should be suppressed as a duplicate. Successful executions always return true (no deduplication for success). Failed executions are deduplicated based on job name, command, and error message.
func (*NotificationDedup) StartCleanupRoutine ¶ added in v0.16.0
func (d *NotificationDedup) StartCleanupRoutine(interval time.Duration) func()
StartCleanupRoutine starts a background goroutine that periodically cleans up expired entries. Returns a stop function to cancel the routine.
type Overlap ¶
type Overlap struct {
OverlapConfig
}
Overlap when this middleware is enabled avoid to overlap executions from a specific job
func (*Overlap) ContinueOnStop ¶
ContinueOnStop Overlap is only called if the process is still running
type OverlapConfig ¶
type OverlapConfig struct {
NoOverlap bool `gcfg:"no-overlap" mapstructure:"no-overlap"`
}
OverlapConfig configuration for the Overlap middleware
type PathSanitizer ¶ added in v0.10.1
type PathSanitizer struct {
// contains filtered or unexported fields
}
PathSanitizer provides secure path sanitization utilities
func NewPathSanitizer ¶ added in v0.10.1
func NewPathSanitizer() *PathSanitizer
NewPathSanitizer creates a new path sanitizer with security rules
func (*PathSanitizer) SanitizeFilename ¶ added in v0.10.1
func (ps *PathSanitizer) SanitizeFilename(filename string) string
SanitizeFilename sanitizes a filename for safe file system operations
func (*PathSanitizer) SanitizeJobName ¶ added in v0.10.1
func (ps *PathSanitizer) SanitizeJobName(jobName string) string
SanitizeJobName sanitizes a job name for use in filenames
func (*PathSanitizer) SanitizePath ¶ added in v0.10.1
func (ps *PathSanitizer) SanitizePath(path string) string
SanitizePath sanitizes a path to prevent directory traversal and injection
func (*PathSanitizer) ValidateSaveFolder ¶ added in v0.10.1
func (ps *PathSanitizer) ValidateSaveFolder(folder string) error
ValidateSaveFolder validates that a save folder path is safe to use
type Preset ¶ added in v0.16.0
type Preset struct {
// Metadata
Name string `yaml:"name"`
Description string `yaml:"description"`
Version string `yaml:"version"`
// URL configuration
URLScheme string `yaml:"url_scheme"` //nolint:tagliatelle // snake_case is idiomatic for YAML configs
// HTTP configuration
Method string `yaml:"method"`
Headers map[string]string `yaml:"headers"`
// Variable definitions
Variables map[string]PresetVariable `yaml:"variables"`
// Body template (Go text/template format)
Body string `yaml:"body"`
}
Preset defines a webhook notification preset
func ParsePreset ¶ added in v0.16.0
ParsePreset parses a preset from YAML data
func (*Preset) BuildURL ¶ added in v0.16.0
func (p *Preset) BuildURL(config *WebhookConfig) (string, error)
BuildURL constructs the final URL by substituting variables
func (*Preset) RenderBody ¶ added in v0.16.0
func (p *Preset) RenderBody(data *WebhookData) (string, error)
RenderBody renders the body template with the given data
type PresetCache ¶ added in v0.16.0
type PresetCache struct {
// contains filtered or unexported fields
}
PresetCache provides caching for remote presets
func NewPresetCache ¶ added in v0.16.0
func NewPresetCache(cacheDir string, ttl time.Duration) *PresetCache
NewPresetCache creates a new preset cache
func (*PresetCache) Cleanup ¶ added in v0.16.0
func (c *PresetCache) Cleanup() error
Cleanup removes expired entries from cache
func (*PresetCache) Clear ¶ added in v0.16.0
func (c *PresetCache) Clear() error
Clear removes all cached presets
func (*PresetCache) Get ¶ added in v0.16.0
func (c *PresetCache) Get(url string) (*Preset, error)
Get retrieves a preset from cache
func (*PresetCache) Invalidate ¶ added in v0.16.0
func (c *PresetCache) Invalidate(url string)
Invalidate removes a preset from cache
func (*PresetCache) Put ¶ added in v0.16.0
func (c *PresetCache) Put(url string, preset *Preset) error
Put stores a preset in cache
func (*PresetCache) Stats ¶ added in v0.16.0
func (c *PresetCache) Stats() CacheStats
Stats returns cache statistics
type PresetDataForTemplate ¶ added in v0.16.0
type PresetDataForTemplate struct {
ID string
Secret string
URL string
Link string
LinkText string
}
PresetDataForTemplate provides preset config to templates that need it
type PresetLoader ¶ added in v0.16.0
type PresetLoader struct {
// contains filtered or unexported fields
}
PresetLoader handles loading presets from various sources
func NewPresetLoader ¶ added in v0.16.0
func NewPresetLoader(globalConfig *WebhookGlobalConfig) *PresetLoader
NewPresetLoader creates a new preset loader
func (*PresetLoader) AddLocalPresetDir ¶ added in v0.16.0
func (l *PresetLoader) AddLocalPresetDir(dir string)
AddLocalPresetDir adds a directory to search for local preset files
func (*PresetLoader) GetBundledPreset ¶ added in v0.16.0
func (l *PresetLoader) GetBundledPreset(name string) (*Preset, bool)
GetBundledPreset returns a bundled preset by name
func (*PresetLoader) ListBundledPresets ¶ added in v0.16.0
func (l *PresetLoader) ListBundledPresets() []string
ListBundledPresets returns the names of all bundled presets
func (*PresetLoader) Load ¶ added in v0.16.0
func (l *PresetLoader) Load(presetSpec string) (*Preset, error)
Load loads a preset by name or path Supports: - Built-in preset names: "slack", "discord", etc. - Local file paths: "/path/to/preset.yaml", "./preset.yaml" - GitHub shorthand: "gh:org/repo/path/preset.yaml@v1.0" - Full URLs: "https://example.com/preset.yaml"
type PresetVariable ¶ added in v0.16.0
type PresetVariable struct {
Description string `yaml:"description"`
Required bool `yaml:"required"`
Sensitive bool `yaml:"sensitive"`
Default string `yaml:"default,omitempty"`
Example string `yaml:"example,omitempty"`
}
PresetVariable defines a variable that can be used in the preset
type Save ¶
type Save struct {
SaveConfig
}
Save the save middleware saves to disk a dump of the stdout and stderr after every execution of the process
func (*Save) ContinueOnStop ¶
ContinueOnStop always returns true; we always want to report the final status
type SaveConfig ¶
type SaveConfig struct {
SaveFolder string `gcfg:"save-folder" mapstructure:"save-folder"`
SaveOnlyOnError bool `gcfg:"save-only-on-error" mapstructure:"save-only-on-error"`
}
SaveConfig configuration for the Save middleware
type Slack ¶
type Slack struct {
SlackConfig
Client *http.Client
}
Slack middleware calls to a Slack input-hook after every execution of a job
func (*Slack) ContinueOnStop ¶
ContinueOnStop always returns true; we always want to report the final status
type SlackConfig ¶
type SlackConfig struct {
SlackWebhook string `gcfg:"slack-webhook" mapstructure:"slack-webhook" json:"-"`
SlackOnlyOnError bool `gcfg:"slack-only-on-error" mapstructure:"slack-only-on-error"`
// Dedup is the notification deduplicator (set by config loader, not INI)
Dedup *NotificationDedup `mapstructure:"-" json:"-"`
}
SlackConfig configuration for the Slack middleware
type TriggerType ¶ added in v0.16.0
type TriggerType string
TriggerType defines when a webhook notification should be sent
const ( TriggerAlways TriggerType = "always" // Send on every execution TriggerError TriggerType = "error" // Send only on errors TriggerSuccess TriggerType = "success" // Send only on success TriggerSkipped TriggerType = "skipped" // Send only on skipped executions )
type Webhook ¶ added in v0.16.0
type Webhook struct {
Config *WebhookConfig
Preset *Preset
PresetLoader *PresetLoader
Client *http.Client
}
Webhook middleware sends HTTP webhook notifications after job execution
func (*Webhook) ContinueOnStop ¶ added in v0.16.0
ContinueOnStop returns true because we want to report final execution status
type WebhookConfig ¶ added in v0.16.0
type WebhookConfig struct {
// Name is the unique identifier for this webhook (from INI section name)
Name string `gcfg:"-" mapstructure:"-"`
// Preset specifies the preset to use (e.g., "slack", "discord", "gh:org/repo/preset.yaml@v1.0")
Preset string `gcfg:"preset" mapstructure:"preset"`
// ID is a generic identifier used by the preset's URL scheme (e.g., Slack workspace/bot ID)
ID string `gcfg:"id" mapstructure:"id" json:"-"`
// Secret is a generic secret/token used by the preset's URL scheme
Secret string `gcfg:"secret" mapstructure:"secret" json:"-"`
// URL overrides the preset's url_scheme entirely (useful for custom endpoints)
URL string `gcfg:"url" mapstructure:"url" json:"-"`
// Link is an optional URL to include in notifications (e.g., link to logs, dashboard)
Link string `gcfg:"link" mapstructure:"link"`
// LinkText is the display text for the link (defaults to "View Details" if link is set)
LinkText string `gcfg:"link-text" mapstructure:"link-text"`
// Trigger determines when to send notifications
Trigger TriggerType `gcfg:"trigger" mapstructure:"trigger"`
// Timeout for the HTTP request
Timeout time.Duration `gcfg:"timeout" mapstructure:"timeout"`
// RetryCount is the number of retry attempts on failure
RetryCount int `gcfg:"retry-count" mapstructure:"retry-count"`
// RetryDelay is the delay between retry attempts
RetryDelay time.Duration `gcfg:"retry-delay" mapstructure:"retry-delay"`
// CustomVars holds additional custom variables for template expansion
CustomVars map[string]string `gcfg:"-" mapstructure:"-"`
// Dedup is the notification deduplicator (set by config loader, not INI)
Dedup *NotificationDedup `mapstructure:"-" json:"-"`
}
WebhookConfig holds configuration for a single webhook endpoint
func DefaultWebhookConfig ¶ added in v0.16.0
func DefaultWebhookConfig() *WebhookConfig
DefaultWebhookConfig returns default webhook configuration values
func (*WebhookConfig) ApplyDefaults ¶ added in v0.16.0
func (c *WebhookConfig) ApplyDefaults()
ApplyDefaults applies default values to empty fields
func (*WebhookConfig) ShouldNotify ¶ added in v0.16.0
func (c *WebhookConfig) ShouldNotify(failed, skipped bool) bool
ShouldNotify determines if a notification should be sent based on trigger and execution state
func (*WebhookConfig) Validate ¶ added in v0.16.0
func (c *WebhookConfig) Validate() error
Validate checks the webhook configuration for errors
type WebhookData ¶ added in v0.16.0
type WebhookData struct {
Job WebhookJobData
Execution WebhookExecutionData
Host WebhookHostData
Ofelia WebhookOfeliaData
}
WebhookData is the data structure passed to webhook templates
type WebhookExecutionData ¶ added in v0.16.0
type WebhookExecutionData struct {
ID string
Status string
Failed bool
Skipped bool
Duration time.Duration
Error string
Output string
Stderr string
ExitCode int
StartTime time.Time
EndTime time.Time
}
WebhookExecutionData contains execution information for templates
type WebhookGlobalConfig ¶ added in v0.16.0
type WebhookGlobalConfig struct {
// Webhooks is a comma-separated list of webhook names to use globally
Webhooks string `gcfg:"webhooks" mapstructure:"webhooks"`
// AllowRemotePresets enables fetching presets from remote URLs
AllowRemotePresets bool `gcfg:"allow-remote-presets" mapstructure:"allow-remote-presets"`
// TrustedPresetSources is a comma-separated list of trusted remote preset sources
// Supports glob patterns (e.g., "gh:netresearch/*", "gh:myorg/ofelia-presets/*")
TrustedPresetSources string `gcfg:"trusted-preset-sources" mapstructure:"trusted-preset-sources"`
// PresetCacheTTL is how long to cache remote presets
PresetCacheTTL time.Duration `gcfg:"preset-cache-ttl" mapstructure:"preset-cache-ttl"`
// PresetCacheDir is the directory for caching remote presets
PresetCacheDir string `gcfg:"preset-cache-dir" mapstructure:"preset-cache-dir"`
}
WebhookGlobalConfig holds global webhook settings
func DefaultWebhookGlobalConfig ¶ added in v0.16.0
func DefaultWebhookGlobalConfig() *WebhookGlobalConfig
DefaultWebhookGlobalConfig returns default global webhook configuration
type WebhookHostData ¶ added in v0.16.0
WebhookHostData contains host information for templates
type WebhookJobData ¶ added in v0.16.0
WebhookJobData contains job information for templates
type WebhookManager ¶ added in v0.16.0
type WebhookManager struct {
// contains filtered or unexported fields
}
WebhookManager manages multiple webhook configurations
func NewWebhookManager ¶ added in v0.16.0
func NewWebhookManager(globalConfig *WebhookGlobalConfig) *WebhookManager
NewWebhookManager creates a new webhook manager
func (*WebhookManager) Get ¶ added in v0.16.0
func (m *WebhookManager) Get(name string) (*WebhookConfig, bool)
Get returns a webhook configuration by name
func (*WebhookManager) GetGlobalMiddlewares ¶ added in v0.16.0
func (m *WebhookManager) GetGlobalMiddlewares() ([]core.Middleware, error)
GetGlobalMiddlewares returns middlewares for globally configured webhooks
func (*WebhookManager) GetMiddlewares ¶ added in v0.16.0
func (m *WebhookManager) GetMiddlewares(names []string) ([]core.Middleware, error)
GetMiddlewares returns middlewares for the specified webhook names
func (*WebhookManager) Register ¶ added in v0.16.0
func (m *WebhookManager) Register(config *WebhookConfig) error
Register adds a webhook configuration
type WebhookMiddleware ¶ added in v0.16.0
type WebhookMiddleware struct {
// contains filtered or unexported fields
}
WebhookMiddleware is a composite middleware that dispatches to multiple webhooks
func (*WebhookMiddleware) ContinueOnStop ¶ added in v0.16.0
func (w *WebhookMiddleware) ContinueOnStop() bool
ContinueOnStop returns true because we want to report final status
type WebhookOfeliaData ¶ added in v0.16.0
type WebhookOfeliaData struct {
Version string
}
WebhookOfeliaData contains Ofelia metadata for templates
type WebhookSecurityConfig ¶ added in v0.16.0
type WebhookSecurityConfig struct {
// AllowPrivateNetworks allows access to private IP ranges (dangerous!)
AllowPrivateNetworks bool
// AllowLocalhost allows access to localhost (dangerous!)
AllowLocalhost bool
// AllowedHosts whitelist of allowed hosts (if set, only these hosts are allowed)
AllowedHosts []string
// BlockedHosts additional hosts to block
BlockedHosts []string
}
WebhookSecurityConfig holds security configuration for webhooks
func DefaultWebhookSecurityConfig ¶ added in v0.16.0
func DefaultWebhookSecurityConfig() *WebhookSecurityConfig
DefaultWebhookSecurityConfig returns the default security configuration
type WebhookSecurityValidator ¶ added in v0.16.0
type WebhookSecurityValidator struct {
// contains filtered or unexported fields
}
WebhookSecurityValidator validates URLs with configurable security rules
func NewWebhookSecurityValidator ¶ added in v0.16.0
func NewWebhookSecurityValidator(config *WebhookSecurityConfig) *WebhookSecurityValidator
NewWebhookSecurityValidator creates a new security validator
func (*WebhookSecurityValidator) Validate ¶ added in v0.16.0
func (v *WebhookSecurityValidator) Validate(rawURL string) error
Validate checks if a URL is safe to access. The complexity is intentional for comprehensive security validation.