trust

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: BSD-2-Clause Imports: 4 Imported by: 1 module, 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 trust provides the boolean-combinator trust-decision framework for the maintainer-watcher-github-pr. Callers compose leaves with And, Or, and Not to express compound trust policies without modifying the watcher core.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type And

type And []Trust

And succeeds only if every member succeeds. Evaluates ALL members (no short-circuit) to produce a complete audit trail. An empty And returns vacuous success — callers must ensure non-empty slices for security-relevant decisions (startup validation enforces this).

func (And) IsTrusted

func (a And) IsTrusted(ctx context.Context, pr PR) (Result, error)

type Func

type Func func(ctx context.Context, pr PR) (Result, error)

Func adapts a plain function to the Trust interface. Useful for inline trust checks without struct boilerplate.

func (Func) IsTrusted

func (f Func) IsTrusted(ctx context.Context, pr PR) (Result, error)

type Or

type Or []Trust

Or succeeds if any member succeeds. Evaluates ALL members (no short-circuit) to produce a complete audit trail. An empty Or returns vacuous failure — callers must ensure non-empty slices for security-relevant decisions.

func (Or) IsTrusted

func (o Or) IsTrusted(ctx context.Context, pr PR) (Result, error)

type PR

type PR struct {
	AuthorLogin string

	// HeadRepoFullName is the head repository's `owner/repo` full name as
	// GitHub reports it (`pr.head.repo.full_name`). Empty when the head repo
	// is unknown — a deleted fork, or a PR derived from the Search API, which
	// does not carry it.
	HeadRepoFullName string

	// BaseRepoFullName is the base repository's `owner/repo` full name
	// (`pr.base.repo.full_name`). Empty when unknown.
	BaseRepoFullName string
}

PR is the trust-evaluation input derived from a GitHub pull request. Only the fields needed for trust decisions are included.

type Result

type Result interface {
	Success() bool
	Description() string
}

Result captures a trust decision and a human-readable description. The description is the audit trail: why was this PR trusted or denied?

func NewResult

func NewResult(success bool, description string) Result

NewResult constructs a Result with the given outcome and description.

type Trust

type Trust interface {
	IsTrusted(ctx context.Context, pr PR) (Result, error)
}

Trust is the single-method trust-decision interface. Each implementation returns both an outcome (trusted/denied) and a human-readable description forming the audit trail for the decision.

func NewAuthorAllowlist

func NewAuthorAllowlist(members []string) Trust

NewAuthorAllowlist returns a Trust leaf that grants trust by exact GitHub login membership (case-sensitive byte equality).

Fail-safe rules:

  • Empty members list → always denies.
  • PR with empty AuthorLogin → always denies (author unknown).

Operators are responsible for matching GitHub's stored casing.

func NewSameRepo added in v0.16.0

func NewSameRepo() Trust

NewSameRepo returns a Trust leaf that grants trust only when the pull request's head repository is the base repository it targets.

An author login is not an ownership proof: a workflow running in a fork that opens a pull request against upstream renders as the same login (for example `github-actions[bot]`), so trusting that login alone would let a fork pull request be auto-reviewed. Comparing the head and base repository full names closes that hole.

Fail-safe rules:

  • Unknown head repo (empty HeadRepoFullName) → always denies.
  • Unknown base repo (empty BaseRepoFullName) → always denies.
  • Both empty never compares equal: the emptiness checks run first.

The comparison is exact byte equality, matching NewAuthorAllowlist's handling of logins.

func Not

func Not(t Trust) Trust

Not inverts the decision of the wrapped Trust, preserving the description.

Jump to

Keyboard shortcuts

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