policy

package
v0.2.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0, Apache-2.0 Imports: 9 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

Vendored from bot-agent internal/agent/policy (Apache-2.0, see ../NOTICE). DD changes: the key set is a caller-supplied Schema instead of bot-agent's fixed keys, and a scalar basic string is accepted. The value parsers (parseBool, parseInt, parseArray, parseString) are unchanged.

Package policy reads a root-owned host policy file in a small TOML subset.

Vendored from bot-agent internal/agent/policy (Apache-2.0, see ../NOTICE). DD changes: Load keeps bot-agent's file checks (regular file, size cap, root owner, not group- or world-writable, SHA-256 of the bytes) and its parser, but returns the parsed values for a caller-supplied Schema. The bot-agent keys (run_as, dirs, images, projects, shared networks) and the passwd/group resolution are dropped; dd-worker's keys and their meaning live in internal/worker.

Index

Constants

View Source
const MaxBytes = 64 * 1024

MaxBytes bounds a policy file. Larger files are invalid.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Exists bool
	Valid  bool
	Values map[string]Value
	Hash   string
	Reason string
}

File is one read of the policy. When Valid is false, Values is nil and Reason names why. Hash is the hex SHA-256 of the file bytes when they were read.

func Load

func Load(f Files) File

Load reads the policy. A missing file returns a zero File (Exists false). It does not return an error: a missing or invalid policy disables work.

type Files

type Files struct {
	Policy    string
	Schema    Schema
	UID       func(os.FileInfo) (uint32, bool)
	SkipOwner bool
	Data      []byte
}

Files selects the policy file and its schema. UID, when set, replaces the uid from the file's stat. Production leaves it nil. Tests set it because this process cannot chown a file to root. The override does not affect the mode check. SkipOwner skips the root-owner and mode checks (a "policy check" of a file before it is installed). Data, when not nil, is the policy's bytes (a candidate read from stdin): Policy is not opened and the owner and mode checks are skipped.

type Kind

type Kind int

Kind is a key's TOML type in the subset: bool, non-negative int, basic string, or array of basic strings.

const (
	Bool Kind = iota
	Int
	String
	Strings
)

type Schema

type Schema map[string]Kind

Schema is the set of keys a file may hold. Anything else is unknown_key.

type Value

type Value struct {
	Bool    bool
	Int     int
	String  string
	Strings []string
}

Value is one parsed key. Only the field for its Kind is set.

Jump to

Keyboard shortcuts

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