policyref

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package policyref holds the contact a governance profile (or the site's policy_help) publishes to the people it refuses, and the one validator for it.

The fields are later written into HTTP headers a sandbox reads, so a value is checked twice: Validate on every write, and Project on every read, which drops field by field whatever no longer passes (a row written by an older binary or straight into the database, or a rule that tightened since). A stored value is never trusted. Leaf package: the standard library and internal/hostrules only.

Index

Constants

View Source
const (

	// SourceProfile and SourceDeployment say what bound the person.
	SourceProfile    = "profile"
	SourceDeployment = "deployment"
)

Variables

This section is empty.

Functions

func UnsafeRune

func UnsafeRune(r rune) bool

UnsafeRune is what no free-text or header-bound field may carry: C0/C1 controls (line breaks included), and the invisible Unicode that can make text read differently from what it is, namely format characters (bidi overrides, zero-width spaces) and the line/paragraph separators.

func Validate

func Validate(c Contact) error

Validate refuses the first field that does not pass. A zero Contact is valid.

Types

type Contact

type Contact struct {
	Owner       string `json:"owner,omitempty"`
	Email       string `json:"email,omitempty"`
	RequestURL  string `json:"request_url,omitempty"`
	RequestText string `json:"request_text,omitempty"`
}

Contact is what an admin writes: who owns a policy and how to ask for a change. Every field is optional.

func (Contact) Fields

func (c Contact) Fields() []string

Fields lists, in a fixed order, the names of the fields that are set. The audit log records this instead of the values.

func (Contact) IsZero

func (c Contact) IsZero() bool

IsZero reports whether every field is empty.

type Ref

type Ref struct {
	Source      string `json:"source"`
	Name        string `json:"name,omitempty"`
	Owner       string `json:"owner,omitempty"`
	Email       string `json:"email,omitempty"`
	RequestURL  string `json:"request_url,omitempty"`
	RequestText string `json:"request_text,omitempty"`
	// Overridden says the person changed the policy for this run (the New Run
	// cards), inside what their ceiling allows. A refusal then names the policy
	// as changed, so the person is not sent to the owner of a policy they edited.
	Overridden bool `json:"overridden,omitempty"`
}

Ref is the one shape every surface serves: the policy that bound the person plus its contact, and nothing else about the profile.

func Project

func Project(source, name string, c *Contact) *Ref

Project is the read-side re-validation: it keeps each field of c that still passes and drops the rest, so one bad field never costs the good ones. It returns nil for a source that is neither profile nor deployment. name is kept for a profile only, and a nil contact yields a Ref that names the policy alone.

func (Ref) HeaderValues

func (r Ref) HeaderValues() (policy, request string)

HeaderValues returns the ASCII values of X-Wardyn-Policy and X-Wardyn-Policy-Request; request is "" when there is no route and the header should be left off. A profile name may be any printable Unicode, so it travels percent-encoded.

func (Ref) RequestRoute

func (r Ref) RequestRoute() string

RequestRoute is the one place the request route is chosen: request_url, else "mailto:" + email, else "". Both candidates are checked again here, so a Ref assembled by hand never yields a route the write rules would have refused.

Jump to

Keyboard shortcuts

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