approve

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package approve records the commands a human has agreed to run.

R2 permits an argv[0] outside the default allowlist -- `bin/dev`, `./scripts/setup.sh` -- because refusing them outright means people fork the project, and because the script is committed, reviewable repository content rather than a model-derived shell string. What makes that safe is the second half of the rule: a human sees the exact argv once and agrees to it.

Until this package existed, devbay printed the approval and ran the command anyway. That is the worst of both designs -- the developer is trained to scroll past a warning, and the rule provides no boundary at all. So the approval now blocks, and because blocking on every single run would be intolerable, it is remembered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(project string, argv []string) string

Key is the identity of an approval: the project and the exact argv.

Hashing the whole array rather than argv[0] is the point of the rule. A developer who approves bin/dev has approved that script, not every future invocation of it with arguments they never saw -- so [bin/dev, --seed-prod] is a different command and asks again.

Types

type Record

type Record struct {
	// Key identifies the approval; see Key.
	Key string
	// Project scopes it. Approving `bin/dev` for one repository must not
	// approve a file of the same name in another, because the thing being
	// approved is that repository's script, not the string.
	Project string
	// At is where in the manifest it appeared, kept for display only -- moving
	// a command from install: to start: does not change what it does.
	At   string
	Argv []string
	// When and By record who took the decision, so an audit answers "who let
	// this run" rather than only "it was allowed".
	When time.Time
	By   string
}

Record is one approved command.

type Store

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

Store is the record of what has been approved.

func Open

func Open(path string) (*Store, error)

Open prepares the store. An empty path uses ~/.devbay/state.db, the same file the rest of devbay's state lives in.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Grant

func (s *Store) Grant(ctx context.Context, r Record) error

Grant records an approval.

func (*Store) Granted

func (s *Store) Granted(ctx context.Context, project string, argv []string) bool

Granted reports whether this exact command has been approved.

func (*Store) List

func (s *Store) List(ctx context.Context, project string) ([]Record, error)

List returns everything approved for a project, oldest first.

func (*Store) Revoke

func (s *Store) Revoke(ctx context.Context, key string) (bool, error)

Revoke removes an approval by key. Withdrawing is as necessary as granting: an approval that cannot be taken back is a decision a developer will avoid making.

Jump to

Keyboard shortcuts

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