Documentation
¶
Overview ¶
Package receivefs validates untrusted receive paths and provides filesystem operations rooted at a directory handle.
Index ¶
- Variables
- func CollisionKey(name string) string
- func ForbiddenComponent(component string) bool
- func Normalize(name string, allowRoot bool) (string, error)
- type Entry
- type Kind
- type Root
- func (r *Root) Chtimes(name string, atime, mtime time.Time) error
- func (r *Root) Close() error
- func (r *Root) CreateTemp(dir, prefix string, perm fs.FileMode) (*os.File, string, error)
- func (r *Root) CreateTempDir(dir, prefix string) (string, error)
- func (r *Root) Lstat(name string) (fs.FileInfo, error)
- func (r *Root) MkdirAll(name string, perm fs.FileMode) error
- func (r *Root) Name() string
- func (r *Root) Open(name string) (*os.File, error)
- func (r *Root) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
- func (r *Root) RejectSymlinkPath(name string) error
- func (r *Root) Remove(name string) error
- func (r *Root) RemoveAll(name string) error
- func (r *Root) Rename(oldName, newName string) error
- func (r *Root) Stat(name string) (fs.FileInfo, error)
- func (r *Root) Symlink(target, name string) error
- func (r *Root) WriteFileAtomic(name string, data []byte, perm fs.FileMode) error
Constants ¶
This section is empty.
Variables ¶
var ErrPathCollision = errors.New("receive path collision")
ErrPathCollision marks destinations that are ambiguous on a supported filesystem or conflict as file and directory paths.
var ErrSensitivePath = errors.New("sensitive receive path")
ErrSensitivePath marks a path containing a component that receivers must never create from untrusted transfer metadata.
var ErrUnsafePath = errors.New("unsafe receive path")
ErrUnsafePath marks a path that is not safe to create portably.
Functions ¶
func CollisionKey ¶
CollisionKey returns the portable comparison form used for duplicate detection on case-insensitive and normalization-insensitive filesystems.
func ForbiddenComponent ¶
ForbiddenComponent reports whether a normalized path component names a sensitive receiver-owned directory. Matching uses the same portable Unicode collision key as manifest duplicate detection.
Types ¶
type Entry ¶
Entry is an untrusted destination path and its intended type.
func ValidateEntries ¶
ValidateEntries normalizes a complete untrusted manifest and rejects exact, case-folded, normalization-equivalent, and file/directory collisions.
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root performs receive operations relative to one opened destination root. os.Root keeps operations contained even when path components are replaced concurrently.
func (*Root) CreateTemp ¶
CreateTemp creates an exclusive random file below dir and returns its root-relative slash path.
func (*Root) CreateTempDir ¶
CreateTempDir creates an exclusive private directory below dir and returns its root-relative slash path.
func (*Root) RejectSymlinkPath ¶
RejectSymlinkPath preserves croc's refusal of existing symlink components. The subsequent os.Root operation supplies containment if a component changes after this inspection.