safeio

package
v0.1.0-proto2b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package safeio centralizes every variable-path file open in gapi. All operator-supplied and discovered paths funnel through here: paths are cleaned and made absolute, and the *Under variants refuse to escape their root. This is the audited chokepoint for path-traversal (CWE-22) concerns; open a file through this package, not os, whenever the path is not a literal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(path string) (*os.File, error)

Create creates or truncates the resolved path.

func Open

func Open(path string) (*os.File, error)

Open opens the resolved path for reading.

func OpenUnder

func OpenUnder(root, path string) (*os.File, error)

OpenUnder opens path for reading after confining it to root.

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the resolved path.

func ReadFileUnder

func ReadFileUnder(root, path string) ([]byte, error)

ReadFileUnder reads path after confining it to root.

func Resolve

func Resolve(path string) (string, error)

Resolve cleans path and makes it absolute against the process working directory. Empty paths are rejected.

func ResolveUnder

func ResolveUnder(root, path string) (string, error)

ResolveUnder resolves path and rejects it unless the result stays at or under root. The check is lexical: symlinks inside an operator-owned root are the operator's to manage.

Types

This section is empty.

Jump to

Keyboard shortcuts

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