Documentation
¶
Overview ¶
Package candidate defines the stage envelopes: Chunk, which carries content from source through decode to detect, and Candidate, which detect hands on toward verify with a Finding, its secret.Secret key material and the precomputed suppression context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
Finding model.Finding `json:"finding"`
Key secret.Secret `json:"key"`
Parts []Part `json:"parts,omitempty"`
Unpaired bool `json:"unpaired,omitempty"`
Ctx SuppressCtx `json:"ctx"`
}
Candidate is what detect hands on toward verify: the Finding detect owns so far, the key material sealed in a secret.Secret, and the raw-key predicates that only detect can compute but only suppress decides on. It is internal and never part of the public API; verify drops Key when it turns a Candidate into a Finding.
For a multi-part credential, Key is the primary part and Parts holds every part in the registry's declared order (nil for a single-part key). Unpaired marks a primary part found without its partners: verify reports it not-verified/unpaired.
type Chunk ¶
Chunk is the stage envelope from source through decode to detect: one readable unit of content and the Location it came from (Line and Column unset; detect sets them per match on a copy). Data is content and must never be printed, logged or put into a warning, so every print, log and marshal method shows only the path and size.
Origin is nil for a chunk a source read. A chunk decode produced from another one carries its Origin, which maps every byte of Data back to the source chunk, so detect can report where the encoded form starts in the original content.
func (Chunk) MarshalJSON ¶
MarshalJSON marshals the location and the data length, never the data.
type Origin ¶
type Origin struct {
// Root is the Data of the source chunk, shared, not copied.
Root []byte
// Offsets has one entry per byte of the decoded Data: byte i of Data comes from
// Root[Offsets[i]].
Offsets []int32
// Depth is the number of decoding steps from Root (1 = decoded once).
Depth int
// Index is the newline index of Root, shared by every chunk decoded from one
// source chunk; nil means the reader builds its own.
Index *RootIndex
}
Origin maps a decoded chunk back to the source chunk it was decoded from. Root is content too: it is never printed, logged or marshalled.
func (Origin) MarshalJSON ¶
MarshalJSON marshals the depth and the root length, never the root.
type Part ¶
Part is one named part of a multi-part credential. Key prints, logs and marshals only its redacted form.
type RootIndex ¶
type RootIndex struct {
// contains filtered or unexported fields
}
RootIndex lazily computes the byte offsets of every newline in a root, once, and is safe for concurrent use.
func NewRootIndex ¶
NewRootIndex returns an index of root; nothing is computed until Newlines.
type SuppressCtx ¶
type SuppressCtx struct {
// TestMarker is true when the key carries the TOKENHOUNDTEST marker.
TestMarker bool `json:"test_marker"`
// InlineAllow is true when an inline allow comment covers the match.
InlineAllow bool `json:"inline_allow"`
// AllowlistHits lists the allowlist entries the key matched.
AllowlistHits []string `json:"allowlist_hits"`
}
SuppressCtx holds the suppression predicates detect precomputes from the raw key and its surroundings.