Documentation
¶
Overview ¶
Package backup provides path validation helpers for backup operations.
Usage:
absPath, err := backup.ValidateBackupPath(cfg.Backup.Dir, userSuppliedPath)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListBackups ¶
ListBackups returns the names of all regular files in backupDir. The returned slice is empty (not nil) when the directory contains no files. Directories and other non-regular entries are skipped.
func ValidateBackupPath ¶
ValidateBackupPath resolves userPath relative to backupDir and verifies that the resolved absolute path is contained within backupDir. This prevents path traversal attacks (e.g. "../../../etc/passwd").
backupDir is the trusted root directory for backups (e.g. "/var/backups"). userPath is the caller-supplied relative or absolute path.
Returns the resolved absolute path on success, or an error if the path escapes backupDir.
Types ¶
This section is empty.