Documentation
¶
Overview ¶
Package pipeallow is the operator's allow-list of pipes that may run with permissions on a host that takes runs from other programs (`datatug serve --allow-pipes`, `server.allowPipes` of the user's settings file).
The list says WHAT may run, not which abstract permission is given: an allowed pipe gets exactly the permissions its own manifest declares and nothing more. A pipe that needs a permission and is not on the list does not run. The list is a decision of the person who operates the machine: it is never read from the files of a project.
Index ¶
Constants ¶
const ( // ScopeAll is an entry for every project the host serves: the flag, or // `all` of the settings file. ScopeAll = "all" // ScopeProject is an entry of `projects[]` of the settings file whose // folder is that of the project. ScopeProject = "project" )
The scopes of an entry in the list in force for one project.
const FlagName = "allow-pipes"
FlagName is the flag of `datatug serve` that fills the list.
Variables ¶
This section is empty.
Functions ¶
func RuntimeOf ¶
RuntimeOf is the runtime of a pipe: the language of a script, else the type of its implementation.
func Runtimes ¶
func Runtimes() []string
Runtimes lists the runtimes an entry may name, sorted. They are the script interpreters of the OpenFlange manifest and the two implementation types that leave the process. Everything else (builtins, expressions, Starlark, composites) runs inside the host and needs no entry.
Types ¶
type Config ¶
type Config struct {
All []Entry
Projects []ProjectScope
}
Config is what an operator configured: entries for every project the host serves, and entries for single projects.
func Settings ¶
Settings reads the `server.allowPipes` value of a settings file of the person who operates the host:
allowPipes:
all:
entries: [r, "python:pipes/score/score.py"]
projects:
- path: /home/me/projects/shop
id: shop # optional
entries: ["python:pipes/score"]
Every entry has the syntax of the flag. An error names the file and the line. A key that is not known is an error, so that a mistyped scope never silently allows less or more than was meant.
type Entry ¶
type Entry struct {
// Runtime is the language of a script implementation (`python`, `r`,
// `node`: the interpreters of the OpenFlange manifest) or the
// implementation type `executable` or `http`.
Runtime string
// Path, when set, narrows the entry to one pipe folder or one script
// file, relative to the root of the project, slash-separated and clean.
Path string
// Source says where the entry was given, for people: the flag, or a
// settings file and line.
Source string
// Scope is ScopeAll or ScopeProject in the list in force for a project
// (Config.For); empty in a Config.
Scope string
}
Entry allows the pipes of one runtime, or one pipe or script of it.
type List ¶
type List struct {
Entries []Entry
}
List is the allow-list in force for one project. The zero value allows nothing.
func (*List) Allows ¶
Allows reports whether a pipe may run with the permissions it declares: runtime is its runtime, dir its folder and script its script file (empty when it has none), both relative to the project root. Entries only add: a pipe is allowed when any entry names its runtime, broadly or narrowed to its folder or its script. A pipe outside the project has no dir and is allowed by a broad entry only.
type ProjectScope ¶
type ProjectScope struct {
// Path is the absolute folder of the project. It is compared after
// symbolic links are resolved. A project that moves no longer matches:
// its entries stop applying until the operator updates the path.
Path string
// ID, when set, must be the id of the project as well.
ID string
Entries []Entry
}
ProjectScope holds entries that apply to one project only. The project is named by the folder it lies in, which the operator chose, and optionally by its id as well: the id alone would not do, because a project states its own id and a cloned project could state the id of another.