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
- Variables
- type Advisory
- type CheckFinding
- type CheckRequest
- type CheckResult
- type CloseFailedError
- type CloseRequest
- type CloseResult
- type HistoryEntry
- type IntakeRequest
- type IntakeResult
- type LeftOut
- type MintedRecord
- type Package
- type PendingAdvisory
- type PlanEntry
- type PlannedVulnerability
- type PublicationPlan
- type PublishFailedError
- type PublishRequest
- type PublishResult
- type PublishedAdvisory
- type RefusalError
- type State
- type Store
- type TriageRequest
- type TriageResult
Constants ¶
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).
const ( VerdictVulnerability = "vulnerability" VerdictNotAbcds = "not-abcds" VerdictNotAVulnerability = "not-a-vulnerability" VerdictPublicTrack = "public-track" )
The verdicts triage records (spc-2610120557432880, "Verdicts").
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.
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.
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.
const StoreName = storepath.Name
StoreName is the store's folder under the repository's level of the worktree store.
Variables ¶
var ForgeStates = []string{"triage", "draft", "published", "closed"}
ForgeStates are the states GitHub reports a repository advisory in.
var Verdicts = []string{VerdictVulnerability, VerdictNotAbcds, VerdictNotAVulnerability, VerdictPublicTrack}
Verdicts is every verdict triage accepts, in the order the page lists them.
Functions ¶
This section is empty.
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. 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 ¶
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 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 ¶
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"`
}
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). 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 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"`
}
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"`
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"`
}
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"`
}
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 ¶
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.
func (*RefusalError) Error ¶
func (e *RefusalError) Error() string
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 ¶
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 ¶
SaveState validates st and writes it atomically, owner-only. A state that fails validation writes nothing.
func (Store) Verify ¶
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 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.