checks

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxEvidenceItems = 5

Variables

This section is empty.

Functions

func AppendTruncatedEvidence

func AppendTruncatedEvidence(out *Output, items []string, prefix, overflowLabel string)

func BuildCompliantRationale

func BuildCompliantRationale(items []string, emptyMessage, description string) string

func BuildViolationRationale

func BuildViolationRationale(items []string, singular, plural string) string

func FormatScannedItems

func FormatScannedItems(items []string) string

func SetChecksWriter

func SetChecksWriter(ctx context.Context, w ChecksWriter) context.Context

func TruncateEvidence

func TruncateEvidence(evidence []string) []string

func WriteCheckOutputs

func WriteCheckOutputs(ctx context.Context, input dag_impl.Input, checkOutputs []Output) error

func WriteSummary

func WriteSummary(ctx context.Context, input dag_impl.Input, summary any) error

Types

type BaseCheckNode

type BaseCheckNode struct {
	// UPPER_SNAKE_CASE identifier. Must be unique across all checks.
	Code string `json:"code"`

	// Single sentence stating the condition this check detects.
	// Must read naturally as: "This check fires when: <Description>".
	// State the observable fact only — consequences belong in Categories.
	Description string `json:"description"`

	// One sentence explaining the security or operational risk this check exists to detect.
	// Omit when the Description (and Outcomes, if present) already make the risk self-evident.
	WhyThisMatters string `json:"why_this_matters,omitempty"`

	// Risk category → sentence explaining WHY this check belongs in that category.
	// The key determines policy enforcement; the value completes the sentence
	// "This check is in the <category> category because: <value>".
	// Do NOT restate the Description — explain the consequence or risk.
	Categories map[category.RiskCategory]string `json:"categories"`

	// What each check status means for this specific check.
	// Omit when the Description already makes outcomes self-evident.
	Outcomes storage.Outcomes `json:"outcomes,omitempty"`

	// Methodology, scope limitations, or default thresholds a customer needs to
	// interpret the result correctly. Use fmt.Sprintf for threshold defaults so
	// values stay in sync with code. One caveat per entry.
	Disclaimers []string `json:"disclaimers,omitempty"`

	// Configurable decision boundaries for threshold-based checks.
	// Serialized into catalog and check output for customer visibility.
	Thresholds map[string]any `json:"thresholds,omitempty"`
}

BaseCheckNode provides common fields and all boilerplate methods for check nodes. Embed this struct to get Kind(), GetCode(), GetDescription(), GetCategories(), and CreateSkippedOutput().

All fields serialize into the catalog (go run src/server/main.go meta catalog) and are visible to customers evaluating the product. Write for a non-technical security audience.

func (*BaseCheckNode) CreateSkippedOutput

func (b *BaseCheckNode) CreateSkippedOutput(reason string, input dag_impl.Input) *Output

func (*BaseCheckNode) GetCategories

func (b *BaseCheckNode) GetCategories() map[category.RiskCategory]string

func (*BaseCheckNode) GetCode

func (b *BaseCheckNode) GetCode() string

func (*BaseCheckNode) GetDescription

func (b *BaseCheckNode) GetDescription() string

func (*BaseCheckNode) GetDisclaimers

func (b *BaseCheckNode) GetDisclaimers() []string

func (*BaseCheckNode) GetOutcomes

func (b *BaseCheckNode) GetOutcomes() storage.Outcomes

func (*BaseCheckNode) GetThresholds

func (b *BaseCheckNode) GetThresholds() map[string]any

func (*BaseCheckNode) GetWhyThisMatters

func (b *BaseCheckNode) GetWhyThisMatters() string

func (*BaseCheckNode) Kind

func (b *BaseCheckNode) Kind() string

type CheckOutputProvider

type CheckOutputProvider interface {
	GetCheckOutput() *Output
}

CheckOutputProvider is an interface for types that wrap checks.Output Each check's unique output type should implement this interface

type ChecksWriter

type ChecksWriter func(ctx context.Context, doc storage.ChecksResult, input dag_impl.Input) error

func GetChecksWriter

func GetChecksWriter(ctx context.Context) ChecksWriter

type Output

type Output struct {
	dag_impl.BaseOutput `json:",inline"`
	Check               storage.Check `json:",inline"`
	// contains filtered or unexported fields
}

func NewCompliantOutput

func NewCompliantOutput(checkCode string, rationale string, input dag_impl.Input) *Output

func NewSkippedOutput

func NewSkippedOutput(checkCode string, reason string, input dag_impl.Input) *Output

func NewViolationOutput

func NewViolationOutput(checkCode string, rationale string, evidence []string, input dag_impl.Input) *Output

func (*Output) Metadata

func (o *Output) Metadata() map[string]any

func (*Output) WithEvidence

func (o *Output) WithEvidence(evidence string) *Output

WithEvidencef appends a formatted evidence string and returns the output for chaining

func (*Output) WithEvidencef

func (o *Output) WithEvidencef(format string, args ...any) *Output

WithEvidencef appends a formatted evidence string and returns the output for chaining

func (*Output) WithMetadata

func (o *Output) WithMetadata(key string, value any) *Output

func (*Output) WithThresholds

func (o *Output) WithThresholds(thresholds map[string]any) *Output

WithThresholds sets the thresholds and returns the output for chaining

func (*Output) Write

func (o *Output) Write(ctx context.Context) error

Jump to

Keyboard shortcuts

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