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 ¶
const ( // SourceProfile and SourceDeployment say what bound the person. SourceProfile = "profile" SourceDeployment = "deployment" )
Variables ¶
This section is empty.
Functions ¶
func UnsafeRune ¶
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.
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.
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 ¶
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 ¶
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 ¶
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.