templates

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 5 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 templates renders every piece of markdown patchy writes — issue bodies, comments, pull-request bodies, and the agent-facing handoff files — from embedded text/templates, so the artifacts stay consistent across the estate.

The issue body carries a machine-readable manifest block (an HTML comment holding JSON) that is the authoritative record of the alerts accumulated into the issue; the human-readable body is re-rendered from the manifest on every accumulation, never string-edited. The accumulator (source-controller) owns the body; everyone else appends comments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnrichmentMarker added in v0.5.3

func EnrichmentMarker(enhancer string) string

EnrichmentMarker heads one enhancer's sticky tracking comment; the projection finds the comment to update in place by this prefix.

func FindingIssueTitle added in v0.4.0

func FindingIssueTitle(f *v1alpha1.Finding) string

FindingIssueTitle is the tracking-issue title projected from a Finding.

func PRBody

func PRBody(issue int, report string) (string, error)

PRBody renders the pull-request body for a remediation branch; issue is the tracking issue number ("Fixes #issue" auto-links and auto-closes).

func RenderEnrichmentProjection added in v0.4.0

func RenderEnrichmentProjection(e v1alpha1.Enrichment) string

RenderEnrichmentProjection renders one enhancer enrichment as its sticky tracking-issue comment.

func RenderFindingIssue added in v0.4.0

func RenderFindingIssue(f *v1alpha1.Finding) (string, error)

RenderFindingIssue renders the tracking-issue body from the Finding — a pure human-facing projection (the CR is the state; the body carries only a finding-name marker comment for debugging).

func RenderInvestigatePrompt added in v0.4.0

func RenderInvestigatePrompt(p InvestigatePrompt) (string, error)

RenderInvestigatePrompt renders the investigation prompt.

func RenderRemediatePrompt

func RenderRemediatePrompt(p RemediatePrompt) (string, error)

RenderRemediatePrompt renders the remediation prompt.

func RenderSCCDescription added in v0.8.0

func RenderSCCDescription(f SCCFinding) (string, error)

RenderSCCDescription renders a Security Command Center notification as the Finding's markdown description. That description is the finding body a human reads on the tracking issue and the handoff file an agent investigates, so it carries the detector's own reasoning rather than a patchy summary of it.

func RenderStageReportComment added in v0.4.0

func RenderStageReportComment(stage string, attempt int32, report string) string

RenderStageReportComment renders an agent report as a tracking-issue comment, headed by the stage name and attempt so re-projection can dedup.

func RenderWizIssueDescription added in v0.9.0

func RenderWizIssueDescription(i WizIssue) (string, error)

RenderWizIssueDescription renders a Wiz issue as the Finding's markdown description — the body a human reads on the tracking issue and the handoff an agent investigates.

func RenderWizThreatDescription added in v0.9.0

func RenderWizThreatDescription(t WizThreat) (string, error)

RenderWizThreatDescription renders a Wiz Defend threat as the Finding's markdown description.

Types

type Calibration added in v0.8.0

type Calibration struct {
	// Scope describes where the figures came from, e.g. "owner/repo" or
	// "all repositories" when the per-repository history was too thin.
	Scope string `json:"scope,omitempty"`
	// Runs the averages are drawn from.
	Runs int64 `json:"runs"`
	// AvgPredictedTurns/AvgActualTurns and the token pair are whole-number
	// averages over those runs.
	AvgPredictedTurns        int64 `json:"avgPredictedTurns"`
	AvgActualTurns           int64 `json:"avgActualTurns"`
	AvgPredictedOutputTokens int64 `json:"avgPredictedOutputTokens"`
	AvgActualOutputTokens    int64 `json:"avgActualOutputTokens"`
}

Calibration reports how previous remediations compared to what the investigation predicted, so the next estimate can correct for the observed skew. It is derived from a FindingRollup's remediation stage aggregate and carried to the pod as JSON — the runner has no Kubernetes access, so this travels as configuration like every other fact it needs.

func (*Calibration) TokenSkew added in v0.8.0

func (c *Calibration) TokenSkew() int64

TokenSkew is the same measure for output tokens.

func (*Calibration) TurnSkew added in v0.8.0

func (c *Calibration) TurnSkew() int64

TurnSkew is how far actual turns ran over (positive) or under (negative) the prediction, as a percentage. Zero when there is no prediction to compare against.

type InvestigatePrompt added in v0.4.0

type InvestigatePrompt struct {
	IssuePath     string
	ReportPath    string
	AllowedModels []string
	// AutoMaxTurns/AutoTokenBudget is what a remediation gets unattended, and
	// the line past which an estimate needs human approval — NOT a cap.
	AutoMaxTurns    int
	AutoTokenBudget int
	// ManualMaxTurns/ManualTokenBudget is the most a human-approved run can
	// get. Rendered so the agent knows asking beyond it buys nothing.
	ManualMaxTurns    int
	ManualTokenBudget int
	// Calibration is how earlier estimates compared to reality; nil omits the
	// section (a cold start has nothing honest to say).
	Calibration *Calibration
}

InvestigatePrompt is the data for the analysis-stage prompt (stage 1: exploitability/likelihood/impact plus the verdict).

type RemediatePrompt

