sanitizer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sanitizer provides security-focused sanitization functions to prevent common vulnerabilities like command injection, path traversal, and other security issues.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alphanumeric

func Alphanumeric(input string) string

Alphanumeric removes all non-alphanumeric characters

func CommandArgument

func CommandArgument(arg string) string

CommandArgument sanitizes a single command line argument

func ContainerName

func ContainerName(name string) string

ContainerName sanitizes a Docker container name

func DockerImageName

func DockerImageName(name string) string

DockerImageName sanitizes a Docker image name for use in command execution

func FilePath

func FilePath(path string, allowedBaseDir string) (string, error)

FilePath sanitizes a file path to prevent directory traversal attacks

func Filename

func Filename(filename string) string

Filename sanitizes a filename to prevent path traversal and other issues

func IsSecurityError

func IsSecurityError(err error) bool

IsSecurityError checks if an error is a SecurityError

func Password

func Password(password string) string

Password sanitizes a password string (removes dangerous characters)

func SafeExecArgs

func SafeExecArgs(command string, args []string) (string, []string, error)

SafeExecArgs prepares arguments for exec.Command with validation

func ShellCommand

func ShellCommand(command string) string

ShellCommand sanitizes a shell command for safe execution

func URL

func URL(url string) string

URL sanitizes a URL for HTTP requests

Types

type SecurityError

type SecurityError struct {
	Message string
}

SecurityError represents a security-related error

func (*SecurityError) Error

func (e *SecurityError) Error() string

Jump to

Keyboard shortcuts

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