validate

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package validate provides security validation functions for sensitive data

Package validate provides functions to validate various aspects of the application.

Index

Constants

View Source
const (
	MaxSecretFileSize  = 1024 * 1024 // 1MB - Maximum size for secret files
	MaxEnvValueSize    = 32768       // 32KB - Maximum size for environment variable values
	MaxSecretNameLen   = 253         // DNS name limit - Maximum length for secret names
	MaxEnvKeyLen       = 256         // Maximum length for environment variable keys
	MaxSecretTargetLen = 4096        // Maximum length for secret target paths
)

Security constants for size limits and validation.

Variables

This section is empty.

Functions

func EnvKey added in v0.16.1

func EnvKey(key string) error

EnvKey provides extended validation for environment variable keys.

func ResetCommandRunner

func ResetCommandRunner()

ResetCommandRunner restores the default runner.

func SanitizeForLogging added in v0.16.1

func SanitizeForLogging(key, value string) string

SanitizeForLogging redacts sensitive information from strings for safe logging.

func SetCommandRunner

func SetCommandRunner(runner CommandRunner)

SetCommandRunner allows tests to inject a mock runner.

func SystemRequirements

func SystemRequirements() error

SystemRequirements checks if all required system tools are installed.

Types

type CommandRunner

type CommandRunner interface {
	Run(name string, args ...string) ([]byte, error)
}

CommandRunner defines an interface for executing commands.

type RealCommandRunner

type RealCommandRunner struct{}

RealCommandRunner implements CommandRunner using os/exec.

func (*RealCommandRunner) Run

func (r *RealCommandRunner) Run(name string, args ...string) ([]byte, error)

Run executes a command and returns its output. WARNING: This method executes arbitrary commands and should only be used with trusted input. Callers must validate command names and arguments to prevent command injection.

type SecretValidator added in v0.16.1

type SecretValidator struct {
	// contains filtered or unexported fields
}

SecretValidator provides validation for secrets and sensitive data.

func NewSecretValidator added in v0.16.1

func NewSecretValidator() *SecretValidator

NewSecretValidator creates a new SecretValidator instance.

func (*SecretValidator) ValidateEnvValue added in v0.16.1

func (sv *SecretValidator) ValidateEnvValue(key, value string) error

ValidateEnvValue validates environment variable values for size and content.

func (*SecretValidator) ValidateSecretName added in v0.16.1

func (sv *SecretValidator) ValidateSecretName(name string) error

ValidateSecretName validates that a secret name is safe and follows conventions.

func (*SecretValidator) ValidateSecretTarget added in v0.16.1

func (sv *SecretValidator) ValidateSecretTarget(target string) error

ValidateSecretTarget validates that a secret target path is safe.

func (*SecretValidator) ValidateSecretValue added in v0.16.1

func (sv *SecretValidator) ValidateSecretValue(value string) error

ValidateSecretValue validates that a secret value is safe and within size limits.

Jump to

Keyboard shortcuts

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