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 ¶
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 ¶
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 ¶
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.