tag

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 13 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 tag holds the record of one drill run on one target, and the chain that links those records.

Index

Constants

View Source
const (
	Pass  = "PASS"
	Fail  = "FAIL"
	Warn  = "WARN"
	NA    = "N/A"
	Skip  = "SKIP"
	Error = "ERROR"
)

Verdicts for one run.

View Source
const (
	Open    = "OPEN"
	Closed  = "CLOSED"
	Unknown = "UNKNOWN"
	Retired = "RETIRED"
)

Safeguard states over time.

Variables

This section is empty.

Functions

func EvidenceHash

func EvidenceHash(e Evidence) (string, error)

EvidenceHash returns the SHA-256 of evidence.

func HeaderHash

func HeaderHash(h Header) (string, error)

HeaderHash returns the SHA-256 of a header.

func NextState

func NextState(prev, verdict string, retired bool) string

NextState applies the one rule: only FAIL opens a safeguard, and only PASS closes it. Every other verdict leaves the state where it was.

func Redact

func Redact(t *Tag)

Redact replaces a tag's evidence with a redaction marker. The header, and so the chain, stays as it was.

func ScanSnapshot

func ScanSnapshot(s *graph.Snapshot, h graph.Hasher) int

ScanSnapshot scans a snapshot's attributes before it is written, returning how many values it replaced.

func ScanTag

func ScanTag(t *Tag, h graph.Hasher)

ScanTag scans a tag's evidence in place before it is written.

func ScanValue

func ScanValue(v any, h graph.Hasher, where string, notes *[]string) any

ScanValue replaces any string that looks like a secret with its hash, and returns a note for each. A hit never stops a run and never changes a verdict.

func Slug

func Slug(s string) string

Slug makes a target safe to use as one path segment.

Types

type ChainStatus

type ChainStatus struct {
	OK       bool
	Tampered []string
	Redacted int
}

ChainStatus is the result of checking one history.

func VerifyChain

func VerifyChain(history []*Tag) ChainStatus

VerifyChain checks that each header links to the previous one and that each evidence part matches its hash. Evidence replaced by a redaction marker is reported as redacted, never tampered.

type Condition

type Condition struct {
	Expr   string `json:"expr"`
	Result string `json:"result"` // true, false or an error message
}

Condition is the result of one condition.

type Evidence

type Evidence struct {
	Facts    map[string]any `json:"facts,omitempty"`
	Read     []string       `json:"read,omitempty"`
	Redacted bool           `json:"redacted,omitempty"`
}

Evidence is what the verdict was decided on.

type Header struct {
	DrillID      string            `json:"drill_id"`
	DrillHash    string            `json:"drill_sha256"`
	Version      string            `json:"firedrill_version"`
	Target       string            `json:"target"`
	Stream       string            `json:"stream"`
	Verdict      string            `json:"verdict"`
	Reason       string            `json:"reason,omitempty"`
	State        string            `json:"state"`
	Waived       bool              `json:"waived,omitempty"`
	WaivedParts  int               `json:"waived_findings,omitempty"`
	Severity     string            `json:"severity"`
	Owner        string            `json:"owner,omitempty"`
	Conditions   []Condition       `json:"conditions,omitempty"`
	FactSources  map[string]string `json:"fact_sources,omitempty"`
	Time         time.Time         `json:"time"`
	RanBy        string            `json:"ran_by"`
	Attested     bool              `json:"attested"`
	SaltPrint    string            `json:"salt_fingerprint,omitempty"`
	EvidenceHash string            `json:"evidence_sha256"`
	Previous     string            `json:"previous_sha256,omitempty"`
	ScannerNotes []string          `json:"scanner_notes,omitempty"`
}

Header is the part of a tag the chain covers. It holds a hash of the evidence rather than the evidence, so evidence about a person can be redacted without breaking the chain.

type Key

type Key struct{ DrillID, TargetSlug string }

Key names one drill and target directory.

type Store

type Store struct{ Root string }

Store reads and writes tags under one directory.

func (Store) History

func (s Store) History(drillID, target string) ([]*Tag, error)

History returns the tags of one drill and target, oldest first.

func (Store) Keys

func (s Store) Keys() ([]Key, error)

Keys lists every drill and target with tags.

func (Store) Latest

func (s Store) Latest(drillID, target string) (*Tag, error)

Latest returns the newest tag of one drill and target, or nil.

func (Store) Write

func (s Store) Write(t *Tag) (string, error)

Write stores a tag, filling in its evidence hash and link to the previous tag.

type Tag

type Tag struct {
	Header   Header   `json:"header"`
	Evidence Evidence `json:"evidence"`
}

Tag is one record.

Jump to

Keyboard shortcuts

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