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 ¶
- func Create(path string) (*os.File, error)
- func Open(path string) (*os.File, error)
- func OpenUnder(root, path string) (*os.File, error)
- func ReadFile(path string) ([]byte, error)
- func ReadFileUnder(root, path string) ([]byte, error)
- func Resolve(path string) (string, error)
- func ResolveUnder(root, path string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFileUnder ¶
ReadFileUnder reads path after confining it to root.
func Resolve ¶
Resolve cleans path and makes it absolute against the process working directory. Empty paths are rejected.
func ResolveUnder ¶
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.