embargo

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 38 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

Package embargo keeps private security advisories private until they are published (itd-2610112239022766, spc-2610120557432880). Its records live in the embargo store, a worktree in the machine-scoped worktree store that is created detached and never committed, and every sub-verb verifies the store before it reads or writes anything (adr-2610120558328615, decisions 1 and 2). This file is the store; state.go is its state file.

Index

Constants

View Source
const (
	KindAdvisoryID         = "advisory_id"          // an unpublished advisory's GHSA id
	KindReservedCVE        = "reserved_cve_id"      // a CVE id reserved for one
	KindAdvisoryTitle      = "advisory_title"       // its title, unless it was moved to the public track
	KindStorePath          = "store_path"           // where the private records live
	KindUnlistedAdvisoryID = "unlisted_advisory_id" // an advisory id the store does not hold, not --allow'ed
	KindEmbargoedRecord    = "embargoed_record"     // a record the store holds for an advisory not yet published
)

The kinds of finding the outbound check reports (adr-2610120558328615, decision 3).

View Source
const (
	VerdictVulnerability     = "vulnerability"
	VerdictNotAbcds          = "not-abcds"
	VerdictNotAVulnerability = "not-a-vulnerability"
	VerdictPublicTrack       = "public-track"
)

The verdicts triage records (spc-2610120557432880, "Verdicts").

View Source
const DraftDirRel = ".abcd/.work.local/embargo/close"

DraftDirRel is where triage keeps each closing draft inside the store, slash-separated: the local tier, beside the state, one file per advisory.

View Source
const SchemaVersion = 2

SchemaVersion is the state shape this package writes. Schema 1, which had no pending list, is still read (loadState), as a state with nothing pending.

View Source
const StateRel = ".abcd/.work.local/embargo/state.json"

StateRel is the state file's path inside the store, slash-separated. It sits in the local tier, which every worktree of an abcd repository ignores, so the link from an advisory to its record is never one `git add` away.

View Source
const StoreName = storepath.Name

StoreName is the store's folder under the repository's level of the worktree store.

Variables

View Source
var ForgeStates = []string{"triage", "draft", "published", "closed"}

ForgeStates are the states GitHub reports a repository advisory in.

Verdicts is every verdict triage accepts, in the order the page lists them.

Functions

func AnnouncementCheck added in v0.16.0

func AnnouncementCheck(root, home, text string, records []string) (bool, error)

