web

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 25 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 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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionRequest added in v0.5.2

type ActionRequest struct {
	By string `json:"by"`
	At string `json:"at"`
}

ActionRequest is a recorded human retry/expedite request.

type ActiveRun

type ActiveRun struct {
	Kind string `json:"kind"`
	Name string `json:"name"`
}

ActiveRun points at the child currently running.

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"`
	Attributes map[string]string `json:"attributes,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"`
	// TotalUsage sums token and cost accounting across every attempt of
	// both stages, lifted from the Investigation/Remediation children.
	TotalUsage        *Usage     `json:"totalUsage,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

type Granter interface {
	Grants(ctx context.Context, id auth.Identity) (authz.Grants, error)
}

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"`
	Report         string `json:"report,omitempty"`
	Harness        string `json:"harness,omitempty"`
	Model          string `json:"model,omitempty"`
	Usage          *Usage `json:"usage,omitempty"`
}

Investigation mirrors the Finding's investigation summary, plus the report markdown and run accounting lifted from the Investigation child.

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 PhaseTime

type PhaseTime struct {
	Phase string `json:"phase"`
	At    string `json:"at"`
}

PhaseTime is one phase-entry log record.

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 struct {
	Name         string `json:"name"`
	Relationship string `json:"relationship"`
}

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"`
	Report      string `json:"report,omitempty"`
	Harness     string `json:"harness,omitempty"`
	Model       string `json:"model,omitempty"`
	Usage       *Usage `json:"usage,omitempty"`
}

Remediation mirrors the Finding's remediation summary, plus the report markdown and run accounting lifted from the Remediation child.

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

type RollupScope struct {
	Type string `json:"type"`
	Key  string `json:"key,omitempty"`
}

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

func (s *Server) Handler() http.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

func (s *Server) StartWatch(ctx context.Context, c cache.Cache) error

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.

type Tracking

type Tracking struct {
	IssueNumber int64  `json:"issueNumber,omitempty"`
	URL         string `json:"url,omitempty"`
	State       string `json:"state,omitempty"`
}

Tracking links the projected tracking issue.

type Usage added in v0.5.3

type Usage struct {
	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"`
}

Usage is token and cost accounting — one run's, or the finding's total across every attempt of both stages. Cost is integer micro-USD, matching the rollup wire type.

type User

type User struct {
	Name     string `json:"name"`
	LoggedIn bool   `json:"loggedIn"`
	// AdminActions are the granted namespace-wide verbs (replay, reset) the
	// user menu renders. Absent means none.
	AdminActions []string `json:"adminActions,omitempty"`
}

User is the signed-in identity the top bar renders.

Directories

Path Synopsis
Package auth resolves who is making a status-server request.
Package auth resolves who is making a status-server request.
Package authz resolves what an identity may do to findings.
Package authz resolves what an identity may do to findings.

Jump to

Keyboard shortcuts

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