fileutils

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fileutils provides file operation utilities including atomic writes.

Package fileutils provides file operation utilities including atomic writes and path validation for security.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteFile

func AtomicWriteFile(targetPath string, data []byte, perm os.FileMode) error

AtomicWriteFile writes data to a file atomically by writing to a temporary file and then renaming it. This ensures that readers either see the complete old file or the complete new file, never a partially written file.

func ValidateWorkloadNameForPath

func ValidateWorkloadNameForPath(workloadName string) error

ValidateWorkloadNameForPath validates a workload name to prevent path traversal attacks. It ensures the name is safe for use in file path construction by checking: - Path traversal patterns (..) - Absolute paths - Path separators (/, \) - Command injection patterns - Null bytes - Invalid characters (only alphanumeric, dots, hyphens, underscores allowed) - Length limits

This function delegates to types.ValidateWorkloadName which performs comprehensive validation including filepath.Clean normalization and filepath.Rel path traversal checks.

Returns nil if the workload name is safe for path construction, or an error describing the validation failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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