type RemediatePrompt struct {
	IssuePath         string
	InvestigationPath string
	ReportPath        string
	CommitScriptPath  string
}

RemediatePrompt is the data for the stage-2 (remediation) prompt.

type SCCCompliance added in v0.8.0

type SCCCompliance struct {
	Standard string
	Version  string
	IDs      []string
}

SCCCompliance is one standard a finding breaches.

type SCCFinding added in v0.8.0

type SCCFinding struct {
	// Name is the finding's full SCC resource name.
	Name string
	// Category is the detector's raw finding type (PUBLIC_BUCKET_ACL).
	Category string
	// Class is the finding class (VULNERABILITY, MISCONFIGURATION, ...).
	Class string
	// Severity is SCC's own rating, for display alongside patchy's.
	Severity string
	// Description is the detector's prose explanation.
	Description string
	// NextSteps is the detector's remediation guidance, already markdown.
	NextSteps string
	// Resource is the affected cloud resource.
	Resource SCCResource
	// CVE and CVSS are set when the finding is a vulnerability.
	CVE  string
	CVSS string
	// MitreTactic and MitreTechniques are the ATT&CK mapping, when present.
	MitreTactic     string
	MitreTechniques []string
	// Compliances are the standards breached.
	Compliances []SCCCompliance
	// Properties are the detector's own facts, sorted by key.
	Properties []SCCKV
	// Marks are the operator's security marks, sorted by key. They are worth
	// showing: they are how a human annotates a resource, and one of them may
	// be the very label that failed to resolve a repository.
	Marks []SCCKV
	// DetectedAt is the event time.
	DetectedAt string
	// ExternalURI links to the finding in the Cloud Console.
	ExternalURI string
}

SCCFinding is the data the Security Command Center description template renders. It is a flattened, presentation-ready view of the notification — the source decides what is worth showing, the template decides how it looks.

type SCCKV added in v0.8.0

type SCCKV struct {
	Key   string
	Value string
}

SCCKV is one ordered key/value fact. Security Command Center hands several of its richest fields over as unordered maps; the source sorts them into slices so the rendered markdown is stable and the goldens mean something.

type SCCResource added in v0.8.0

type SCCResource struct {
	Name        string
	DisplayName string
	Type        string
	Project     string
	Location    string
	Service     string
}

SCCResource describes the affected cloud resource.

type WizEntity added in v0.9.0

type WizEntity struct {
	// Name is the normalized provider identifier (the Finding's cloud
	// resource name).
	Name string
	// DisplayName is the resource's human-facing name.
	DisplayName string
	// Type is the provider's own type name.
	Type string
	// Platform is Wiz's platform value (GCP, AWS, Azure).
	Platform string
	// Subscription is the enclosing cloud account, with its display name.
	Subscription     string
	SubscriptionName string
	// Region the resource lives in.
	Region string
	// ConsoleURL links to the resource in its provider's console.
	ConsoleURL string
	// Tags are the provider tags/labels on the resource, sorted by key.
	Tags []WizKV
}

WizEntity describes the affected cloud resource as Wiz snapshotted it.

type WizIssue added in v0.9.0

type WizIssue struct {
	// ID is the Wiz issue id.
	ID string
	// ControlName and ControlID identify the security control that fired.
	ControlName string
	ControlID   string
	// Severity is Wiz's own rating, lowercased for display.
	Severity string
	// Status is the issue's lifecycle status.
	Status string
	// Description is the control's prose explanation.
	Description string
	// Recommendation is Wiz's remediation guidance, already markdown.
	Recommendation string
	// Entity is the affected resource.
	Entity WizEntity
	// Projects names the Wiz projects the entity belongs to.
	Projects string
	// CreatedAt is when Wiz opened the issue.
	CreatedAt string
	// URL links to the issue in the Wiz console.
	URL string
}

WizIssue is the data the Wiz Issues description template renders — a flattened, presentation-ready view of the delivery. The source decides what is worth showing, the template decides how it looks.

type WizKV added in v0.9.0

type WizKV struct {
	Key   string
	Value string
}

WizKV is one ordered key/value fact. Wiz hands resource tags over as unordered maps; the source sorts them into slices so the rendered markdown is stable and the goldens mean something.

type WizThreat added in v0.9.0

type WizThreat struct {
	// ID is the Wiz threat id.
	ID string
	// Name is the threat's title.
	Name string
	// RuleName and RuleID identify the detection rule.
	RuleName string
	RuleID   string
	// Severity is Wiz's own rating, lowercased for display.
	Severity string
	// Status is the threat's lifecycle status.
	Status string
	// Description explains what was detected.
	Description string
	// Entity is the affected resource this Finding was scoped to.
	Entity WizEntity
	// Actors are the identities involved, rendered "name (type)".
	Actors []string
	// MitreTactics and MitreTechniques map the detection onto ATT&CK.
	MitreTactics    []string
	MitreTechniques []string
	// Detections counts the individual detections rolled into the threat.
	Detections int
	// CloudAccounts are the accounts involved.
	CloudAccounts []string
	// CreatedAt is when the threat was raised.
	CreatedAt string
	// URL links to the threat in the Wiz console.
	URL string
}

WizThreat is the data the Wiz Defend description template renders.

Jump to

Keyboard shortcuts

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