util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanText

func CleanText(text string) string

CleanText removes extra whitespace and cleans up text

func DebugLogf

func DebugLogf(format string, args ...interface{})

DebugLogf logs a debug message only if DEBUG environment variable is enabled

func DebugPrintf

func DebugPrintf(format string, args ...interface{})

DebugPrintf prints a debug message only if DEBUG environment variable is enabled

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath safely expands ~ to home directory

func ExtractSlugFromURL

func ExtractSlugFromURL(urlStr string) string

ExtractSlugFromURL extracts a slug from a URL path

func GenerateSlug

func GenerateSlug(text string) string

GenerateSlug converts text to a URL-friendly slug

func GetFloat32

func GetFloat32(m map[string]interface{}, key string) float32

GetFloat32 safely extracts a float32 value from a map

func GetInt

func GetInt(m map[string]interface{}, key string) int

GetInt safely extracts an integer value from a map

func GetString

func GetString(m map[string]interface{}, key string) string

GetString safely extracts a string value from a map

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled returns true if DEBUG environment variable is set to true, 1, or yes (case-insensitive)

func SecureCommand

func SecureCommand(name string, args ...string) (*exec.Cmd, error)

SecureCommand creates a secure exec.Cmd with validated arguments

func SecureJoin

func SecureJoin(base string, elem ...string) (string, error)

SecureJoin safely joins path components and validates the result

func ValidateBranch

func ValidateBranch(branch string) error

ValidateBranch validates git branch names

func ValidatePath

func ValidatePath(path string) error

ValidatePath checks for path traversal attacks and validates path format

func ValidateRepository

func ValidateRepository(repo string) error

ValidateRepository validates repository names to prevent injection

func ValidateScriptPath

func ValidateScriptPath(scriptPath string) error

ValidateScriptPath validates that script paths are in allowed directories

Types

type FileManager

type FileManager struct{}

FileManager provides secure file operations

func NewFileManager

func NewFileManager() *FileManager

NewFileManager creates a new FileManager instance

func (*FileManager) Copy

func (fm *FileManager) Copy(src, dst string) error

Copy safely copies a file from src to dst with validation

func (*FileManager) Remove

func (fm *FileManager) Remove(path string) error

Remove safely removes a file or directory

Jump to

Keyboard shortcuts

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