filescope

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filescope bounds where the file nodes may read and write.

Node-RED's file nodes take any path at all, which means "can edit a flow" implies "can read anything the process can read and write anything it can write". On a Pi in a workshop that is fine. In an App Store app on a customer's plant floor, where the editor is reachable by anyone with a dashboard login, it is a way to read a mounted Secret.

So the file nodes are scoped. The default scope is the data directory — the PVC, where a flow's own files live and where they almost always belong — and an operator adds more roots deliberately. This is enabled rather than disabled by default, unlike the exec node: reading and writing files under your own PVC is the ordinary use, whereas running a command never is.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrOutOfScope

type ErrOutOfScope struct {
	Path  string
	Roots []string
}

ErrOutOfScope is returned for a path outside every allowed root.

func (*ErrOutOfScope) Error

func (e *ErrOutOfScope) Error() string

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope is the set of directory trees the file nodes may touch.

func NewScope

func NewScope(dataDir string, extra []string) (*Scope, error)

NewScope builds a scope. dataDir is always included, because refusing a flow access to its own PVC would make the nodes useless out of the box and every operator would widen the scope to everything just to get started — which is worse than having no scope at all, because it would look deliberate.

func (*Scope) Check

func (s *Scope) Check(path string) (string, error)

Check resolves a path and reports whether it is inside the scope, returning the cleaned absolute path to use.

Symlinks are followed as far as the path exists, which is what closes the obvious hole: a flow writing a file under the PVC, symlinking it at /data/escape -> /, and then reading /data/escape/etc/shadow. Resolving only the textual path would let that through, because /data/escape/etc/shadow starts with /data.

func (*Scope) Roots

func (s *Scope) Roots() []string

Roots lists the allowed trees, for the error message and for the boot log.

Jump to

Keyboard shortcuts

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