pipeallow

package
v0.162.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 7 Imported by: ? 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 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

View Source
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.

View Source
const FlagName = "allow-pipes"

FlagName is the flag of `datatug serve` that fills the list.

Variables

This section is empty.

Functions

func RuntimeOf

func RuntimeOf(implementationType, language string) string

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.

func Suggest

func Suggest(runtime, dir string) string

Suggest is the narrowest entry that would allow a pipe.

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

func Settings(node *yaml.Node, file string) (Config, error)

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.

func (Config) Describe

func (c Config) Describe(served map[string]string) []string

Describe lists every entry with its scope and its source, one per line, for the person who starts the host. served maps the id of each served project to its folder: a project scope that matches none of them is said to apply to nothing.

func (Config) For

func (c Config) For(id, dir string) *List

For is the list in force for the project id that lies in dir: the entries for all projects, then its own. It is never nil.

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.

func Parse

func Parse(value, source string) ([]Entry, error)

Parse reads one value of the flag or of a settings list: entries separated by commas, each `<runtime>` or `<runtime>:<path>`. source is recorded on every entry.

func (Entry) String

func (e Entry) String() string

String is the entry in the syntax it is given in.

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

func (l *List) Allows(runtime, dir, script string) bool

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.

func (*List) Strings

func (l *List) Strings() []string

Strings lists the entries in their syntax.

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.

Jump to

Keyboard shortcuts

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