util

package
v1.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath safely expands ~ to home directory

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) Exists

func (fm *FileManager) Exists(path string) (bool, error)

Exists checks if a path exists

func (*FileManager) IsDir

func (fm *FileManager) IsDir(path string) (bool, error)

IsDir checks if a path is a directory

func (*FileManager) Move

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

Move safely moves a file from src to dst

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