Documentation
¶
Overview ¶
Package web is the status-server backend: the embedded status page SPA, a JSON projection of Findings and FindingRollups, the three human actions (approve, suspend, resume), and an SSE change signal that tells open browsers to refetch.
The exposure contract is deliberately asymmetric: rollup statistics are public (GET /api/rollups and the SSE stream serve without a session), while the findings surface — list, detail, and every action — always requires an authenticated identity (internal/web/auth) holding the RBAC grants (internal/web/authz). The server never writes finding status and never moves a phase: approve records spec.approval and suspend/resume toggle spec.suspend, leaving every phase edge to its owning controller.
The wire types in data.go mirror the status page's TypeScript contract (ui/src/types.ts) field for field; keep the two in lockstep.
Index ¶
- type ActionRequest
- type ActiveRun
- type Alert
- type Approval
- type Attempts
- type Dataset
- type Enrichment
- type Finding
- type Granter
- type Investigation
- type Location
- type MonthlyBucket
- type PhaseTime
- type PullRequest
- type Related
- type Remediation
- type Repository
- type Rollup
- type RollupBucket
- type RollupScope
- type Server
- type StageAggregate
- type Tracking
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionRequest ¶ added in v0.5.2
ActionRequest is a recorded human retry/expedite request.
type Alert ¶
type Alert struct {
ID string `json:"id"`
URL string `json:"url,omitempty"`
Locations []Location `json:"locations,omitempty"`
}
Alert is one scanner alert folded into the finding.
type Approval ¶
type Approval struct {
By string `json:"by"`
At string `json:"at"`
Note string `json:"note,omitempty"`
}
Approval is the recorded human approval.
type Attempts ¶
type Attempts struct {
Investigation int32 `json:"investigation,omitempty"`
Remediation int32 `json:"remediation,omitempty"`
}
Attempts tallies agent runs per stage.
type Dataset ¶
type Dataset struct {
GeneratedAt string `json:"generatedAt"`
Namespace string `json:"namespace,omitempty"`
Version string `json:"version,omitempty"`
User *User `json:"user,omitempty"`
Findings []Finding `json:"findings"`
Rollups []Rollup `json:"rollups,omitempty"`
}
Dataset is the payload behind GET /api/findings (everything) and GET /api/rollups (findings empty, no user). It mirrors ui/src/types.ts.
type Enrichment ¶
type Enrichment struct {
Enhancer string `json:"enhancer"`
Owners []string `json:"owners,omitempty"`
Markdown string `json:"markdown,omitempty"`
AppliedAt string `json:"appliedAt,omitempty"`
}
Enrichment is one enhancer contribution.
type Finding ¶
type Finding struct {
Name string `json:"name"`
CreatedAt string `json:"createdAt,omitempty"`
Integration string `json:"integration,omitempty"`
Source string `json:"source,omitempty"`
Repository *Repository `json:"repository,omitempty"`
Advisories []string `json:"advisories"`
RuleID string `json:"ruleID,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Severity string `json:"severity,omitempty"`
Alerts []Alert `json:"alerts,omitempty"`
// OverflowAlerts counts alerts dropped past the accumulation cap.
OverflowAlerts int32 `json:"overflowAlerts,omitempty"`
Related []Related `json:"related,omitempty"`
Suspend bool `json:"suspend,omitempty"`
Approval *Approval `json:"approval,omitempty"`
Retry *ActionRequest `json:"retry,omitempty"`
Expedite *ActionRequest `json:"expedite,omitempty"`
Phase string `json:"phase,omitempty"`
PhaseTimes []PhaseTime `json:"phaseTimes,omitempty"`
FirstObservedAt string `json:"firstObservedAt,omitempty"`
AccumulateUntil string `json:"accumulateUntil,omitempty"`
Tracking *Tracking `json:"tracking,omitempty"`
Owners []string `json:"owners,omitempty"`
Enrichments []Enrichment `json:"enrichments,omitempty"`
Priority string `json:"priority,omitempty"`
Investigation *Investigation `json:"investigation,omitempty"`
Remediation *Remediation `json:"remediation,omitempty"`
PullRequest *PullRequest `json:"pullRequest,omitempty"`
Attempts *Attempts `json:"attempts,omitempty"`
ActiveRun *ActiveRun `json:"activeRun,omitempty"`
LastFailureReason string `json:"lastFailureReason,omitempty"`
CompletedAt string `json:"completedAt,omitempty"`
// UserActions are the verbs the requesting user may invoke; the client
// intersects them with the state machine. Absent means read-only.
UserActions []string `json:"userActions,omitempty"`
}
Finding is the flattened metadata+spec+status projection of one Finding, plus the requesting user's granted action verbs.
type Granter ¶
Granter resolves what an identity may do; internal/web/authz provides the SubjectAccessReview implementation and the mode-none bypass.
type Investigation ¶
type Investigation struct {
Name string `json:"name,omitempty"`
Attempt int32 `json:"attempt,omitempty"`
Outcome string `json:"outcome,omitempty"`
Recommendation string `json:"recommendation,omitempty"`
Confidence string `json:"confidence,omitempty"`
Exploitability string `json:"exploitability,omitempty"`
Likelihood string `json:"likelihood,omitempty"`
Impact string `json:"impact,omitempty"`
AwaitApproval bool `json:"awaitApproval,omitempty"`
CompletedAt string `json:"completedAt,omitempty"`
}
Investigation mirrors the Finding's investigation summary.
type Location ¶
type Location struct {
Path string `json:"path"`
StartLine int32 `json:"startLine,omitempty"`
EndLine int32 `json:"endLine,omitempty"`
Snippet string `json:"snippet,omitempty"`
}
Location is one source location an alert points at.
type MonthlyBucket ¶
type MonthlyBucket struct {
Findings int64 `json:"findings,omitempty"`
Runs int64 `json:"runs,omitempty"`
CostMicroUSD int64 `json:"costMicroUSD,omitempty"`
}
MonthlyBucket is one month of the total scope's trend line.
type PullRequest ¶
type PullRequest struct {
Number int64 `json:"number"`
URL string `json:"url,omitempty"`
State string `json:"state,omitempty"`
MergedAt string `json:"mergedAt,omitempty"`
}
PullRequest is the remediation pull request's lifecycle.
type Related ¶
Related is one relationship edge, named from this finding's perspective: the CRD stores {from, to}, the wire type carries the other endpoint.
type Remediation ¶
type Remediation struct {
Name string `json:"name,omitempty"`
Attempt int32 `json:"attempt,omitempty"`
Outcome string `json:"outcome,omitempty"`
Success bool `json:"success,omitempty"`
Branch string `json:"branch,omitempty"`
CompletedAt string `json:"completedAt,omitempty"`
}
Remediation mirrors the Finding's remediation summary.
type Repository ¶
type Repository struct {
Type string `json:"type"`
URL string `json:"url"`
Name string `json:"name,omitempty"`
DefaultBranch string `json:"defaultBranch,omitempty"`
}
Repository locates the finding's repository.
type Rollup ¶
type Rollup struct {
Scope RollupScope `json:"scope"`
FirstProcessed string `json:"firstProcessed,omitempty"`
LastProcessed string `json:"lastProcessed,omitempty"`
Bucket RollupBucket `json:"bucket"`
Monthly map[string]MonthlyBucket `json:"monthly,omitempty"`
}
Rollup is one scope's all-time statistics, identified by scope.key ("" is the total scope) — never by object name.
type RollupBucket ¶
type RollupBucket struct {
Findings int64 `json:"findings,omitempty"`
Phases map[string]int64 `json:"phases,omitempty"`
Recommendations map[string]int64 `json:"recommendations,omitempty"`
Attempts int64 `json:"attempts,omitempty"`
Stages map[string]StageAggregate `json:"stages,omitempty"`
}
RollupBucket carries the finding-level counters; harness and model scopes carry only stages.
type RollupScope ¶
RollupScope identifies one rollup dimension value.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the status-server backend: the public rollups projection, the authenticated findings projection, the three actions, the SSE change signal, and the embedded SPA.
func NewServer ¶
func NewServer(c client.Client, namespace string, a auth.Authenticator, g Granter, log *slog.Logger) *Server
NewServer builds the backend over the manager's cached client. log may be nil.
func (*Server) Handler ¶
Handler builds the HTTP surface: the split public/authenticated API, the SSE stream, the sign-in routes (when the auth mode has any), and the embedded SPA with client-side-routing fallback.
func (*Server) StartWatch ¶
StartWatch registers change handlers on the Finding and FindingRollup informers and publishes a debounced findings-changed notification to the SSE broker. It blocks until ctx is cancelled, so it slots straight into a manager runnable — running after the cache has synced and stopping with the manager.
type StageAggregate ¶
type StageAggregate struct {
Runs int64 `json:"runs,omitempty"`
Succeeded int64 `json:"succeeded,omitempty"`
Outcomes map[string]int64 `json:"outcomes,omitempty"`
InputTokens int64 `json:"inputTokens,omitempty"`
OutputTokens int64 `json:"outputTokens,omitempty"`
CacheReadTokens int64 `json:"cacheReadTokens,omitempty"`
CacheCreationTokens int64 `json:"cacheCreationTokens,omitempty"`
CostMicroUSD int64 `json:"costMicroUSD,omitempty"`
ElapsedMilliseconds int64 `json:"elapsedMilliseconds,omitempty"`
}
StageAggregate is one stage's raw sums; the client computes rates and averages.