backup

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 4 Imported by: 0

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

func ListBackups(backupDir string) ([]string, error)

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

func ValidateBackupPath(backupDir, userPath string) (string, error)

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.

Jump to

Keyboard shortcuts

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