AnnouncementCheck is the embargo check an announcement is held to (itd-2609151838312703 C5), in the shape claim.EmbargoCheck takes: `abcd embargo check` on the announcement's whole message and the record it names. Any finding holds it, and a check that cannot run is an error, which refuses it too. `abcd announce` and the announcements abcd's own pushes make (`abcd land`, a build or drain lane's landing) all pass through it, so no announcement is judged by a second copy of the check.

func SwapOriginRepoForTest added in v0.16.0

func SwapOriginRepoForTest(fn func(top string) (string, error)) (restore func())

SwapOriginRepoForTest substitutes how a plan reads the repository origin names, and returns the restore: a test binary's git reaches no network, so a fixture stands origin in with a local repository, which names none. It is exported because the surface's tests live in another package. Tests only; never called in production code, and never safe to call from a parallel test.

Types

type Advisory

type Advisory struct {
	GHSAID      string         `json:"ghsa_id"`
	IssueID     string         `json:"issue_id"`
	Title       string         `json:"title"`
	CVEID       *string        `json:"cve_id"`
	Severity    string         `json:"severity"`
	ForgeState  string         `json:"forge_state"`
	Verdict     *string        `json:"verdict"`
	DecidedBy   *string        `json:"decided_by"`
	DecidedAt   *time.Time     `json:"decided_at"`
	Reason      *string        `json:"reason"`
	ClosedAt    *time.Time     `json:"closed_at"`
	PublishedAt *time.Time     `json:"published_at"`
	History     []HistoryEntry `json:"history,omitempty"`
}

Advisory is one advisory the store holds. A nullable field is a pointer, so "not yet" is written as null and never as an empty string a reader could mistake for a value.

type CheckFinding

type CheckFinding struct {
	Kind    string `json:"kind"`
	Source  string `json:"source"`
	Where   string `json:"where,omitempty"`
	Line    int    `json:"line"`
	Snippet string `json:"snippet"`
}

CheckFinding is one place the check refuses. It names where the match is (Source, Where, Line) and never repeats it: Snippet is the line with every matched span starred out, whole, the way the scanner masks an identifier.

type CheckRequest

type CheckRequest struct {
	Home     string
	RepoRoot string
	Range    string
	Files    []string
	Stdin    io.Reader
	Allow    []string
	Records  []string
	Now      func() time.Time
}

CheckRequest is one outbound check. Range is a commit range `<a>..<b>` whose messages and added lines are read; each of Files is a path, or "-" for Stdin. Allow names advisory ids of other projects, already public, that may appear. Records are record ids a caller is about to name in public (an announcement's item, itd-2609151838312703 C5): each the store holds for an advisory not yet published is refused. Now is the clock; nil is the system clock.

type CheckResult

type CheckResult struct {
	NoStore      bool           `json:"no_store"`
	Note         string         `json:"note,omitempty"`
	UnderEmbargo int            `json:"under_embargo"`
	IntakeAt     *time.Time     `json:"intake_at"`
	IntakeStale  bool           `json:"intake_stale"`
	Commits      int            `json:"commits"`
	Files        int            `json:"files"`
	Allowed      []string       `json:"allowed"`
	Findings     []CheckFinding `json:"findings"`
}

CheckResult is what the check read and found. UnderEmbargo counts the ids under embargo, each once however many stores hold it; IntakeAt is the oldest intake of the stores read, nil when one has had none; IntakeStale warns that it is more than a day old, so a report made since is not yet in the set. The result never carries a store's location.

func Check

func Check(req CheckRequest) (CheckResult, error)

Check is the outbound embargo check. It reads the commit range and the files, and reports every unpublished advisory's id, its reserved CVE id, its title (unless the advisory was moved to the public track, which is fixed in the open) and the store's location, plus any advisory id the store does not hold that --allow does not name and GitHub does not list among this repository's published advisories (publishedOnGitHub, asked only when the inputs name such an id). Inputs are read before the store, so a refusal to read one is the same with or without a store.

The deny set is the union of every store under this home (storepath.Reachable): this checkout's own, verified as every sub-verb verifies it, and whatever else sits at worktrees/<key>/embargo there, whatever repository it belongs to and whether or not git still lists it, read and never written (readOtherStore): a store whose checkout was deleted keeps its records under embargo, and a folder with no state file holds nothing. The Note counts the stores read with no live registration, naming none. No root commit decides which stores are read, so a shallow clone or rewritten history reads the same stores. A place that cannot be examined, a state file that cannot be read or is of the wrong shape, and a store this repository registered under another home refuse the check. Only with no store of its own and nothing at any place under this home is nothing under embargo, and the check passes saying so. A store under another home that this repository never registered is not read.

func (CheckResult) Clean

func (r CheckResult) Clean() bool

Clean reports a check with nothing to refuse.

type CloseFailedError

type CloseFailedError struct {
	StateHeld bool
	TextHeld  bool
	Reason    string
}

CloseFailedError is a close GitHub accepted but whose read-back does not confirm it: the advisory is not closed, or its description does not carry the approved text where it was placed. closed_at is not recorded.

func (*CloseFailedError) Error

func (e *CloseFailedError) Error() string

type CloseRequest

type CloseRequest struct {
	Home     string
	RepoRoot string
	Target   string
	Approve  string
	Now      func() time.Time
}

CloseRequest closes one advisory on GitHub with the explanation its closing verdict drafted. Without Approve it only shows the text and its digest; with Approve equal to that digest it closes the advisory. A host passes Approve only after the person, in that session, has seen the text and said yes to it (adr-2610120558328615, decision 4). Now is the clock; nil is the system clock.

type CloseResult

type CloseResult struct {
	GHSAID      string     `json:"ghsa_id"`
	IssueID     string     `json:"issue_id"`
	Verdict     string     `json:"verdict"`
	ForgeState  string     `json:"forge_state"`
	Text        string     `json:"text"`
	Digest      string     `json:"digest"`
	ApproveWith string     `json:"approve_with"`
	Closed      bool       `json:"closed"`
	ClosedAt    *time.Time `json:"closed_at,omitempty"`
	Reconciled  bool       `json:"reconciled,omitempty"`
	TextHeld    *bool      `json:"text_held,omitempty"`
}

CloseResult is what a close showed and did. Text is exactly the explanation that is posted, Digest the approval it takes, and ApproveWith the command that gives it. Closed and ClosedAt report a close GitHub confirmed. Reconciled reports that GitHub already held the advisory closed, so nothing was sent and closed_at was recorded from that; TextHeld then says whether its description begins with the drafted text.

func Close

func Close(req CloseRequest) (CloseResult, error)

Close shows, and on approval posts, the closing explanation of an advisory whose verdict is not-abcds or not-a-vulnerability and which is neither closed nor published. Without approval the only request is one read of the advisory. With it, the draft and the advisory are read again and the digest recomputed; any difference refuses with nothing sent. On a match one PATCH sets the advisory closed with the composed description, and a read-back must show it closed with the approved text in place before closed_at is stamped. An advisory GitHub already reports closed or published is not updated: its closed_at or published_at is recorded from what GitHub reports, so a close whose read-back or save failed is completed by running close again.

The text is scanned before it is shown, with the outbound scanner, the private-names layer, and every other advisory still under embargo: the advisory stays private after closing, but its reporter reads the text.

type ForgeEnd added in v0.16.0

type ForgeEnd struct {
	GHSAID  string    `json:"ghsa_id"`
	IssueID string    `json:"issue_id"`
	State   string    `json:"state"`
	At      time.Time `json:"at"`
}

ForgeEnd is a held advisory GitHub reports published or closed, as the store now records it: State is "published" or "closed", At its published_at or closed_at.

type HistoryEntry

type HistoryEntry struct {
	Verdict   string    `json:"verdict"`
	DecidedBy string    `json:"decided_by"`
	DecidedAt time.Time `json:"decided_at"`
	Reason    string    `json:"reason,omitempty"`
}

HistoryEntry is a verdict a later triage replaced: triage appends rather than overwrites, so who decided what, and when, is never lost.

type IntakeRequest

type IntakeRequest struct {
	Home     string
	RepoRoot string
	Now      func() time.Time
}

IntakeRequest asks for one intake of the repository at RepoRoot, with the store under Home. Now is the clock; nil is the system clock.

type IntakeResult

type IntakeResult struct {
	Store         string         `json:"store"`
	StoreCreated  bool           `json:"store_created"`
	Repo          string         `json:"repo"`
	IntakeAt      time.Time      `json:"intake_at"`
	Minted        []MintedRecord `json:"minted"`
	Held          []string       `json:"held"`
	NeedsSeverity []string       `json:"needs_severity"`
	// Ended lists each held advisory GitHub no longer lists in triage or
	// draft and reports published or closed, as now recorded; Unread each
	// one whose end was not recorded, left as the store holds it, and why.
	Ended  []ForgeEnd       `json:"ended"`
	Unread []UnreadAdvisory `json:"unread"`
	// Restores is each restore the store's state owes (restoresOwed).
	Restores []Restore `json:"restores"`
}

IntakeResult is what an intake did. Held lists the advisories the store already held (refreshed, never recorded twice); NeedsSeverity lists those GitHub gives no severity this abcd maps, for the person to set on GitHub: they get no record, and the state holds them as pending, under embargo.

func Intake

func Intake(req IntakeRequest) (IntakeResult, error)

Intake lists the repository's advisories in the triage and draft states through the person's own gh and mints one private record per advisory the store does not yet hold, in the store's own ledger and never in the checkout's (adr-2610120558328615, decision 1). Each held advisory the listing no longer names is read on its own, and an end GitHub reports for it (published or closed, by any hand) is recorded (readHeld). The listing is judged whole before anything is written: an advisory whose id, state or CVE id this abcd does not recognise refuses the intake with nothing recorded.

type LeftOut

type LeftOut struct {
	GHSAID  string `json:"ghsa_id"`
	IssueID string `json:"issue_id"`
	Reason  string `json:"reason"`
}

LeftOut is an advisory judged a vulnerability that the plan does not publish, and why.

type MintedRecord

type MintedRecord struct {
	GHSAID   string `json:"ghsa_id"`
	IssueID  string `json:"issue_id"`
	Severity string `json:"severity"`
}

MintedRecord is one private record an intake made.

type Package

type Package struct {
	Ecosystem string `json:"ecosystem"`
	Name      string `json:"name"`
}

Package is an advisory's affected package, as GitHub names it.

type PendingAdvisory

type PendingAdvisory struct {
	GHSAID     string  `json:"ghsa_id"`
	Title      string  `json:"title"`
	CVEID      *string `json:"cve_id"`
	ForgeState string  `json:"forge_state"`
}

PendingAdvisory is an advisory held without a record until GitHub gives it a severity: what the deny set needs of it, and no more.

type PlanEntry

type PlanEntry struct {
	GHSAID          string                 `json:"ghsa_id"`
	IssueID         string                 `json:"issue_id"`
	FixCommit       string                 `json:"fix_commit"`
	FirstTag        string                 `json:"first_tag"`
	PatchedVersion  string                 `json:"patched_version"`
	ForgeState      string                 `json:"forge_state"`
	Vulnerabilities []PlannedVulnerability `json:"vulnerabilities"`
	TextDigest      string                 `json:"text_digest"`
	// StoreEvidence marks an entry whose fix commit is taken from its
	// private record, resolved in the store's own ledger, because the
	// release carries no public record of it. It is omitted when false, so a
	// public-record entry, and the digest over it, is what it always was.
	StoreEvidence bool `json:"store_evidence,omitempty"`
}

PlanEntry is one advisory the plan publishes: its record, the commit that fixed it, the first release tag holding that commit, the patched version it gives, and each affected package's versions. ForgeState is the state GitHub reported; TextDigest binds the advisory's text as read.

type PlannedVulnerability

type PlannedVulnerability struct {
	Package                Package  `json:"package"`
	VulnerableVersionRange string   `json:"vulnerable_version_range"`
	PatchedVersions        string   `json:"patched_versions"`
	VulnerableFunctions    []string `json:"vulnerable_functions"`
}

PlannedVulnerability is one affected package as the plan will set it, in the shape GitHub's update takes.

type PublicationPlan

type PublicationPlan struct {
	Repo    string      `json:"repo"`
	Release string      `json:"release"`
	Entries []PlanEntry `json:"entries"`
	LeftOut []LeftOut   `json:"left_out"`
	// Unread is each held advisory whose end was not recorded, left as the
	// store holds it, and why (readHeld).
	Unread []UnreadAdvisory `json:"unread"`
	// Ended is each held advisory this plan found published or closed on
	// GitHub and recorded so (readHeld): a plan changes the store's state
	// only so, and says so. It is not bound into the digest.
	Ended []ForgeEnd `json:"ended"`
	// Restores is each restore the store's state owes (restoresOwed): it is
	// not bound into the digest, since approving a plan approves what it
	// publishes.
	Restores    []Restore `json:"restores"`
	Digest      string    `json:"digest"`
	ApproveWith string    `json:"approve_with"`
}

PublicationPlan is what publication would do. Digest is the approval it takes, and ApproveWith the command that gives it (empty when nothing is planned).

type PublishFailedError

type PublishFailedError struct {
	GHSAID      string   `json:"ghsa_id,omitempty"`
	Canary      bool     `json:"canary"`
	Reason      string   `json:"reason"`
	Published   []string `json:"published"`
	Unpublished []string `json:"unpublished"`
	// contains filtered or unexported fields
}

PublishFailedError is a publication that stopped: at advisory GHSAID (the canary when Canary), or, with GHSAID empty, at the final check that none is left in draft. Published and Unpublished say where each planned advisory stands; nothing was sent after the failure.

func (*PublishFailedError) Error

func (e *PublishFailedError) Error() string

type PublishRequest

type PublishRequest struct {
	Home     string
	RepoRoot string
	Release  string
	Approve  string
	Now      func() time.Time
}

PublishRequest asks for the publication plan of the release tag Release (empty: the highest vMAJOR.MINOR.PATCH tag) and, with Approve equal to the plan's digest, for its publication. A host passes Approve only after the person, in that session, has seen the plan and said yes to it (adr-2610120558328615, decision 4). Now is the clock; nil is the system clock.

type PublishResult

type PublishResult struct {
	Plan        PublicationPlan     `json:"plan"`
	Approved    bool                `json:"approved"`
	Published   []PublishedAdvisory `json:"published"`
	NoDraftLeft bool                `json:"no_draft_left"`
	// Restores, after a publication, is each restore the store's state then
	// owes (restoresOwed), those of the advisories just published included.
	Restores []Restore `json:"restores"`
}

PublishResult is what a publish showed and did: the plan, and with an approval, each advisory published in order and whether GitHub then lists none of them in draft or triage.

func Publish

func Publish(req PublishRequest) (PublishResult, error)

Publish shows the publication plan and, with Approve equal to the digest of the plan as it stands now, publishes it. Without approval the only requests are reads. With it, the plan is rebuilt and a digest that does not match refuses with nothing sent. Then, in id order, each advisory is published the same way, the first as the canary: one update sets its versions (accepting it to draft when it is still in triage), a read must show them, a second update publishes it, and a read must show it published with them; published_at is stamped at once. Any failure stops the run before the next update and says which advisories are published. Last, the draft and triage listings must name none of the planned ones.

type PublishedAdvisory

type PublishedAdvisory struct {
	GHSAID      string    `json:"ghsa_id"`
	IssueID     string    `json:"issue_id"`
	PublishedAt time.Time `json:"published_at"`
}

PublishedAdvisory is one advisory GitHub confirmed published, and when abcd recorded it.

type RefusalError

type RefusalError struct {
	Reason string
	Remedy string
	Store  string
}

RefusalError is a refusal with nothing written: the reason, and the one thing the person can do about it. The surfaces exit 2 on it. Store is the store whose reading refused, when one did; the message never names it, and a caller acting for another verb may.

func (*RefusalError) Error

func (e *RefusalError) Error() string

type Restore added in v0.16.0

type Restore struct {
	GHSAID      string `json:"ghsa_id"`
	IssueID     string `json:"issue_id"`
	RestoreWith string `json:"restore_with,omitempty"`
	Reason      string `json:"reason,omitempty"`
}

Restore is an advisory published on GitHub whose private record is resolved in the store and not yet in the checkout's public ledger: RestoreWith is the command, run from the checkout's root, that copies the record there; when it is empty, Reason says why none is named.

type State

type State struct {
	SchemaVersion int        `json:"schema_version"`
	Repo          string     `json:"repo"`
	IntakeAt      *time.Time `json:"intake_at"`
	Advisories    []Advisory `json:"advisories"`
	// Pending are the advisories the last intake listed with no severity
	// this abcd maps: no record is minted for them, but they are under
	// embargo all the same, so the outbound check refuses them.
	Pending []PendingAdvisory `json:"pending"`
}

State is the store's record of every advisory it holds. The link from an advisory to its private record lives here and not in the record, so the record a fix lands with carries one thing fewer to redact.

type Store

type Store struct {
	Root     string `json:"root"`
	Checkout string `json:"checkout"`
}

Store is the embargo store of one repository: Root is the store worktree, Checkout the working-tree root of the checkout it belongs to.

func (Store) SaveState

func (s Store) SaveState(st State) error

SaveState validates st and writes it atomically, owner-only. A state that fails validation writes nothing.

func (Store) StatePath

func (s Store) StatePath() string

StatePath is the state file's absolute path.

func (Store) Verify

func (s Store) Verify() (State, error)

Verify is the check every sub-verb runs before it reads or writes the store, and returns the store's state. It refuses, writing nothing, when the store is not a real directory that is this repository's own worktree; when it resolves inside the checkout; when its HEAD is on a branch; when its state file is refused (state.go); or when its index tracks anything in its local tier, or a record the state names; or when another account could read its folder or a record the state names. A refusal never names a record's file or an advisory.

type TriageRequest

type TriageRequest struct {
	Home          string
	RepoRoot      string
	Target        string
	Verdict       string
	By            string
	Reason        string
	ExistsWithout string
	CannotHelp    string
	Now           func() time.Time
}

TriageRequest records one verdict on one advisory the store holds. Target is the private record's iss-N or the advisory's GHSA id. By names who decided (free text: the store is private). Reason is the why of not-a-vulnerability and public-track, optional for vulnerability; not-abcds takes ExistsWithout and CannotHelp instead, the two halves of abcd-fixes-what-it-adds. Now is the clock; nil is the system clock. The decision time is never typed.

type TriageResult

type TriageResult struct {
	GHSAID         string    `json:"ghsa_id"`
	IssueID        string    `json:"issue_id"`
	Verdict        string    `json:"verdict"`
	DecidedBy      string    `json:"decided_by"`
	DecidedAt      time.Time `json:"decided_at"`
	Reason         string    `json:"reason,omitempty"`
	RecordStatus   string    `json:"record_status"`
	Draft          string    `json:"draft,omitempty"`
	DraftPath      string    `json:"draft_path,omitempty"`
	CaptureCommand string    `json:"capture_command,omitempty"`
}

TriageResult is the verdict recorded. Draft is the closing text drafted for a closing verdict, as written to DraftPath; CaptureCommand is the command a public-track verdict hands the person to run in the public checkout.

func Triage

func Triage(req TriageRequest) (TriageResult, error)

Triage records a verdict on one advisory the store holds, with who decided it and when (from the clock). A second verdict replaces the first and keeps it in the entry's history. A verdict that ends the private track (not-abcds, not-a-vulnerability, public-track) moves the private record to wontfix/ in the store through the ledger's own code; the two closing verdicts draft the explanation `abcd embargo close` posts on approval, and public-track hands back the capture command for the public checkout.

Every refusal writes nothing: the request is judged before the store is opened, and the store's facts before anything in it changes.

type UnreadAdvisory added in v0.16.0

type UnreadAdvisory struct {
	GHSAID  string `json:"ghsa_id"`
	IssueID string `json:"issue_id"`
	Reason  string `json:"reason"`
}

UnreadAdvisory is a held advisory whose end on GitHub was not recorded, left as the store holds it, under embargo, and why: its state could not be told, or GitHub reports a close the store's verdict does not make (closedUnjudged).

Directories

Path Synopsis
Package storepath names where a repository's embargo store lives (adr-2610120558328615).
Package storepath names where a repository's embargo store lives (adr-2610120558328615).

Jump to

Keyboard shortcuts

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