Documentation
¶
Overview ¶
Package scan models one execution of the Cortex engine.
A Scan groups everything produced by running N scanners against a git revision: its findings, timing, status, and the rules each scanner used.
Aggregate root: Scan Value Objects: ScanID, Revision, Status (sum type), Duration Domain Events: Started, Completed, Failed
Status transitions are explicit and validated:
Queued → Running → Completed
↘ Failed
Index ¶
- Constants
- func NewID(raw string) mo.Result[ID]
- func NewRevision(commit, branch string) mo.Result[Revision]
- type Completed
- type DomainEvent
- type Failed
- type ID
- type Queued
- type Revision
- type Scan
- func (s Scan) Complete(now time.Time, findings []finding.Fingerprint) mo.Result[Scan]
- func (s Scan) Duration() time.Duration
- func (s Scan) EndedAt() time.Time
- func (s Scan) Events() []DomainEvent
- func (s Scan) Fail(now time.Time, reason string) mo.Result[Scan]
- func (s Scan) Failure() string
- func (s Scan) Findings() []finding.Fingerprint
- func (s Scan) ID() ID
- func (s Scan) Revision() Revision
- func (s Scan) Start(now time.Time) mo.Result[Scan]
- func (s Scan) StartedAt() time.Time
- func (s Scan) Status() Status
- type Started
- type Status
Constants ¶
const UnknownRevisionCommit = "unknown"
UnknownRevisionCommit marks a Scan whose git revision could not be resolved — a tarball, a vendored copy, any target outside a repository. Baseline and differential features degrade gracefully for such scans.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DomainEvent ¶
type DomainEvent interface {
EventName() string
}
DomainEvent is implemented by every event recorded by the Scan aggregate.
type ID ¶
type ID string
ID identifies a Scan instance. Generation is the application layer's responsibility (typically a UUID via an injected IDGenerator port).
type Revision ¶
type Revision struct {
// contains filtered or unexported fields
}
Revision describes the git revision under analysis.
func UnknownRevision ¶
func UnknownRevision() Revision
UnknownRevision is the fallback Revision for non-repository targets.
type Scan ¶
type Scan struct {
// contains filtered or unexported fields
}
Scan is the aggregate root for one execution of the Cortex engine against a given revision. It owns the lifecycle status, the timestamps, and the (referential) list of findings produced.
Findings are held by Fingerprint, not by value — keeping the Scan aggregate lean and avoiding accidental coupling to Finding internals.
All transition methods return a NEW Scan; the receiver is never mutated.
func (Scan) Complete ¶
Complete transitions Running → Completed and snapshots the findings' fingerprints. Invalid otherwise.
func (Scan) Events ¶
func (s Scan) Events() []DomainEvent
func (Scan) Fail ¶
Fail transitions any non-terminal status → Failed. Invalid from a terminal state.
func (Scan) Findings ¶
func (s Scan) Findings() []finding.Fingerprint
type Status ¶
type Status int
Status represents the lifecycle state of a Scan.
Transitions:
Queued ──Start──▶ Running ──Complete──▶ Completed (terminal)
│ │
└──Fail──▶ Failed (terminal)
│
└──Fail──▶ Failed (terminal)
func (Status) IsTerminal ¶
IsTerminal reports whether the scan has reached an end state.