Documentation
¶
Overview ¶
Package response is the response module: the execution switch, the action catalog, rules and the engine, requests and approvals in the app, the box actions (block list, message, webhook) and the hash-chained log. See CONTRACT.md.
Index ¶
- Constants
- Variables
- func CheckValue(t ParamType, v string) (string, bool)
- func Fill(text string, vals Values, t Transport) (string, error)
- func HasShellChar(s string) bool
- func ValidAllowValue(v string) (string, bool)
- func ValidateTpl(t Tpl, what string) string
- type AIAction
- type AIParam
- type ActionRequest
- type Actor
- type AiGates
- type AiMeta
- type AiNote
- type AiQuality
- type AiState
- type AiUsage
- type AllowEntry
- type Approval
- type ApprovalItem
- type ApprovalMessage
- type ApprovalView
- type Approver
- type BlockEntry
- type BlocklistView
- type BreakerEvent
- type Bus
- type Catalog
- type CatalogAction
- type CatalogInput
- type CatalogUpdate
- type Change
- type ChannelView
- type ChatDecision
- type ChatOutcome
- type CodeSent
- type Condition
- type Config
- type Connection
- type ConnectionInfo
- type Connections
- type DecisionEvent
- type Det
- type DeviceInfo
- type DeviceResult
- type DeviceStep
- type Directory
- type DraftParam
- type DraftStep
- type EmailLink
- type EventView
- type Evidence
- type EvidencePorts
- type EvidenceRef
- type ExecutedEvent
- type Executor
- type FindingInfo
- type Hint
- type HostInfra
- type Identity
- type IncidentInfo
- type IncidentOption
- type IncidentPanel
- type IncidentReader
- type IncidentRef
- type IncidentSource
- type ItemStatus
- type LastFetch
- type LinkBinding
- type LinkMailer
- type LinkRecord
- type LinkSender
- type LinkTokens
- type LogAddress
- type LogCounts
- type LogEntry
- type LogKind
- type LogSource
- type Metrics
- type ModuleGate
- type Notifier
- type NotifyChannel
- type ParamType
- type Plan
- type PlanAsk
- type PlanDraft
- type PlanList
- type PlanRead
- type PlanStep
- type PlanTarget
- type Planner
- type PlannerFinding
- type PlannerStatus
- type PortOpenedEvent
- type Proposal
- type ProposeBody
- type ProposeResult
- type ProposedEvidence
- type ProposedRequest
- type RejectedRow
- type ReplyCodeRecord
- type RequestEvent
- type RequestItem
- type ResponseHandlers
- func (h *ResponseHandlers) ResponseDeleteResponseCatalogID(ctx context.Context, params oas.ResponseDeleteResponseCatalogIDParams) error
- func (h *ResponseHandlers) ResponseDeleteResponseMeIdentitiesChannel(ctx context.Context, ...) error
- func (h *ResponseHandlers) ResponseDeleteResponseRulesID(ctx context.Context, params oas.ResponseDeleteResponseRulesIDParams) error
- func (h *ResponseHandlers) ResponseGetResponseActions(ctx context.Context) (*oas.ResponseGetResponseActionsOK, error)
- func (h *ResponseHandlers) ResponseGetResponseAi(ctx context.Context) (*oas.ResponseGetResponseAiOK, error)
- func (h *ResponseHandlers) ResponseGetResponseAllowlist(ctx context.Context) (*oas.ResponseGetResponseAllowlistOK, error)
- func (h *ResponseHandlers) ResponseGetResponseApproveToken(ctx context.Context, params oas.ResponseGetResponseApproveTokenParams) (*oas.ResponseGetResponseApproveTokenOK, error)
- func (h *ResponseHandlers) ResponseGetResponseBlocklist(ctx context.Context) (*oas.ResponseGetResponseBlocklistOK, error)
- func (h *ResponseHandlers) ResponseGetResponseBlocklistTokenTxt(ctx context.Context, params oas.ResponseGetResponseBlocklistTokenTxtParams) (oas.ResponseGetResponseBlocklistTokenTxtOK, error)
- func (h *ResponseHandlers) ResponseGetResponseCatalog(ctx context.Context) (*oas.ResponseGetResponseCatalogOK, error)
- func (h *ResponseHandlers) ResponseGetResponseEvents(ctx context.Context) (*oas.ResponseGetResponseEventsOK, error)
- func (h *ResponseHandlers) ResponseGetResponseIncidentsID(ctx context.Context, params oas.ResponseGetResponseIncidentsIDParams) (*oas.ResponseGetResponseIncidentsIDOK, error)
- func (h *ResponseHandlers) ResponseGetResponseLog(ctx context.Context) (*oas.ResponseGetResponseLogOK, error)
- func (h *ResponseHandlers) ResponseGetResponseMeIdentities(ctx context.Context) (*oas.ResponseGetResponseMeIdentitiesOK, error)
- func (h *ResponseHandlers) ResponseGetResponseMetrics(ctx context.Context) (*oas.ResponseGetResponseMetricsOK, error)
- func (h *ResponseHandlers) ResponseGetResponsePlans(ctx context.Context, params oas.ResponseGetResponsePlansParams) (*oas.ResponseGetResponsePlansOK, error)
- func (h *ResponseHandlers) ResponseGetResponseRules(ctx context.Context) (*oas.ResponseGetResponseRulesOK, error)
- func (h *ResponseHandlers) ResponseGetResponseSettings(ctx context.Context) (*oas.ResponseGetResponseSettingsOK, error)
- func (h *ResponseHandlers) ResponseGetResponseTemplates(ctx context.Context) (*oas.ResponseGetResponseTemplatesOK, error)
- func (h *ResponseHandlers) ResponseGetResponseTriggers(ctx context.Context) (*oas.ResponseGetResponseTriggersOK, error)
- func (h *ResponseHandlers) ResponsePostResponseActionsIDApprove(ctx context.Context, req *oas.ResponsePostResponseActionsIDApproveReq, ...) (*oas.ResponsePostResponseActionsIDApproveOK, error)
- func (h *ResponseHandlers) ResponsePostResponseActionsIDChatDecision(context.Context, *oas.ResponsePostResponseActionsIDChatDecisionReq, ...) (*oas.ResponsePostResponseActionsIDChatDecisionOK, error)
- func (h *ResponseHandlers) ResponsePostResponseActionsIDReject(ctx context.Context, req *oas.ResponsePostResponseActionsIDRejectReq, ...) (*oas.ResponsePostResponseActionsIDRejectOK, error)
- func (h *ResponseHandlers) ResponsePostResponseActionsIDRollback(ctx context.Context, params oas.ResponsePostResponseActionsIDRollbackParams) (*oas.ResponsePostResponseActionsIDRollbackOK, error)
- func (h *ResponseHandlers) ResponsePostResponseAiProposals(context.Context, *oas.ResponsePostResponseAiProposalsReq) (*oas.ResponsePostResponseAiProposalsOK, error)
- func (h *ResponseHandlers) ResponsePostResponseAiResume(ctx context.Context) (*oas.ResponsePostResponseAiResumeOK, error)
- func (h *ResponseHandlers) ResponsePostResponseApproveToken(ctx context.Context, req *oas.ResponsePostResponseApproveTokenReq, ...) (*oas.ResponsePostResponseApproveTokenOK, error)
- func (h *ResponseHandlers) ResponsePostResponseBlocklistToken(ctx context.Context) (*oas.ResponsePostResponseBlocklistTokenOK, error)
- func (h *ResponseHandlers) ResponsePostResponseBreakerReset(ctx context.Context) (*oas.ResponsePostResponseBreakerResetOK, error)
- func (h *ResponseHandlers) ResponsePostResponseCatalog(ctx context.Context, req *oas.ResponsePostResponseCatalogReq) (*oas.ResponsePostResponseCatalogCreated, error)
- func (h *ResponseHandlers) ResponsePostResponseEmergencyStop(ctx context.Context) (*oas.ResponsePostResponseEmergencyStopOK, error)
- func (h *ResponseHandlers) ResponsePostResponseExecution(ctx context.Context, req *oas.ResponsePostResponseExecutionReq) (*oas.ResponsePostResponseExecutionOK, error)
- func (h *ResponseHandlers) ResponsePostResponseIncidentsIDRequest(ctx context.Context, req *oas.ResponsePostResponseIncidentsIDRequestReq, ...) (*oas.ResponsePostResponseIncidentsIDRequestCreated, error)
- func (h *ResponseHandlers) ResponsePostResponseMeIdentitiesChannelCode(ctx context.Context, ...) (*oas.ResponsePostResponseMeIdentitiesChannelCodeOK, error)
- func (h *ResponseHandlers) ResponsePostResponseMeIdentitiesChannelConfirm(ctx context.Context, ...) (*oas.ResponsePostResponseMeIdentitiesChannelConfirmOK, error)
- func (h *ResponseHandlers) ResponsePostResponseProposalsIDRequest(ctx context.Context, params oas.ResponsePostResponseProposalsIDRequestParams) (*oas.ResponsePostResponseProposalsIDRequestCreated, error)
- func (h *ResponseHandlers) ResponsePostResponseRules(ctx context.Context, req *oas.ResponsePostResponseRulesReq) (*oas.ResponsePostResponseRulesCreated, error)
- func (h *ResponseHandlers) ResponsePostResponseRulesIDManual(ctx context.Context, req *oas.ResponsePostResponseRulesIDManualReq, ...) (*oas.ResponsePostResponseRulesIDManualOK, error)
- func (h *ResponseHandlers) ResponsePostResponseRulesRun(context.Context) (*oas.ResponsePostResponseRulesRunOK, error)
- func (h *ResponseHandlers) ResponsePostResponseRulesSimulate(ctx context.Context, req *oas.ResponsePostResponseRulesSimulateReq) (*oas.ResponsePostResponseRulesSimulateOK, error)
- func (h *ResponseHandlers) ResponsePostResponseTemplatesIDClone(ctx context.Context, params oas.ResponsePostResponseTemplatesIDCloneParams) (*oas.ResponsePostResponseTemplatesIDCloneCreated, error)
- func (h *ResponseHandlers) ResponsePutResponseAllowlist(ctx context.Context, req *oas.ResponsePutResponseAllowlistReq) (*oas.ResponsePutResponseAllowlistOK, error)
- func (h *ResponseHandlers) ResponsePutResponseCatalogID(ctx context.Context, req *oas.ResponsePutResponseCatalogIDReq, ...) (*oas.ResponsePutResponseCatalogIDOK, error)
- func (h *ResponseHandlers) ResponsePutResponseRulesID(ctx context.Context, req *oas.ResponsePutResponseRulesIDReq, ...) (*oas.ResponsePutResponseRulesIDOK, error)
- func (h *ResponseHandlers) ResponsePutResponseSettings(ctx context.Context, req *oas.ResponsePutResponseSettingsReq) (*oas.ResponsePutResponseSettingsOK, error)
- type RestCall
- type Risk
- type RollbackChange
- type RolledBackEvent
- type Rule
- type RuleAction
- type RuleInput
- type RunSummary
- type SecondCheck
- type SentProposal
- type Service
- func (s *Service) AIActions(ctx context.Context) ([]AIAction, error)
- func (s *Service) AIState(ctx context.Context) (AiState, error)
- func (s *Service) Actions(ctx context.Context) ([]ActionRequest, error)
- func (s *Service) AddAction(ctx context.Context, who Actor, in CatalogInput) (CatalogAction, error)
- func (s *Service) AddRule(ctx context.Context, who Actor, in RuleInput) (Rule, error)
- func (s *Service) Allowlist(ctx context.Context) ([]AllowEntry, error)
- func (s *Service) Approve(ctx context.Context, who Actor, id string, pick []string, code string) (ActionRequest, error)
- func (s *Service) Blocklist(ctx context.Context) (BlocklistView, error)
- func (s *Service) Catalog(ctx context.Context, full bool) (Catalog, error)
- func (s *Service) ChangeAction(ctx context.Context, who Actor, id string, u CatalogUpdate) (CatalogAction, error)
- func (s *Service) ChangeRule(ctx context.Context, who Actor, id string, in RuleInput) (Rule, error)
- func (s *Service) ChangesInForce(ctx context.Context, connectionID string) (bool, error)
- func (s *Service) ChatLinkToken(ctx context.Context, userID, channel, address string) (token, name string, err error)
- func (s *Service) Clone(ctx context.Context, who Actor, id string) (Rule, error)
- func (s *Service) Close()
- func (s *Service) ConfirmLink(ctx context.Context, who Actor, channel, code string) (Identity, error)
- func (s *Service) DecideByLink(ctx context.Context, token, decision, from string) (ActionRequest, error)
- func (s *Service) DecideFromChat(ctx context.Context, d ChatDecision) (ChatOutcome, error)
- func (s *Service) DeleteAction(ctx context.Context, who Actor, id string) error
- func (s *Service) DeleteRule(ctx context.Context, who Actor, id string) error
- func (s *Service) DeviceMerged(ctx context.Context, tx *sql.Tx, m lifecycle.Merge) error
- func (s *Service) DropChatLink(ctx context.Context, actor, userID, channel, address string) error
- func (s *Service) DropLinkToken(ctx context.Context, userID, channel, address, token string) error
- func (s *Service) DroppedEvents() int64
- func (s *Service) EmergencyStop(ctx context.Context, who Actor) (int, error)
- func (s *Service) Evaluate(ctx context.Context) (RunSummary, error)
- func (s *Service) Events(ctx context.Context) ([]EventView, error)
- func (s *Service) ExportLog(ctx context.Context, from, to time.Time, w io.Writer) error
- func (s *Service) FetchBlocklist(ctx context.Context, token, from string) ([]byte, error)
- func (s *Service) FindingFolded(ctx context.Context, tx *sql.Tx, f lifecycle.FindingFold) error
- func (s *Service) FindingMoved(ctx context.Context, tx *sql.Tx, f lifecycle.FindingMove) error
- func (s *Service) IncidentPanel(ctx context.Context, id string) (IncidentPanel, error)
- func (s *Service) Jobs() []jobs.Job
- func (s *Service) LinkView(ctx context.Context, token, from string) (ApprovalView, error)
- func (s *Service) Linked(ctx context.Context, userID, channel, address string) (bool, error)
- func (s *Service) Log(ctx context.Context) ([]LogEntry, error)
- func (s *Service) Metrics(ctx context.Context) (Metrics, error)
- func (s *Service) MyIdentities(ctx context.Context, who Actor) ([]Identity, error)
- func (s *Service) PlanOpen(ctx context.Context) (int, error)
- func (s *Service) Plans(ctx context.Context, finding string) (PlanList, error)
- func (s *Service) PollLogs(ctx context.Context) error
- func (s *Service) Propose(ctx context.Context, in ProposeBody) (ProposeResult, error)
- func (s *Service) RecordLink(ctx context.Context, l LinkRecord) error
- func (s *Service) RecordReplyCode(ctx context.Context, c ReplyCodeRecord) error
- func (s *Service) RegenerateToken(ctx context.Context, who Actor) (BlocklistView, error)
- func (s *Service) Reject(ctx context.Context, who Actor, id, reason, remember string) (ActionRequest, error)
- func (s *Service) RequestFromIncident(ctx context.Context, who Actor, id, actionID string) (ActionRequest, error)
- func (s *Service) RequestProposal(ctx context.Context, who Actor, pid string) (ActionRequest, error)
- func (s *Service) ResetBreaker(ctx context.Context, who Actor) (SettingsView, error)
- func (s *Service) ResumeAI(ctx context.Context, who Actor) (AiState, error)
- func (s *Service) Rollback(ctx context.Context, who Actor, id string) (ActionRequest, error)
- func (s *Service) Rules(ctx context.Context) ([]Rule, error)
- func (s *Service) RunManual(ctx context.Context, who Actor, ruleID, assetID string) (RunSummary, error)
- func (s *Service) RunSchedules(ctx context.Context) error
- func (s *Service) SaveSettings(ctx context.Context, who Actor, in SettingsInput) (SettingsView, error)
- func (s *Service) SendLinkCode(ctx context.Context, who Actor, channel string) (CodeSent, error)
- func (s *Service) SetAllowlist(ctx context.Context, who Actor, in []AllowEntry) ([]AllowEntry, error)
- func (s *Service) SetExecution(ctx context.Context, who Actor, enabled bool, phrase string) (SettingsView, error)
- func (s *Service) Settings(ctx context.Context) (SettingsView, error)
- func (s *Service) Simulate(ctx context.Context, who Actor, in RuleInput, eventID string) (Simulation, error)
- func (s *Service) StoreEvent(ctx context.Context, d Det) error
- func (s *Service) Subscribe(bus Bus) (unsubscribe func())
- func (s *Service) Sweep(ctx context.Context) error
- func (s *Service) Templates(ctx context.Context) ([]Template, error)
- func (s *Service) Triggers(ctx context.Context) ([]TriggerInfo, error)
- func (s *Service) Unlink(ctx context.Context, who Actor, channel string) error
- func (s *Service) VerifyLog(ctx context.Context) (chain.Result, error)
- type Settings
- type SettingsInput
- type SettingsView
- type SimCondition
- type SimStep
- type Simulation
- type Stat
- type Status
- type StepStatus
- type Template
- type Tpl
- type Transport
- type TriggerField
- type TriggerInfo
- type TwoStep
- type User
- type Users
- type Values
- type Verified
- type Via
- type WebhookTarget
- type Webhooks
- type Window
Constants ¶
const ( AIMinConfidence = 0.8 // AI_MIN_CONFIDENCE AIRepeatDays = 7 // AI_REPEAT_DAYS )
AI thresholds of the contract (INV-15). Propose reads them for the proposal gates.
const ( RememberNone = "none" RememberRule = "rule" RememberMemory = "memory" )
Remember is what a rejection keeps of its reason (INV-18). It is a hint for the people who read it, nothing more.
const ( EventRequestCreated = "response.request.created" EventDecisionMade = "response.decision.made" EventActionExecuted = "response.action.executed" EventActionRolledBack = "response.action.rolled_back" EventBreakerTripped = "response.breaker.tripped" )
Events this module publishes, after the transaction that caused them committed (payloads: CONTRACT "Events").
const ( EventFindingCreated = "findings.finding.created" EventFindingStatusChanged = "findings.finding.status_changed" // EventFindingUrgency: an open finding rose into a more urgent layer (1 under attack here .. 4); a rise to 1 or 2 (its CVE joined an // exploited list, or an attack here named it) is a finding trigger, as a new exploited finding is. EventFindingUrgency = "findings.finding.urgency_raised" EventAssetDiscovered = "inventory.asset.discovered" EventHoneypotHit = "honeypot.hit.created" EventIocHit = "logs.ioc_hit.detected" EventPortOpened = "exposure.port.opened" )
Events this module listens to (it imports none of their producers; of logs only the stdlib-only address check of logs/signature):
findings.finding.created, findings.finding.status_changed (to confirmed) -> trigger finding findings.finding.urgency_raised (an open finding rose to exploited or under attack) -> trigger finding inventory.asset.discovered (a device that is not approved) -> trigger unknown_device honeypot.hit.created (a real hit; a test hit publishes nothing) -> trigger honeypot logs.ioc_hit.detected (logs L4) -> trigger ioc_connection (no event) logs.Counts read by PollLogs every minute -> trigger log_threshold exposure.port.opened (cmd/vedette, from exposure's own Diff) -> trigger new_port
const ( PlannerNoAI = "no_ai" // no usable AI profile for the job, or the ai module is off PlannerAIPaused = "ai_paused" // the quality breaker paused AI proposals (INV-15) )
Blocked of a run that asked nothing at all.
const ( OutcomeProposed = "proposed" // a request was sent to the inbox OutcomeNoted = "noted" // a suggestion or digest note, no request (confidence below 0.8, or the AI budget per hour/day) OutcomeRefused = "refused" // a gate of Propose refused every proposal of the plan OutcomeNotSent = "not_sent" // the plan was stored; its proposals were not sent (switch off, or the finding trigger not allowed) OutcomeNoAction = "no_action" // the plan was stored without a proposal OutcomePlanRefused = "plan_refused" // the AI's plan failed the checks and was not stored OutcomeAIFailed = "ai_failed" // the AI call failed OutcomeHasPlan = "has_plan" // a plan was written on an earlier run; one plan per finding OutcomeBackedOff = "backed_off" // waiting after failed or refused plans OutcomeLater = "later" // more findings than one run asks about )
Outcome of one finding on the last run.
const ( EvFinding = "finding" EvIocHit = "ioc_hit" EvConfigRead = "config_read" )
Evidence kinds a proposal may name.
const ( OutcomeRequest = "request" OutcomeSuggestion = "suggestion" OutcomeDigest = "digest" )
Outcomes of a proposal that was not refused.
const AIActor = "ai:response"
AIActor is the actor of everything an AI proposal does: the log, the audit and the request carry this name. It is not a user: no session, no role, and it can never approve anything (INV-1).
const EndSplit = "split"
EndSplit is the end reason of a request a device split withdrew: its finding moved to another device before anyone decided.
const ModuleID = "response"
ModuleID is the id of this module in the registry.
const RiskPhrase = "I ACCEPT THE RISK"
RiskPhrase is what an admin types to turn execution on (INV-7).
Variables ¶
var ErrLinkInvalid = errors.New("response: the approval link is not valid")
ErrLinkInvalid is what LinkTokens answers for a token that is malformed, has a wrong MAC or does not match the record it was found with. The caller answers 404 unknown for it and for a token without a record, so nothing can be probed.
var ErrLogsOff = errors.New("the Logs module is off")
ErrLogsOff is what a LogCounts adapter answers while the Logs module is off: no event, not a failure (SYS-5).
ErrPlanUnavailable is what a Planner answers when the AI cannot be used now (no usable profile, or this month's AI budget is used up). The run stops: nothing is wrong here, nothing was spent, and a used-up budget is not quiet: the ai module puts it on Home and sends it to the alert channels.
var ErrSendUnsure = errors.New("response: some messages may have gone out")
ErrSendUnsure is what a Notifier wraps an error in when the failure may have come after some messages had already gone out (notify could not write its record of them): the request log line then says so instead of claiming nobody was told.
var Migrations = mustSub(migrationFiles, "migrations/sqlite")
Migrations holds the SQLite migrations of the module. Pass it to store.Migrate(ctx, db, "response", response.Migrations).
var ParamLabel = map[ParamType]string{ PIP: "an IP address", PCIDR: "an address range", PDomain: "a domain", PPort: "a port number", PMAC: "a MAC address", PVLAN: "a VLAN number", PInterface: "a port or interface name", PID: "a whole number (for example a policy number)", PName: "a name of letters, numbers, . _ and - (up to 64)", PText: "a short plain-text value", }
ParamLabel says in plain words what a type expects.
var ParamTypes = []ParamType{PIP, PCIDR, PDomain, PPort, PMAC, PVLAN, PInterface, PID, PName, PText}
ParamTypes lists the types in the order the API shows them.
var RuntimeValues = []string{"seq", "previous_vlan", "found_id", "expiry_s", "timeout", "rules_before"}
RuntimeValues are read from the device or derived when an action runs (action-templates 1.1 precheck, 1.4 ttl). A rule never supplies them: they are not parameters, and a request shows them as <name>.
var System = Actor{ID: "system", Name: "Vedette", Email: "system", Via: ViaAuto}
System is the actor of what the box does by itself.
Functions ¶
func CheckValue ¶
CheckValue is the type check (layer 1). It returns the canonical spelling of v, which is what every later step uses, and false when v is not a value of the type. The type check never looks at the never-touch list: that is the planner's job, because the list changes while the check does not.
func Fill ¶
Fill puts checked values into the placeholders of text. A placeholder that is a runtime value shows as <name>. It returns an error, never a partial text, when a placeholder has no checked value (callers run CheckValues first), and for the cli transport when the result still holds a shell character.
func HasShellChar ¶
HasShellChar reports whether s contains a character of the never-allowed set.
func ValidAllowValue ¶
ValidAllowValue reports whether v can be an entry of the list; it returns the canonical (lower case) text.
func ValidateTpl ¶
ValidateTpl checks a template when it is saved (and again when it is loaded): only characters that cannot reach a shell, only typed placeholders or runtime values, a path that cannot leave the connection, a body that is JSON. It returns "" when the template is acceptable, otherwise a one-line reason in plain words.
Types ¶
type AIAction ¶
type AIAction struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Risk Risk `json:"risk"`
Reversible bool `json:"reversible"`
Available bool `json:"available"`
Params []AIParam `json:"params"`
// ConnectionID is the connection of a device action ("" for an action of the box): a read through it is the only read that can be
// evidence for the action. Not part of what is sent to the model as JSON.
ConnectionID string `json:"-"`
}
AIAction is an enabled catalog action with ai_may_propose, as the AI sees it: a name, what it does, how risky it is and the typed values it takes. Never a command, a path, a body or a template. Available is false when the action cannot run now (no connection, connection not ready): a proposal for it is refused 409.
type AIParam ¶
type AIParam struct {
Name string `json:"name"`
Type string `json:"type"`
Label string `json:"label"`
Pattern string `json:"pattern,omitempty"`
Min int `json:"min,omitempty"`
Max int `json:"max,omitempty"`
}
AIParam is one typed value of an action the AI may propose. Name is the key to send in params; Pattern or Min and Max say what the type accepts (the server checks the type again and the AI cannot widen it).
type ActionRequest ¶
type ActionRequest struct {
ID string `json:"id"`
Source string `json:"source"` // "rule", "ai", or "person" (asked from an incident)
ProposalID string `json:"proposal_id"`
RuleID *string `json:"rule_id"`
RuleName *string `json:"rule_name"`
Trigger *string `json:"trigger"`
TriggerSummary *string `json:"trigger_summary"`
FindingID *string `json:"finding_id"`
CVE *string `json:"cve"`
AssetID *string `json:"asset_id"`
AssetName string `json:"asset_name"`
Title string `json:"title"`
Items []RequestItem `json:"items"`
Risk Risk `json:"risk"`
Status Status `json:"status"`
RequestedAt string `json:"requested_at"`
ExpiresAt string `json:"expires_at"`
DecidedAt *string `json:"decided_at"`
RequiresApprovals int `json:"requires_approvals"`
TwoBecause *string `json:"two_because"`
Approvals []Approval `json:"approvals"`
SentTo []string `json:"sent_to"`
EmailLinks []EmailLink `json:"email_links"`
Note *string `json:"note"`
PreApproved bool `json:"pre_approved"`
AI *AiMeta `json:"ai"`
}
ActionRequest is a bundled request: one per rule run or AI proposal.
type Actor ¶
type Actor struct {
ID string
Name string
Email string
Via Via
Chat string // a decision made in chat: the sender's id on that platform (INV-3), part of the actor text in the log
}
Actor is the person (or system) behind a call.
type AiGates ¶
type AiGates struct {
Triggers []string `json:"triggers"`
BudgetHour int `json:"budget_hour"`
BudgetDay int `json:"budget_day"`
PausedAt *string `json:"paused_at"`
PausedReason *string `json:"paused_reason"`
}
AiGates are the gates of the AI requests (part 13b enforces them; the settings keep them).
type AiMeta ¶
type AiMeta struct {
Confidence float64 `json:"confidence"`
Evidence []Evidence `json:"evidence"`
Why string `json:"why"`
SecondCheck *SecondCheck `json:"second_check"`
InAppOnly bool `json:"in_app_only"`
}
AiMeta is what an AI request adds (part 13b); it is always null in this part.
type AiNote ¶
type AiNote struct {
ID string `json:"id"`
TS string `json:"ts"`
Kind string `json:"kind"`
Title string `json:"title"`
Why string `json:"why"`
Confidence float64 `json:"confidence"`
ActionID string `json:"action_id"`
Target string `json:"target"`
Evidence []Evidence `json:"evidence"`
}
AiNote is a suggestion or digest line the AI left instead of a request (Propose writes them, propose.go).
type AiQuality ¶
type AiQuality struct {
Decided int `json:"decided"`
Rejected int `json:"rejected"`
Paused bool `json:"paused"`
}
AiQuality is how the last decided AI requests went.
type AiState ¶
type AiState struct {
Gates AiGates `json:"gates"`
MinConfidence float64 `json:"min_confidence"`
RepeatDays int `json:"repeat_days"`
Usage AiUsage `json:"usage"`
Quality AiQuality `json:"quality"`
Notes []AiNote `json:"notes"`
Hints []Hint `json:"hints"`
}
AiState is GET /response/ai.
type AllowEntry ¶
AllowEntry is one line of the never-touch list.
type Approval ¶
type Approval struct {
UserID string `json:"user_id"`
Name string `json:"name"`
Email string `json:"email"`
Via Via `json:"via"`
At string `json:"at"`
Items []string `json:"items"`
}
Approval is one person's (or a pre-approved rule's) approval.
type ApprovalItem ¶
type ApprovalItem struct {
Title string `json:"title"`
Risk Risk `json:"risk"`
Change Change `json:"change"`
}
ApprovalItem is one action as the page of a link shows it.
type ApprovalMessage ¶
type ApprovalMessage struct {
RequestID string
Title string
What string
Risk Risk
InAppOnly bool
// NoChatButtons: no chat channel gets an Approve button, a code or a link-less shortcut, because the risk is high or the whole
// change does not fit one message. The text then says to open Vedette; notify only obeys.
NoChatButtons bool
Channels []string
Expires time.Time
}
ApprovalMessage is one approval request to send. What is plain text of at most 4 KiB. Channels are the channel types the request may go to (empty sends nothing). InAppOnly means every channel only says to open Vedette: no link, no button, no code.
type ApprovalView ¶
type ApprovalView struct {
State string `json:"state"` // ready, expired, used, decided, withdrawn or unknown
Title *string `json:"title"`
Items []ApprovalItem `json:"items"`
Approver *string `json:"approver"`
ExpiresAt *string `json:"expires_at"`
Status *Status `json:"status"`
RequiresApprovals *int `json:"requires_approvals"`
ApprovedSoFar *int `json:"approved_so_far"`
AIGenerated bool `json:"ai_generated"` // an AI proposed the request: the page shows the label
}
ApprovalView is GET /response/approve/{token}: what the link would change, never a decision. Every field about the content is empty or null unless State is "ready", so a wrong, used or expired link shows nothing of the request (spec approval-tokens.md 4.4).
type Approver ¶
type Approver struct {
UserID, Address string
Name string // the shown name of the address where the channel knows it (Zalo personal); "" elsewhere
}
Approver is a person who may approve on a channel, as the channel's saved list names them.
type BlockEntry ¶
type BlockEntry struct {
Value string `json:"value"`
Source string `json:"source"`
Reason string `json:"reason"`
AddedAt string `json:"added_at"`
ExpiresAt *string `json:"expires_at"`
}
BlockEntry is one line of the block list.
type BlocklistView ¶
type BlocklistView struct {
URL string `json:"url"`
TokenLast4 string `json:"token_last4"`
Entries []BlockEntry `json:"entries"`
LastFetch *LastFetch `json:"last_fetch"`
}
BlocklistView is GET /response/blocklist.
type BreakerEvent ¶
type BreakerEvent struct {
MaxPerHour int `json:"max_per_hour"`
TrippedAt string `json:"tripped_at"`
}
BreakerEvent is the payload of response.breaker.tripped.
type Bus ¶
type Bus interface {
Flush(ctx context.Context, o *events.Outbox)
Subscribe(name string, fn events.Handler) (unsubscribe func())
}
Bus is the event bus as this module needs it (core/events.Bus satisfies it).
type Catalog ¶
type Catalog struct {
Items []CatalogAction `json:"items"`
Connections []Connection `json:"connections"`
}
Catalog is GET /response/catalog.
type CatalogAction ¶
type CatalogAction struct {
ID string `json:"id"`
Builtin bool `json:"builtin"`
Pack string `json:"pack"`
Name string `json:"name"`
Description string `json:"description"`
ConnectionID *string `json:"connection_id"`
Connection *string `json:"connection"`
ConnectionKind *string `json:"connection_kind"`
Tool *string `json:"tool"`
RollbackTool *string `json:"rollback_tool"`
Run Tpl `json:"run"`
Rollback Tpl `json:"rollback"`
Verify Tpl `json:"verify"`
Precheck Tpl `json:"precheck"`
PrecheckRefuse []string `json:"precheck_refuse"`
PrecheckExpect string `json:"precheck_expect"`
Params []ParamType `json:"params"`
Risk Risk `json:"risk"`
Enabled bool `json:"enabled"`
Reversible bool `json:"reversible"`
AIMayPropose bool `json:"ai_may_propose"`
Device bool `json:"device"`
Available bool `json:"available"`
}
CatalogAction is an action of the catalog as the API shows it.
type CatalogInput ¶
type CatalogInput struct {
Name string `json:"name"`
Description string `json:"description"`
ConnectionID string `json:"connection_id"`
Tool *string `json:"tool"`
RollbackTool *string `json:"rollback_tool"`
Run Tpl `json:"run"`
Rollback Tpl `json:"rollback"`
Verify Tpl `json:"verify"`
// Precheck and PrecheckRefuse are optional: a read-only template that runs right before the action, and up to 5
// texts that make it refuse. Both or neither.
Precheck Tpl `json:"precheck"`
PrecheckRefuse []string `json:"precheck_refuse"`
PrecheckExpect string `json:"precheck_expect"`
Risk Risk `json:"risk"`
Enabled bool `json:"enabled"`
AIMayPropose bool `json:"ai_may_propose"`
}
CatalogInput is the body of POST /response/catalog.
type CatalogUpdate ¶
type CatalogUpdate struct {
Name *string `json:"name"`
Description *string `json:"description"`
ConnectionID *string `json:"connection_id"`
Tool *string `json:"tool"`
RollbackTool *string `json:"rollback_tool"`
Run *Tpl `json:"run"`
Rollback *Tpl `json:"rollback"`
Verify *Tpl `json:"verify"`
Precheck *Tpl `json:"precheck"`
PrecheckRefuse *[]string `json:"precheck_refuse"`
PrecheckExpect *string `json:"precheck_expect"`
Risk *Risk `json:"risk"`
Enabled *bool `json:"enabled"`
AIMayPropose *bool `json:"ai_may_propose"`
// Present records which keys the body carried, so "connection_id": null differs from a missing key.
Present map[string]bool `json:"-"`
}
CatalogUpdate is the body of PUT /response/catalog/{id}: every field optional (a built-in action takes only enabled, ai_may_propose and connection_id).
type Change ¶
type Change struct {
Before string `json:"before"`
After string `json:"after"`
CLI string `json:"cli"`
Rest *RestCall `json:"rest"`
Rollback RollbackChange `json:"rollback"`
Verify string `json:"verify"`
// What the approver also sees (review of 13b-2): the check that runs right before the change, with the texts that refuse it or
// that it must contain, and the text the read-back must (after the change) or must not (after the undo) contain.
Precheck string `json:"precheck"`
PrecheckRules string `json:"precheck_rules"`
VerifyRule string `json:"verify_rule"`
}
Change is the exact change of one action.
type ChannelView ¶
type ChannelView struct {
Type string `json:"type"`
Label string `json:"label"`
Ready bool `json:"ready"`
Approvers int `json:"approvers"`
Link bool `json:"link"`
Linked int `json:"linked"` // approvers who linked their address
Unlinked []string `json:"unlinked"` // names of the approvers who have not
}
ChannelView is an approval channel as the settings show it.
type ChatDecision ¶
type ChatDecision struct {
Channel string // slack, telegram or zalo-personal
ExternalID string
RequestID string
Approve bool
Code string
}
ChatDecision is what a listener of notify passes after it checked the platform: the sender's id on the platform, the request from the button (empty for a Zalo reply code, which names the request itself), the decision and the code that was typed (Zalo only).
type ChatOutcome ¶
type ChatOutcome struct {
RequestID string // the request that was decided (a Zalo reply code names it only through its record)
Status string
Approvals int
Required int
Message string
}
ChatOutcome says what was recorded. Status is "approved" (the approval that completes the request: it runs now), "pending" (an approval was recorded and another person must still approve) or "rejected". Approvals and Required are the counts after the decision. Message is a short private reply for the person who pressed the button. A refusal is an error (an *apierr.Error), never an outcome.
type CodeSent ¶
type CodeSent struct {
SentTo string `json:"sent_to"`
ResendAfter int `json:"resend_after"`
// Link is set only on a sendLink channel when nothing was sent because the person confirms in this session (LinkSender).
Link string `json:"link,omitempty"`
}
CodeSent answers Send code: the address masked (a chat ID as it is) and when a new code or link may be asked for.
type Condition ¶
type Condition struct {
Field string `json:"field"`
Op string `json:"op"`
Value string `json:"value"`
N *int `json:"n"`
WindowMin *int `json:"window_min"`
}
Condition is one IF test.
type Config ¶
type Config struct {
DB *store.DB
Secrets *secrets.Store
Audit *audit.Log
Users Users
Log *slog.Logger
Modules ModuleGate // nil = on (tests)
Bus Bus // nil = events are dropped
Directory Directory // nil = trigger events are logged and skipped
LogCounts LogCounts // nil = the log_threshold trigger has no events (#332)
Notifier Notifier // nil = no alert channel
Connections Connections // nil = no connection
Executor Executor // nil = no device can be changed
Webhooks Webhooks // nil = no webhook
Links LinkTokens // nil = no approval link can be checked: every link is unknown (404)
TwoStep TwoStep // nil = no code can be checked: a high-risk AI request cannot be approved (403 twofa_required)
Planner Planner // nil = no plan is ever written; ai_available is false (13b-11)
Mailer LinkMailer // nil = no link code can be mailed: an email approver cannot link (503 email_not_ready)
LinkSender LinkSender // nil = My account cannot ask for a new confirm link on a chat channel (400 chat_channel)
// Critical lists the open critical findings with their device, for the plan job. nil = no plan is asked for.
Critical func(ctx context.Context) ([]PlanTarget, error)
// Incidents reads an incident and its source for Respond; nil = no incident can be read (404).
Incidents IncidentReader
Evidence EvidencePorts // a nil port means no such evidence exists: an AI proposal naming it is refused (422 evidence_invalid)
Clock func() time.Time
// Zone is the organization's time zone the times in the status lines people read are written in (orgtime); nil: UTC.
Zone orgtime.Source
// BoxAddrs adds to the addresses of the network interfaces, which always count as never-touch and as forbidden webhook targets. An error
// means the set is not known (a configured host that has never answered, an unreadable honeypot record): the callers fail closed
// (errNeverTouchUnread: nothing is requested or run) instead of checking against a smaller set.
BoxAddrs func() ([]netip.Addr, error)
// MachineAddrs are the addresses of the machine Vedette runs on (vedette-host's report, the container's gateways, -hosts,
// VEDETTE_BIND_IP, the host aliases) with a known flag; webhook_call refuses them on Vedette's own ports only, and every target while
// they are not known. nil = none, known. SelfAddrs are more addresses that are Vedette itself (the honeypot's decoys), refused by
// webhook_call on every port; nil = none. Neither changes never-touch (BoxAddrs).
MachineAddrs func() ([]netip.Addr, bool)
SelfAddrs func() ([]netip.Addr, error) // an error (an unreadable decoy record) refuses every webhook: a decoy must never be a target
// BoxMACs adds to the MAC addresses of the network interfaces, which count as never-touch too: the decoys of the honeypot (macvlan links with
// MACs of their own) and the cards of the appliance. An error is as for BoxAddrs.
BoxMACs func() ([]string, error)
// HostInfra lists the network the box itself depends on, as vedette-host reports it: the default gateways of the kernel's IPv4 and IPv6
// routes with their MACs, the DNS servers in use (a DHCP lease's too) and the gateway and DNS servers of the management card's saved
// configuration. They count as never-touch without being listed (INV-10):
// an automated ban on the gateway or the resolver would cut the box off with the rest of the network. An error is as for BoxAddrs
// (fail closed). nil = none known (no host: a container-only box, whose own route is the container bridge).
HostInfra func() ([]HostInfra, error)
// BaseURL is the address people open Vedette at (https://192.168.10.2:8443), asked at every use (the Box address of
// Settings → Box network). It is the start of the block list address; nil or "" = the address is shown from /api/v1 on.
BaseURL func() string
}
Config wires a Service. DB, Secrets, Audit, Users and Log are required.
type Connection ¶
type Connection struct {
ID string `json:"id"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Kind string `json:"kind"`
WriteTools []string `json:"write_tools"`
ReadOnly bool `json:"read_only"`
}
Connection is a connection to a customer device, as the catalog shows it. Part 13b owns the connections (ai_connectors); this part reads them through the Connections port.
type ConnectionInfo ¶
type ConnectionInfo struct {
Connection
Target string // address the API paths are under, for the exact call a request shows
// UpdatedAt changes whenever the connection is edited (address, credentials, tools). With the id, kind and Target it makes the
// fingerprint stored in every request item (INV-9).
UpdatedAt string
// Allow is the allow-list of the connection (conn.Connection.Allow). nil = not known (a test double): the address check is skipped.
Allow []string
// NotReady is why a request cannot use the connection yet (core/conn NotReady: off, never tested, last test failed, SSH host key
// not pinned), or "" when it can. An action on a connection that is not ready is not available.
NotReady string
}
ConnectionInfo is a connection to a customer device (ai_connectors, part 13b).
type Connections ¶
type Connections interface {
List(ctx context.Context) ([]ConnectionInfo, error)
}
Connections lists the connections to devices. nil = none exist.
type DecisionEvent ¶
type DecisionEvent struct {
RequestID string `json:"request_id"`
Decision string `json:"decision"`
By string `json:"by"`
Final bool `json:"final"`
}
DecisionEvent is the payload of response.decision.made. Decision is approved, rejected, expired or cancelled; Final is false for the first of two approvals.
type Det ¶
type Det struct {
ID string
Trigger string
TS string
Summary string
Fields map[string]string
DeviceKind string
AssetID string
FindingID string
CVE string
}
Det is an event a trigger watches for.
type DeviceInfo ¶
type DeviceInfo struct {
ID string
Name string
IP string
MAC string
Vendor string
Kind string
Approved bool
Seen time.Time
}
DeviceInfo is a device of the inventory.
type DeviceResult ¶
type DeviceResult struct {
Status StepStatus
Detail string
Output string
}
DeviceResult is what a step did. Output is what a read step (precheck, verify) printed: it lives in memory only, to be compared with the check texts and dropped (INV-22); it is never stored, logged or returned by the API. Detail is one cleaned line.
type DeviceStep ¶
type DeviceStep struct {
ConnectionID string
ConnFP string // conn.Fingerprint of the connection when the request was made: the executor refuses a connection that is not that version
// ByIdentity holds the step to ConnIdentity (conn.Identity: id, kind, address) instead of ConnFP: an undo and the read-backs that settle an
// unclear outcome must survive a rotated token or a renewed pin.
ByIdentity bool
ConnIdentity string
Phase string
Tool string // MCP: the write tool to call
Lines []string // SSH: the command lines, one at a time
Method string // API kinds
URL string
Body string
Headers map[string]string
Args json.RawMessage // MCP: the typed arguments, a JSON object
RequestID string
ItemID string
}
DeviceStep is what an Executor is asked to do: one step of one item, exactly as it was rendered when the request was made (itemRec.Exec) and approved. An Executor never sees text that came from a client. Phase is "precheck", "run", "rollback" or "verify"; precheck and verify only read.
type Directory ¶
type Directory interface {
// DevicesOfKind lists the inventory devices of the given kinds (router, firewall: the never-touch gateways). An error means the
// inventory cannot be read: the callers refuse the action instead of going on with fewer entries.
DevicesOfKind(ctx context.Context, kinds ...string) ([]DeviceInfo, error)
Device(ctx context.Context, id string) (DeviceInfo, bool, error)
Finding(ctx context.Context, id string) (FindingInfo, bool, error)
}
Directory resolves the ids an event carries. cmd/vedette adapts inventory and findings; the module never imports them.
type DraftParam ¶
type DraftParam struct{ Name, Value string }
DraftParam is one value the AI chose for a parameter of an action.
type DraftStep ¶
type DraftStep struct {
Kind, Title, Detail string // Kind is contain, check or patch
ActionID string
Params []DraftParam
Confidence float64
Evidence []string
}
DraftStep is one step the AI drafted. ActionID and Params are empty for a step that only advises. Nothing else about a proposal comes from the AI: no command, no path, no body, no undo time. Confidence (0 to 1) and Evidence (ids of reads the box made, listed to the AI) are used only when the proposal is sent through Propose; they are not stored with the plan (INV-14e).
type EmailLink ¶
type EmailLink struct {
Approver string `json:"approver"`
Address string `json:"address"`
URL string `json:"url"`
ExpiresAt string `json:"expires_at"`
Used bool `json:"used"`
}
EmailLink is a preview-build field: the real build always answers an empty list (FORBID-4).
type EventView ¶
type EventView struct {
ID string `json:"id"`
Trigger string `json:"trigger"`
TS string `json:"ts"`
Summary string `json:"summary"`
Fields map[string]string `json:"fields"`
DeviceKind *string `json:"device_kind"`
HandledBy []string `json:"handled_by"`
}
EventView is an event a trigger watches for.
type Evidence ¶
type Evidence struct {
Kind string `json:"kind"`
ID string `json:"id"`
Summary string `json:"summary"`
}
Evidence of an AI request (part 13b).
type EvidencePorts ¶
type EvidencePorts struct {
// IocHit finds a known-bad connection by id (logs). Nil until that module offers a read-only lookup.
IocHit func(ctx context.Context, id string) (EvidenceRef, bool, error)
// ConfigRead finds a read the box made through a connection, by its read record: the ai module's ai_read, at most 24 hours old;
// an existing read tool proves nothing. Nil (a binary without the ai module) = no read is evidence.
ConfigRead func(ctx context.Context, id string) (EvidenceRef, bool, error)
}
EvidencePorts look up evidence the module does not own. A nil port, or a lookup that says not found, means the evidence does not exist: the proposal is refused (422 evidence_invalid). A finding is looked up through Directory.
type EvidenceRef ¶
type EvidenceRef struct {
// ID is the canonical id of the object when it differs from the id asked for; "" = the id asked for.
ID string
Summary string
Relates []string
// Connection is, for a connection read, the id of the connection it went through. A read relates to an action only when this is the
// connection of that action; "" = it relates to nothing.
Connection string
}
EvidenceRef is a piece of evidence a port found: what it says in one line, and the addresses, ports and names it is about (the target of an action must be one of them, compared by type).
type ExecutedEvent ¶
type ExecutedEvent struct {
RequestID string `json:"request_id"`
ItemID string `json:"item_id"`
ActionID string `json:"action_id"`
Device bool `json:"device"` // false for a box action (block list, message, webhook)
}
ExecutedEvent is the payload of response.action.executed: one item ran and was recorded as executed.
type Executor ¶
type Executor interface {
Execute(ctx context.Context, s DeviceStep) (DeviceResult, error)
}
Executor carries a step out on a device (cmd/vedette wires core/conn/write, FORBID-1). A nil Executor means no device can be changed: such items fail and nothing is sent. Execute must respect ctx (it carries the item's deadline): when ctx ends the service stops waiting, records "state unknown" and lets go of the device-step lock, but it cannot stop an Execute that ignores ctx from finishing later. A returned error means the step could not be tried at all.
type FindingInfo ¶
type FindingInfo struct {
ID string
AssetID string
CVE string
Severity string
Status string // suspected, confirmed, ...
KEV bool
}
FindingInfo is a finding.
type Hint ¶
type Hint struct {
ID string `json:"id"`
TS string `json:"ts"`
Kind string `json:"kind"` // rule or memory
Text string `json:"text"`
FromRequest string `json:"from_request"`
}
Hint is a rejection reason kept as advice (INV-18). Nothing reads it to change a rule, a prompt or a decision.
type HostInfra ¶
type HostInfra struct {
Addr netip.Addr
Kind string // "gateway" or "dns"
// MAC is a gateway's link-layer address from the kernel's neighbour table, "" when not known. It is never-touch too, so
// an action that names only a MAC (a switch quarantine, an event with no address) cannot reach the gateway.
MAC string
}
HostInfra is one address of the network the box depends on (Config.HostInfra).
type Identity ¶
type Identity struct {
Channel string `json:"channel"`
Label string `json:"label"`
Address string `json:"address"`
Name string `json:"name,omitempty"` // the shown name of the address (Zalo personal)
Linked bool `json:"linked"`
LinkedAt *string `json:"linked_at"`
Method string `json:"method"` // email_code, send_code (a confirm link sent to the chat ID), or unavailable
CodeWaiting bool `json:"code_waiting"`
}
Identity is one approval channel whose list names the person, as My account shows it.
type IncidentInfo ¶
type IncidentInfo struct {
ID, Kind, Title, Action string
Status string // new, acknowledged or resolved: a resolved incident offers nothing
SourceIP string
AssetID string // the inventory device of the source, "" when not known
HitKind string // a trap's hit: service, token or scan
// Unconfirmed: the source may be forged. A scan hit can be made from attempts that completed no handshake, and a UDP trap hit
// from one datagram; it counts as confirmed only when the same source also completed a connection to a trap
// service (a TCP service hit) near it. Nothing is offered for an unconfirmed source.
Unconfirmed bool
}
IncidentInfo is what response needs of an incident: the notify incident, and for a trap the source of its hit (honeypot), joined by cmd/vedette. SourceIP is "" when the incident names no single address (another kind, a test hit, an unreadable hit).
type IncidentOption ¶
type IncidentOption struct {
ActionID string `json:"action_id"`
Name string `json:"name"`
Title string `json:"title"`
Connection *string `json:"connection"`
Device bool `json:"device"`
Risk Risk `json:"risk"`
TTLMin int `json:"ttl_min"`
Ready bool `json:"ready"`
Why *string `json:"why"`
Requested bool `json:"requested"`
}
IncidentOption is one action that can be asked for the source.
type IncidentPanel ¶
type IncidentPanel struct {
Incident IncidentRef `json:"incident"`
Note *string `json:"note"` // why nothing can be asked for a source that is there: resolved (no options), or unconfirmed
Source *IncidentSource `json:"source"`
Options []IncidentOption `json:"options"`
Execution bool `json:"execution"`
}
IncidentPanel is GET /response/incidents/{id} (contract.ts IncidentPanel).
type IncidentReader ¶
type IncidentReader interface {
Incident(ctx context.Context, id string) (IncidentInfo, bool, error)
}
IncidentReader reads one incident (Config.Incidents). ok is false for an unknown id or while the notify module is off.
type IncidentRef ¶
type IncidentRef struct {
ID string `json:"id"`
Kind string `json:"kind"`
Title string `json:"title"`
Action string `json:"action"`
Status string `json:"status"`
}
IncidentRef names the incident in the panel.
type IncidentSource ¶
type IncidentSource struct {
IP string `json:"ip"`
Device *string `json:"device"`
AssetID *string `json:"asset_id"`
Scope string `json:"scope"` // "lan" (the block list never publishes it) or "public"
}
IncidentSource is the address the response acts on, read by the server from the incident.
type ItemStatus ¶
type ItemStatus string
ItemStatus is the status of one action of a request.
const ( ItemPending ItemStatus = "pending" ItemSkipped ItemStatus = "skipped" ItemExecuted ItemStatus = "executed" ItemFailed ItemStatus = "failed" ItemRolledBack ItemStatus = "rolled_back" )
The item statuses.
type LinkBinding ¶
LinkBinding is what a link is bound to: the request, the person, the channel and the moment it ends.
type LinkMailer ¶
type LinkMailer interface {
Available(ctx context.Context) bool
SendLinkCode(ctx context.Context, to, code string) error
}
LinkMailer mails a link code to an address (cmd/vedette adapts notify's code mailer, the SMTP path of the sign-in codes). nil = no code can be mailed: Send code answers 503 email_not_ready.
type LinkRecord ¶
type LinkRecord struct {
ID []byte
RequestID string
UserID string
Channel string
Address string
KeyID string
ExpiresAt time.Time
}
LinkRecord is a link notify made, as it is stored: ID is the token id (the 16 bytes), Address where the link was sent.
type LinkSender ¶
type LinkSender interface {
SendApproverLink(ctx context.Context, actor, channel, userID string) (link string, err error)
}
LinkSender asks notify to send the person's own listed chat ID a new confirm link (Send again in My account on a sendLink channel; cmd/vedette adapts notify). actor is the signed-in person's email (audit). link is set only when notify sends nothing because the person confirms in this session (the box's own Zalo account): the page to open. The token comes from ChatLinkToken, so its limits hold.
type LinkTokens ¶
type LinkTokens interface {
// ID returns the 16 bytes of the token id after a check of the form only (it proves nothing about who made the token).
ID(token string) ([]byte, error)
// Verify checks the MAC against the binding read from the stored record and the key the record names. It writes and burns nothing.
// ErrLinkInvalid for a token that does not match; any other error means the box could not check.
Verify(ctx context.Context, token string, b LinkBinding, keyID string) error
}
LinkTokens checks approval links (cmd/vedette wires notify.VerifyApprovalLink). A nil LinkTokens means no link can be checked: every link is unknown.
type LogAddress ¶
LogAddress is a remote address and how many lines of one signature it sent (logs.AddressCount).
type LogCounts ¶
type LogCounts interface {
Sources(ctx context.Context) ([]LogSource, error)
Counts(ctx context.Context, sourceID, signature string, window time.Duration) (int, error)
TopAddresses(ctx context.Context, sourceID, signature string, window time.Duration, n int) ([]LogAddress, error)
}
LogCounts is the read port of the Logs module for the log_threshold trigger; cmd/vedette adapts logs.Service. The counts are per declared log source and signature (5-minute buckets); TopAddresses answers the remote addresses behind them, most first, never the log sender, the box, its gateway or a decoy (logs CONTRACT), and as lower bounds. Sources answers no source and no error while the Logs module is off; an error is a failure, logged, and no event this round.
type LogEntry ¶
type LogEntry struct {
ID string `json:"id"`
TS string `json:"ts"`
Kind string `json:"kind"`
Actor string `json:"actor"`
Detail string `json:"detail"`
PrevHash string `json:"prev_hash"`
Hash string `json:"hash"`
}
LogEntry is one line of the response log.
type LogKind ¶
type LogKind string
LogKind is the kind of a resp_log line (INV-19).
const ( LogRuleFired LogKind = "rule_fired" LogProposal LogKind = "proposal" LogRequest LogKind = "request" LogApproved LogKind = "approved" LogRejected LogKind = "rejected" LogExecuted LogKind = "executed" LogRolledBack LogKind = "rolled_back" LogTTLRemoved LogKind = "ttl_removed" LogRefused LogKind = "refused" LogExpired LogKind = "expired" LogFailed LogKind = "failed" LogSettings LogKind = "settings" LogEmergencyStop LogKind = "emergency_stop" LogBlocklistToken LogKind = "blocklist_token" LogDryRun LogKind = "dry_run" LogSimulated LogKind = "simulated" LogDeduped LogKind = "deduped" LogBreaker LogKind = "breaker" LogAINote LogKind = "ai_note" )
The log kinds.
type Metrics ¶
type Metrics struct {
AI Stat `json:"ai"`
Rules Stat `json:"rules"`
Suggestions int `json:"suggestions"`
Digested int `json:"digested"`
Rejected []RejectedRow `json:"rejected"`
}
Metrics is GET /response/metrics.
type ModuleGate ¶
ModuleGate says whether a module is on (modreg.Registry satisfies it).
type Notifier ¶
type Notifier interface {
Channels(ctx context.Context) ([]NotifyChannel, error)
// Message sends one short text to the alert channels. It never changes a device.
Message(ctx context.Context, id, title, text string) error
// Approvers lists the people who may approve on a channel (its saved list), for the check made again when a link is used (INV-3).
Approvers(ctx context.Context, channel string) ([]Approver, error)
// RequestApproval sends an approval request to the approvers of the channels in m.Channels and returns the labels of the channels that
// received it (POST-5). It is called after the request committed, with a 60 second budget, and its error never fails the request.
RequestApproval(ctx context.Context, m ApprovalMessage) (sentTo []string, err error)
}
Notifier is the notify module as this module needs it. A nil Notifier means no alert channel exists: messages are refused with a plain reason and the settings list no channel.
type NotifyChannel ¶
type NotifyChannel struct {
Type string // slack, telegram, zalo, zalo-personal, email, webhook
Label string
Configured bool
Enabled bool
Approvals bool // the channel takes approvals
Approvers int
}
NotifyChannel is an alert channel as the settings and the approval flow need it.
type ParamType ¶
type ParamType string
ParamType is the type of a placeholder.
const ( PIP ParamType = "ip" PCIDR ParamType = "cidr" PDomain ParamType = "domain" PPort ParamType = "port" PMAC ParamType = "mac" PVLAN ParamType = "vlan" PInterface ParamType = "interface" PID ParamType = "id" PName ParamType = "name" PText ParamType = "text" )
The placeholder types of a template.
type Plan ¶
type Plan struct {
ID string `json:"id"`
FindingID string `json:"finding_id"`
CVE string `json:"cve"`
AssetID string `json:"asset_id"`
AssetName string `json:"asset_name"`
GeneratedAt string `json:"generated_at"`
Model string `json:"model"`
Profile string `json:"profile"`
Path string `json:"path"`
Reads []PlanRead `json:"reads"`
Steps []PlanStep `json:"steps"`
SentTo []string `json:"sent_to"`
}
Plan is an AI response plan for a finding.
type PlanAsk ¶
type PlanAsk struct {
Target PlanTarget
Actions []AIAction
}
PlanAsk is one call of the Planner: the finding, and the actions the AI may propose (AIActions that are available now).
type PlanDraft ¶
PlanDraft is the AI's answer: the steps, and the model and profile that wrote them (shown on the plan).
type PlanList ¶
type PlanList struct {
Items []Plan `json:"items"`
AIAvailable bool `json:"ai_available"`
Execution bool `json:"execution"`
Planner PlannerStatus `json:"planner"`
}
PlanList is GET /response/plans.
type PlanRead ¶
type PlanRead struct {
Connection string `json:"connection"`
Tool string `json:"tool"`
Summary string `json:"summary"`
}
PlanRead is one read the AI made.
type PlanStep ¶
type PlanStep struct {
Kind string `json:"kind"`
Title string `json:"title"`
Detail string `json:"detail"`
Proposal *Proposal `json:"proposal"`
}
PlanStep is one step of a plan.
type PlanTarget ¶
type PlanTarget struct {
FindingID, CVE, AssetID, AssetName, AssetIP, AssetKind string
// Urgency is the status code of the finding's urgency layer (under_attack, exploited, public_exploit, critical_edge,
// update_recommended); "" when not known.
Urgency string
}
PlanTarget is an open critical finding and the device it is on: what the AI is asked about.
type Planner ¶
type Planner interface {
Available(ctx context.Context) bool
Plan(ctx context.Context, a PlanAsk) (PlanDraft, error)
Proposed(ctx context.Context, t PlanTarget, sent []SentProposal)
}
Planner is the ai module as this module needs it (cmd/vedette adapts ai.Service.RunJob for the job response-plan). Available is false while the ai module is off or no profile is assigned and allowed for the job; then the job asks nothing. Plan answers ErrPlanUnavailable when the AI cannot be used after all. Proposed is told what the job sent through Propose for a stored plan and what came of it, for the activity log of the ai module; it is not called when nothing was sent. A nil Planner means no plan is ever written; everything else in this module works.
type PlannerFinding ¶
type PlannerFinding struct {
FindingID string `json:"finding_id"`
CVE string `json:"cve"`
AssetName string `json:"asset_name"`
Outcome string `json:"outcome"`
Reason string `json:"reason"`
}
PlannerFinding is what happened to one open critical finding on the last run.
type PlannerStatus ¶
type PlannerStatus struct {
RanAt *string `json:"ran_at"`
Blocked string `json:"blocked"`
Sending bool `json:"sending"`
Considered int `json:"considered"`
Asked int `json:"asked"`
Proposed int `json:"proposed"`
Findings []PlannerFinding `json:"findings"`
}
PlannerStatus is the planner of GET /response/plans.
type PortOpenedEvent ¶
type PortOpenedEvent struct {
TargetID string `json:"target_id"`
Date string `json:"date"` // the scan day that saw it, YYYY-MM-DD
IP string `json:"ip"`
Port int `json:"port"`
Service string `json:"service"`
// Service stays nmap's or the port list's name (rules compare it, "service eq sip"); Label is the
// person's wording for the summary ("probably SIP", "service not identified"), Identified how the name was read: probed (a
// probe's answer or the page's Server header), port (only the port number: not confirmed), none; "" from an older producer.
Label string `json:"label,omitempty"`
Identified string `json:"identified,omitempty"`
}
PortOpenedEvent is the payload of exposure.port.opened: one port that a scan of an exposure target saw open and the previous scan day of that target did not. cmd/vedette publishes it from exposure's own Diff; the exposure module does not know the name.
type Proposal ¶
type Proposal struct {
ID string `json:"id"`
Title string `json:"title"`
ToolKey string `json:"tool_key"`
Tool string `json:"tool"`
ConnectorID string `json:"connector_id"`
Connection string `json:"connection"`
AssetID string `json:"asset_id"`
AssetName string `json:"asset_name"`
Change Change `json:"change"`
State string `json:"state"`
RequestID *string `json:"request_id"`
}
Proposal is an AI plan proposal (part 13b writes plans; part 1 reads them).
type ProposeBody ¶
type ProposeBody struct {
Trigger string `json:"trigger"`
ActionID string `json:"action_id"`
Params map[string]string `json:"params"`
Confidence float64 `json:"confidence"`
Evidence []ProposedEvidence `json:"evidence"`
Why string `json:"why"`
}
ProposeBody is what the AI sends. Every field is a name or a typed value; the change itself is rendered by the server from the catalog templates, exactly as for a rule.
type ProposeResult ¶
type ProposeResult struct {
Outcome string `json:"outcome"`
Note string `json:"note"`
Request *ProposedRequest `json:"request"`
}
ProposeResult is what Propose answers when the proposal was not refused.
type ProposedEvidence ¶
ProposedEvidence names one piece of evidence: the kind and the id the server looks up. The AI never supplies the summary.
type ProposedRequest ¶
type ProposedRequest struct {
ID string `json:"id"`
Status Status `json:"status"`
Risk Risk `json:"risk"`
Title string `json:"title"`
RequiresApprovals int `json:"requires_approvals"`
ExpiresAt string `json:"expires_at"`
InAppOnly bool `json:"in_app_only"`
}
ProposedRequest is all the AI gets back about the request it caused: where to find it and how risky it is, never the rendered change, the address, the body or the headers. The people who approve see the rest in the app.
type RejectedRow ¶
type RejectedRow struct {
ID string `json:"id"`
Title string `json:"title"`
Source string `json:"source"`
Reason string `json:"reason"`
At string `json:"at"`
}
RejectedRow is a rejected request in the metrics.
type ReplyCodeRecord ¶
type ReplyCodeRecord struct {
RequestID string
UserID string
Address string
Approve bool
CodeHash string
ExpiresAt time.Time
}
ReplyCodeRecord is one reply code of one approver for one request: CodeHash is the lowercase hex hash of spec 7.1 (the code itself never reaches this module).
type RequestEvent ¶
type RequestEvent struct {
RequestID string `json:"request_id"`
Source string `json:"source"`
Title string `json:"title"`
Risk string `json:"risk"`
Items int `json:"items"`
ExpiresAt string `json:"expires_at"`
Approvals int `json:"approvals"` // how many different approvers it needs
}
RequestEvent is the payload of response.request.created: an approval request exists (notify may send it to the approvers, part 13b).
type RequestItem ¶
type RequestItem struct {
ID string `json:"id"`
ActionID string `json:"action_id"`
Title string `json:"title"`
Risk Risk `json:"risk"`
Reversible bool `json:"reversible"`
ConnectorID *string `json:"connector_id"`
Connection *string `json:"connection"`
Tool string `json:"tool"`
Targets int `json:"targets"`
Change Change `json:"change"`
TTLMin *int `json:"ttl_min"`
Status ItemStatus `json:"status"`
ExecutedAt *string `json:"executed_at"`
RemoveAt *string `json:"remove_at"`
RolledBackAt *string `json:"rolled_back_at"`
Result *string `json:"result"`
Verified *Verified `json:"verified"`
// StateUnknown marks a failed item whose step was sent and whose outcome is not known (a time-out after it left, an answer that does not
// say "refused", a crash): the change may be in force on the device, so the connection cannot be deleted (ChangesInForce) and a person
// can undo it to be sure. The sweep reads the device back when the action has a read-back text and settles it either way.
StateUnknown bool `json:"state_unknown"`
}
RequestItem is one action of a request.
type ResponseHandlers ¶
type ResponseHandlers struct {
// contains filtered or unexported fields
}
ResponseHandlers implements the operations of the response module that part 1 builds. Embed it in the composite handler of cmd/vedette. The role of each route comes from the route table, so nothing here checks roles.
GET and POST /response/approve/{token} (public: the link is the credential, 13b-7) are implemented here too; they read no session.
The three preview-only operations, POST /response/rules/run, POST /response/actions/{id}/chat-decision and POST /response/ai/proposals, are implemented only to answer 404 like an unknown route: they must not exist in the real build (FORBID-5).
ogen generates a separate struct per operation for the same schema, so answers are built from the domain types (their JSON names are the wire names) and decoded into the generated ones; request bodies go the other way.
func NewResponseHandlers ¶
func NewResponseHandlers(svc *Service) *ResponseHandlers
NewResponseHandlers returns the handlers of the module.
func (*ResponseHandlers) ResponseDeleteResponseCatalogID ¶
func (h *ResponseHandlers) ResponseDeleteResponseCatalogID(ctx context.Context, params oas.ResponseDeleteResponseCatalogIDParams) error
ResponseDeleteResponseCatalogID implements DELETE /response/catalog/{id} (admin).
func (*ResponseHandlers) ResponseDeleteResponseMeIdentitiesChannel ¶
func (h *ResponseHandlers) ResponseDeleteResponseMeIdentitiesChannel(ctx context.Context, params oas.ResponseDeleteResponseMeIdentitiesChannelParams) error
ResponseDeleteResponseMeIdentitiesChannel implements DELETE /response/me/identities/{channel} (operator).
func (*ResponseHandlers) ResponseDeleteResponseRulesID ¶
func (h *ResponseHandlers) ResponseDeleteResponseRulesID(ctx context.Context, params oas.ResponseDeleteResponseRulesIDParams) error
ResponseDeleteResponseRulesID implements DELETE /response/rules/{id} (admin).
func (*ResponseHandlers) ResponseGetResponseActions ¶
func (h *ResponseHandlers) ResponseGetResponseActions(ctx context.Context) (*oas.ResponseGetResponseActionsOK, error)
ResponseGetResponseActions implements GET /response/actions (viewer).
func (*ResponseHandlers) ResponseGetResponseAi ¶
func (h *ResponseHandlers) ResponseGetResponseAi(ctx context.Context) (*oas.ResponseGetResponseAiOK, error)
ResponseGetResponseAi implements GET /response/ai (viewer).
func (*ResponseHandlers) ResponseGetResponseAllowlist ¶
func (h *ResponseHandlers) ResponseGetResponseAllowlist(ctx context.Context) (*oas.ResponseGetResponseAllowlistOK, error)
ResponseGetResponseAllowlist implements GET /response/allowlist (viewer).
func (*ResponseHandlers) ResponseGetResponseApproveToken ¶
func (h *ResponseHandlers) ResponseGetResponseApproveToken(ctx context.Context, params oas.ResponseGetResponseApproveTokenParams) (*oas.ResponseGetResponseApproveTokenOK, error)
ResponseGetResponseApproveToken implements GET /response/approve/{token} (public). It only reads.
func (*ResponseHandlers) ResponseGetResponseBlocklist ¶
func (h *ResponseHandlers) ResponseGetResponseBlocklist(ctx context.Context) (*oas.ResponseGetResponseBlocklistOK, error)
ResponseGetResponseBlocklist implements GET /response/blocklist (admin).
func (*ResponseHandlers) ResponseGetResponseBlocklistTokenTxt ¶
func (h *ResponseHandlers) ResponseGetResponseBlocklistTokenTxt(ctx context.Context, params oas.ResponseGetResponseBlocklistTokenTxtParams) (oas.ResponseGetResponseBlocklistTokenTxtOK, error)
ResponseGetResponseBlocklistTokenTxt implements GET /response/blocklist/{token}.txt (public: the token is the credential). The contract declares text/plain; charset=utf-8 (response 'text', blocklist-format.md §4): one address per line.
func (*ResponseHandlers) ResponseGetResponseCatalog ¶
func (h *ResponseHandlers) ResponseGetResponseCatalog(ctx context.Context) (*oas.ResponseGetResponseCatalogOK, error)
ResponseGetResponseCatalog implements GET /response/catalog (viewer).
func (*ResponseHandlers) ResponseGetResponseEvents ¶
func (h *ResponseHandlers) ResponseGetResponseEvents(ctx context.Context) (*oas.ResponseGetResponseEventsOK, error)
ResponseGetResponseEvents implements GET /response/events (viewer).
func (*ResponseHandlers) ResponseGetResponseIncidentsID ¶
func (h *ResponseHandlers) ResponseGetResponseIncidentsID(ctx context.Context, params oas.ResponseGetResponseIncidentsIDParams) (*oas.ResponseGetResponseIncidentsIDOK, error)
ResponseGetResponseIncidentsID implements GET /response/incidents/{id} (viewer).
func (*ResponseHandlers) ResponseGetResponseLog ¶
func (h *ResponseHandlers) ResponseGetResponseLog(ctx context.Context) (*oas.ResponseGetResponseLogOK, error)
ResponseGetResponseLog implements GET /response/log (operator).
func (*ResponseHandlers) ResponseGetResponseMeIdentities ¶
func (h *ResponseHandlers) ResponseGetResponseMeIdentities(ctx context.Context) (*oas.ResponseGetResponseMeIdentitiesOK, error)
ResponseGetResponseMeIdentities implements GET /response/me/identities (operator).
func (*ResponseHandlers) ResponseGetResponseMetrics ¶
func (h *ResponseHandlers) ResponseGetResponseMetrics(ctx context.Context) (*oas.ResponseGetResponseMetricsOK, error)
ResponseGetResponseMetrics implements GET /response/metrics (viewer).
func (*ResponseHandlers) ResponseGetResponsePlans ¶
func (h *ResponseHandlers) ResponseGetResponsePlans(ctx context.Context, params oas.ResponseGetResponsePlansParams) (*oas.ResponseGetResponsePlansOK, error)
ResponseGetResponsePlans implements GET /response/plans (viewer).
func (*ResponseHandlers) ResponseGetResponseRules ¶
func (h *ResponseHandlers) ResponseGetResponseRules(ctx context.Context) (*oas.ResponseGetResponseRulesOK, error)
ResponseGetResponseRules implements GET /response/rules (viewer).
func (*ResponseHandlers) ResponseGetResponseSettings ¶
func (h *ResponseHandlers) ResponseGetResponseSettings(ctx context.Context) (*oas.ResponseGetResponseSettingsOK, error)
ResponseGetResponseSettings implements GET /response/settings (admin).
func (*ResponseHandlers) ResponseGetResponseTemplates ¶
func (h *ResponseHandlers) ResponseGetResponseTemplates(ctx context.Context) (*oas.ResponseGetResponseTemplatesOK, error)
ResponseGetResponseTemplates implements GET /response/templates (viewer).
func (*ResponseHandlers) ResponseGetResponseTriggers ¶
func (h *ResponseHandlers) ResponseGetResponseTriggers(ctx context.Context) (*oas.ResponseGetResponseTriggersOK, error)
ResponseGetResponseTriggers implements GET /response/triggers (viewer).
func (*ResponseHandlers) ResponsePostResponseActionsIDApprove ¶
func (h *ResponseHandlers) ResponsePostResponseActionsIDApprove(ctx context.Context, req *oas.ResponsePostResponseActionsIDApproveReq, params oas.ResponsePostResponseActionsIDApproveParams) (*oas.ResponsePostResponseActionsIDApproveOK, error)
ResponsePostResponseActionsIDApprove implements POST /response/actions/{id}/approve (operator).
func (*ResponseHandlers) ResponsePostResponseActionsIDChatDecision ¶
func (h *ResponseHandlers) ResponsePostResponseActionsIDChatDecision(context.Context, *oas.ResponsePostResponseActionsIDChatDecisionReq, oas.ResponsePostResponseActionsIDChatDecisionParams) (*oas.ResponsePostResponseActionsIDChatDecisionOK, error)
ResponsePostResponseActionsIDChatDecision answers 404: the operation exists only in the preview build (FORBID-5).
func (*ResponseHandlers) ResponsePostResponseActionsIDReject ¶
func (h *ResponseHandlers) ResponsePostResponseActionsIDReject(ctx context.Context, req *oas.ResponsePostResponseActionsIDRejectReq, params oas.ResponsePostResponseActionsIDRejectParams) (*oas.ResponsePostResponseActionsIDRejectOK, error)
ResponsePostResponseActionsIDReject implements POST /response/actions/{id}/reject (operator).
func (*ResponseHandlers) ResponsePostResponseActionsIDRollback ¶
func (h *ResponseHandlers) ResponsePostResponseActionsIDRollback(ctx context.Context, params oas.ResponsePostResponseActionsIDRollbackParams) (*oas.ResponsePostResponseActionsIDRollbackOK, error)
ResponsePostResponseActionsIDRollback implements POST /response/actions/{id}/rollback (operator).
func (*ResponseHandlers) ResponsePostResponseAiProposals ¶
func (h *ResponseHandlers) ResponsePostResponseAiProposals(context.Context, *oas.ResponsePostResponseAiProposalsReq) (*oas.ResponsePostResponseAiProposalsOK, error)
ResponsePostResponseAiProposals answers 404: the operation exists only in the preview build (FORBID-5). On a real box the AI calls the Go port of the service as a service identity; there is no HTTP route a person or a token could use to send a proposal.
func (*ResponseHandlers) ResponsePostResponseAiResume ¶
func (h *ResponseHandlers) ResponsePostResponseAiResume(ctx context.Context) (*oas.ResponsePostResponseAiResumeOK, error)
ResponsePostResponseAiResume implements POST /response/ai/resume (admin).
func (*ResponseHandlers) ResponsePostResponseApproveToken ¶
func (h *ResponseHandlers) ResponsePostResponseApproveToken(ctx context.Context, req *oas.ResponsePostResponseApproveTokenReq, params oas.ResponsePostResponseApproveTokenParams) (*oas.ResponsePostResponseApproveTokenOK, error)
ResponsePostResponseApproveToken implements POST /response/approve/{token} (public): the only call that decides.
func (*ResponseHandlers) ResponsePostResponseBlocklistToken ¶
func (h *ResponseHandlers) ResponsePostResponseBlocklistToken(ctx context.Context) (*oas.ResponsePostResponseBlocklistTokenOK, error)
ResponsePostResponseBlocklistToken implements POST /response/blocklist/token (admin).
func (*ResponseHandlers) ResponsePostResponseBreakerReset ¶
func (h *ResponseHandlers) ResponsePostResponseBreakerReset(ctx context.Context) (*oas.ResponsePostResponseBreakerResetOK, error)
ResponsePostResponseBreakerReset implements POST /response/breaker/reset (admin).
func (*ResponseHandlers) ResponsePostResponseCatalog ¶
func (h *ResponseHandlers) ResponsePostResponseCatalog(ctx context.Context, req *oas.ResponsePostResponseCatalogReq) (*oas.ResponsePostResponseCatalogCreated, error)
ResponsePostResponseCatalog implements POST /response/catalog (admin).
func (*ResponseHandlers) ResponsePostResponseEmergencyStop ¶
func (h *ResponseHandlers) ResponsePostResponseEmergencyStop(ctx context.Context) (*oas.ResponsePostResponseEmergencyStopOK, error)
ResponsePostResponseEmergencyStop implements POST /response/emergency-stop (operator).
func (*ResponseHandlers) ResponsePostResponseExecution ¶
func (h *ResponseHandlers) ResponsePostResponseExecution(ctx context.Context, req *oas.ResponsePostResponseExecutionReq) (*oas.ResponsePostResponseExecutionOK, error)
ResponsePostResponseExecution implements POST /response/execution (admin).
func (*ResponseHandlers) ResponsePostResponseIncidentsIDRequest ¶
func (h *ResponseHandlers) ResponsePostResponseIncidentsIDRequest(ctx context.Context, req *oas.ResponsePostResponseIncidentsIDRequestReq, params oas.ResponsePostResponseIncidentsIDRequestParams) (*oas.ResponsePostResponseIncidentsIDRequestCreated, error)
ResponsePostResponseIncidentsIDRequest implements POST /response/incidents/{id}/request (operator).
func (*ResponseHandlers) ResponsePostResponseMeIdentitiesChannelCode ¶
func (h *ResponseHandlers) ResponsePostResponseMeIdentitiesChannelCode(ctx context.Context, params oas.ResponsePostResponseMeIdentitiesChannelCodeParams) (*oas.ResponsePostResponseMeIdentitiesChannelCodeOK, error)
ResponsePostResponseMeIdentitiesChannelCode implements POST /response/me/identities/{channel}/code (operator).
func (*ResponseHandlers) ResponsePostResponseMeIdentitiesChannelConfirm ¶
func (h *ResponseHandlers) ResponsePostResponseMeIdentitiesChannelConfirm(ctx context.Context, req *oas.ResponsePostResponseMeIdentitiesChannelConfirmReq, params oas.ResponsePostResponseMeIdentitiesChannelConfirmParams) (*oas.ResponsePostResponseMeIdentitiesChannelConfirmOK, error)
ResponsePostResponseMeIdentitiesChannelConfirm implements POST /response/me/identities/{channel}/confirm (operator).
func (*ResponseHandlers) ResponsePostResponseProposalsIDRequest ¶
func (h *ResponseHandlers) ResponsePostResponseProposalsIDRequest(ctx context.Context, params oas.ResponsePostResponseProposalsIDRequestParams) (*oas.ResponsePostResponseProposalsIDRequestCreated, error)
ResponsePostResponseProposalsIDRequest implements POST /response/proposals/{id}/request (operator).
func (*ResponseHandlers) ResponsePostResponseRules ¶
func (h *ResponseHandlers) ResponsePostResponseRules(ctx context.Context, req *oas.ResponsePostResponseRulesReq) (*oas.ResponsePostResponseRulesCreated, error)
ResponsePostResponseRules implements POST /response/rules (admin).
func (*ResponseHandlers) ResponsePostResponseRulesIDManual ¶
func (h *ResponseHandlers) ResponsePostResponseRulesIDManual(ctx context.Context, req *oas.ResponsePostResponseRulesIDManualReq, params oas.ResponsePostResponseRulesIDManualParams) (*oas.ResponsePostResponseRulesIDManualOK, error)
ResponsePostResponseRulesIDManual implements POST /response/rules/{id}/manual (operator).
func (*ResponseHandlers) ResponsePostResponseRulesRun ¶
func (h *ResponseHandlers) ResponsePostResponseRulesRun(context.Context) (*oas.ResponsePostResponseRulesRunOK, error)
ResponsePostResponseRulesRun answers 404: the operation exists only in the preview build (FORBID-5).
func (*ResponseHandlers) ResponsePostResponseRulesSimulate ¶
func (h *ResponseHandlers) ResponsePostResponseRulesSimulate(ctx context.Context, req *oas.ResponsePostResponseRulesSimulateReq) (*oas.ResponsePostResponseRulesSimulateOK, error)
ResponsePostResponseRulesSimulate implements POST /response/rules/simulate (operator).
func (*ResponseHandlers) ResponsePostResponseTemplatesIDClone ¶
func (h *ResponseHandlers) ResponsePostResponseTemplatesIDClone(ctx context.Context, params oas.ResponsePostResponseTemplatesIDCloneParams) (*oas.ResponsePostResponseTemplatesIDCloneCreated, error)
ResponsePostResponseTemplatesIDClone implements POST /response/templates/{id}/clone (admin).
func (*ResponseHandlers) ResponsePutResponseAllowlist ¶
func (h *ResponseHandlers) ResponsePutResponseAllowlist(ctx context.Context, req *oas.ResponsePutResponseAllowlistReq) (*oas.ResponsePutResponseAllowlistOK, error)
ResponsePutResponseAllowlist implements PUT /response/allowlist (admin).
func (*ResponseHandlers) ResponsePutResponseCatalogID ¶
func (h *ResponseHandlers) ResponsePutResponseCatalogID(ctx context.Context, req *oas.ResponsePutResponseCatalogIDReq, params oas.ResponsePutResponseCatalogIDParams) (*oas.ResponsePutResponseCatalogIDOK, error)
ResponsePutResponseCatalogID implements PUT /response/catalog/{id} (admin).
func (*ResponseHandlers) ResponsePutResponseRulesID ¶
func (h *ResponseHandlers) ResponsePutResponseRulesID(ctx context.Context, req *oas.ResponsePutResponseRulesIDReq, params oas.ResponsePutResponseRulesIDParams) (*oas.ResponsePutResponseRulesIDOK, error)
ResponsePutResponseRulesID implements PUT /response/rules/{id} (admin).
func (*ResponseHandlers) ResponsePutResponseSettings ¶
func (h *ResponseHandlers) ResponsePutResponseSettings(ctx context.Context, req *oas.ResponsePutResponseSettingsReq) (*oas.ResponsePutResponseSettingsOK, error)
ResponsePutResponseSettings implements PUT /response/settings (admin).
type RestCall ¶
type RestCall struct {
Method string `json:"method"`
URL string `json:"url"`
Body *string `json:"body"`
// Headers are the headers of the template with the typed values filled in, exactly as they are sent (the sign-in is the connection's and
// never appears here; a name that INV-14b forbids never reaches this point). Always an object.
Headers map[string]string `json:"headers"`
}
RestCall is the exact API call of a step.
type RollbackChange ¶
type RollbackChange struct {
Title string `json:"title"`
CLI string `json:"cli"`
Rest *RestCall `json:"rest"`
}
RollbackChange is how a change is undone.
type RolledBackEvent ¶
type RolledBackEvent struct {
RequestID string `json:"request_id"`
ItemID string `json:"item_id"`
ActionID string `json:"action_id"`
Auto bool `json:"auto"`
}
RolledBackEvent is the payload of response.action.rolled_back. Auto is true when the undo time ended.
type Rule ¶
type Rule struct {
ID string `json:"id"`
RuleInput
TemplateID *string `json:"template_id"`
LastFired *string `json:"last_fired"`
}
Rule is a stored rule.
type RuleAction ¶
type RuleAction struct {
ActionID string `json:"action_id"`
Params map[string]string `json:"params"`
TTLMin *int `json:"ttl_min"`
}
RuleAction is one THEN step.
type RuleInput ¶
type RuleInput struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Live bool `json:"live"`
Trigger string `json:"trigger"`
Match string `json:"match"`
Conditions []Condition `json:"conditions"`
Actions []RuleAction `json:"actions"`
PreApproved bool `json:"pre_approved"`
MaxPerHour int `json:"max_per_hour"`
ScheduleMin *int `json:"schedule_min"`
}
RuleInput is what the client sends for a rule.
type RunSummary ¶
type RunSummary struct {
Matched int `json:"matched"`
DryRun int `json:"dry_run"`
Requests int `json:"requests"`
Executed int `json:"executed"`
Refused int `json:"refused"`
Deduped int `json:"deduped"`
}
RunSummary counts what a run did.
type SecondCheck ¶
SecondCheck is the deterministic second checker of a high-risk AI request (part 13b).
type SentProposal ¶
type SentProposal struct {
ProposalID, ActionID, Outcome, RequestID string
}
SentProposal is one proposal of a stored plan that the plan job sent through Propose, and its outcome: request, suggestion or digest, or the code of the refusal. RequestID is set for a request.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the response module. Create it once with New and share it between the handlers, the jobs and the event subscriptions.
func New ¶
New builds a Service and loads the data files (action templates, rule templates, triggers). The built-in catalog rows are written by the first call that reads the catalog.
func (*Service) AIActions ¶
AIActions lists what the AI may propose, in catalog order, for the ai module to build its tool schema from.
func (*Service) Actions ¶
func (s *Service) Actions(ctx context.Context) ([]ActionRequest, error)
Actions is GET /response/actions: newest first. email_links is always empty in the real build (FORBID-4).
func (*Service) AddAction ¶
func (s *Service) AddAction(ctx context.Context, who Actor, in CatalogInput) (CatalogAction, error)
AddAction is POST /response/catalog: a custom action.
func (*Service) Allowlist ¶
func (s *Service) Allowlist(ctx context.Context) ([]AllowEntry, error)
Allowlist is GET /response/allowlist: the declared entries plus the box's own addresses, which always count.
func (*Service) Approve ¶
func (s *Service) Approve(ctx context.Context, who Actor, id string, pick []string, code string) (ActionRequest, error)
Approve is POST /response/actions/{id}/approve: all actions, or the ones picked. A high-risk request, or one that touches more targets than the limit, needs a second, different approver who approves the same actions.
func (*Service) Blocklist ¶
func (s *Service) Blocklist(ctx context.Context) (BlocklistView, error)
Blocklist is GET /response/blocklist (admin): the address with its token, the entries, the last pull.
func (*Service) Catalog ¶
Catalog is GET /response/catalog. The header lines of a template can carry an authorisation value, so the values are hidden from everyone but an admin (full): GET is open to viewers (CONTRACT), who see the header names only.
func (*Service) ChangeAction ¶
func (s *Service) ChangeAction(ctx context.Context, who Actor, id string, u CatalogUpdate) (CatalogAction, error)
ChangeAction is PUT /response/catalog/{id}. A built-in action takes only enabled, ai_may_propose and connection_id.
func (*Service) ChangeRule ¶
ChangeRule is PUT /response/rules/{id}: change a rule, switch it on or off, or from dry run to live.
func (*Service) ChangesInForce ¶
ChangesInForce says whether a change made through the connection may still be in force on a device: an item that was carried out and not rolled back, one that was sent and whose outcome is not known yet (running), and one the sweep or the step deadline failed as "state unknown" (itemRec.StateUnknown). core/conn asks before it deletes a connection (409 in_use).
func (*Service) ChatLinkToken ¶
func (s *Service) ChatLinkToken(ctx context.Context, userID, channel, address string) (token, name string, err error)
ChatLinkToken makes the token of a confirm link for a sendLink channel when an administrator lists the person with that ID (notify sends https://<box>/link/<telegram|zalo>?c=<token> to the ID: Config.LinkCodes). The token is 128 random bits after the person's hint, single use, valid 10 minutes, kept hashed with (person, channel, address), and only ConfirmLink by that person, signed in, uses it: making it links nothing. The person must be an active operator or admin listed with exactly that address and not linked yet; one a minute and five an hour; a new one replaces the one waiting. name is how the message names the person (their name, else their email).
func (*Service) Clone ¶
Clone is POST /response/templates/{id}/clone: a new rule that is switched off and in dry run.
func (*Service) Close ¶
func (s *Service) Close()
Close stops the approval requests that are being sent (their context ends, so a mail server that does not answer cannot hold the shutdown) and waits for them to finish. Nothing else in the service runs in the background.
func (*Service) ConfirmLink ¶
func (s *Service) ConfirmLink(ctx context.Context, who Actor, channel, code string) (Identity, error)
ConfirmLink is POST /response/me/identities/{channel}/confirm (operator): the code proves the address it was made for, if that address is still the person's on the channel's list. On a sendLink channel the code is the token of the confirm link the box sent to the ID: a token for another person is refused before anything is read, so it stays valid for its person.
func (*Service) DecideByLink ¶
func (s *Service) DecideByLink(ctx context.Context, token, decision, from string) (ActionRequest, error)
DecideByLink is POST /response/approve/{token}. The order of the checks: the rate limit, a token that is not known (404), one that ended or was used or whose request was decided (409), the approver (403 approver_not_listed), the risk policy (403 in_app_required), then the decision with via=email. The token is burned in the transaction of the decision: a decision the gates refuse leaves it alive, and of two POSTs at once one wins and the other gets 409 used. Nothing here writes for a token that is not known (an attacker must not fill the log); refusals of a known link are logged like any refusal (INV-19), without the token.
func (*Service) DecideFromChat ¶
func (s *Service) DecideFromChat(ctx context.Context, d ChatDecision) (ChatOutcome, error)
DecideFromChat takes a decision made in Slack, Telegram or a personal Zalo chat (notify calls it through Config.Decisions). The order of the checks is the one of INV-3: the rate limit of the sender, the channel, the sender on the list of that channel, the person (active, operator or above), the risk policy of the channel, for Zalo the reply code (matches request, person and decision, not used, not ended), then the same approve or reject as the app with via set to the channel. A refusal is an *apierr.Error and is logged as "refused" with the sender; a decision a gate refuses does not burn the code.
func (*Service) DeleteAction ¶
DeleteAction is DELETE /response/catalog/{id}: a custom action that no rule uses.
func (*Service) DeleteRule ¶
DeleteRule is DELETE /response/rules/{id}.
func (*Service) DeviceMerged ¶
DeviceMerged is response's part of a device merge (core/lifecycle, inside the inventory's write): the plans, events and requests of device m.From are about device m.Into now; each keeps the device name it stored. A deleted device needs nothing here: they are a log of what was proposed and done, kept with that name.
func (*Service) DropChatLink ¶
DropChatLink ends the person's proof of exactly this address on the channel, and any code waiting for it, when an administrator removes them as an approver or gives them another address (notify Config.LinkCodes): a proof held to an old address must not count again if the list later names that address once more. Nothing linked is no error. The audit row is response.identity_unlink by the actor.
func (*Service) DropLinkToken ¶
DropLinkToken removes the waiting confirm-link token of the person on the channel when it is exactly this token for this address: notify calls it when the link could not be delivered, so no token waits that nobody received (Config.LinkCodes). A newer token, or a proof already made, is left as it is. Nothing waiting is no error.
func (*Service) DroppedEvents ¶
DroppedEvents counts the unprocessed trigger events dropped because the backlog was full since the box started. Every drop is counted here; the warning and the refused line in the response log are coalesced (one per minute, with the count).
func (*Service) EmergencyStop ¶
EmergencyStop is POST /response/emergency-stop: execution off, the global circuit breaker open and every pending request cancelled, in one transaction. The open breaker stops what the execution switch does not: pre-approved rules, the box actions (block list, webhook, message) and every item still to run (fire and runItem read it per rule and per item); only an admin resets it (INV-8, INV-12). It takes neither mu nor execMu: a stop must never wait. A run step that is being sent is cancelled; an undo step that is being sent finishes (an undo is the safe direction), and the next undo is blocked by the stop.
func (*Service) Evaluate ¶
func (s *Service) Evaluate(ctx context.Context) (RunSummary, error)
Evaluate runs the enabled rules on the events that no rule has seen yet. The evaluate job calls it; tests call it directly. Each (rule, event) pair is handled once. A pre-approved rule's request is approved after its own transaction committed.
func (*Service) ExportLog ¶
ExportLog is the "response" source of GET /core/logs/export (core INV-13): resp_log from the first line at or after from to the last at or before to, oldest first, as JSON lines with the chain fields unchanged (id, ts, kind, actor, detail, prev_hash, hash), so the file verifies offline, plus the anchor and head of the chain (logexport.ChainInfo). A zero time is open. The lines are exported as stored: nothing is scrubbed, so resp_log must be free of secrets when a line is written (the response module owns that; TestExportLogRowsHoldNoSecret checks today's lines).
func (*Service) FetchBlocklist ¶
FetchBlocklist answers a pull of the public address. A wrong token is a plain 404 (it looks like a wrong path); a source address that pulls too often, or guesses tokens, gets 429. A store that cannot be read gives 503, never an empty list. from is the source address of the request; the limit is per address, per /64 for IPv6.
func (*Service) FindingFolded ¶
FindingFolded is response's part of a merge that folds finding f.From into f.Into (same device and CVE): its plans, events and requests name the finding that stays.
func (*Service) FindingMoved ¶
FindingMoved is response's part of a finding that went to another device with its software line (findings, inside inventory's split write or its own match write): the events the rules have not run on yet follow it to f.Into. A waiting finding event takes that device's name and address, which a rule reads: from the move itself when the mover names them (f.IntoName, f.IntoIP: a split runs this inside the write that creates the device, which a reader does not see yet), else from the directory, with the device's kind. A kind the directory could not give here is read when the rules come to the event (deviceOfEvent), so a waiting event never keeps the kind of the device the finding left. When neither knows the device, the event keeps no name, kind or address of the old one: a rule that names the address finds the device's when it runs, or is refused as having no target, never run on the old device's. Its plan is retired, not moved: its proposals hold values built for the old device's address, so it is deleted (logged and audited) and the planner writes a new plan for the finding on its new device. A pending request is withdrawn, not moved: its items hold the values it was rendered with (the old device's address), so approving it would act on the old device under the new one's name. It ends expired with the reason, keeps the device it was made for, and is logged and audited; a new request is asked for from the new plan, and a decision on the withdrawn one answers so (endedAnswer). What was decided or done keeps the device it was about: a request approved, executed, rejected, expired, failed or rolled back, and an event the rules already ran on.
func (*Service) IncidentPanel ¶
IncidentPanel is GET /response/incidents/{id}: the incident's source and the actions that can be asked for it, each saying why it is not ready. It changes nothing.
func (*Service) Jobs ¶
Jobs returns the jobs of the module: "evaluate" runs the rules on new events and the due schedules; "sweep" expires old requests and undoes changes whose undo time ended. "evaluate" also polls the Logs counts for the log_threshold rules (PollLogs). Both run only while the module is on (SYS-5).
func (*Service) LinkView ¶
LinkView is GET /response/approve/{token}. It reads and never writes (not a decision, not a log line, not a burned token), so a link scanner that opens every link in a mail changes nothing. Anything but "ready" shows none of the request. A source address that keeps sending links that are not valid gets 429.
func (*Service) Linked ¶
Linked says whether the person proved exactly this address on the channel. notify asks it before it mails an approval link to an approver (notify INV-13, Config.ApproverLinks): an unproved address gets no mail. The error never holds the address (notify logs it).
func (*Service) Log ¶
Log is GET /response/log: the whole chain, oldest first, so it can be checked from the start. There is no way to change or delete a line.
func (*Service) MyIdentities ¶
MyIdentities is GET /response/me/identities (operator).
func (*Service) PlanOpen ¶
PlanOpen is one run of the plan job: for each open critical finding without a plan (at most maxPlansPerRun) it asks the Planner and saves the plan if it passes. It returns how many plans were saved. With the module off, no Planner, or the AI not available it does nothing and asks nothing.
func (*Service) Plans ¶
Plans is GET /response/plans. Plans of findings that are no longer open and critical are left out.
func (*Service) PollLogs ¶
PollLogs makes the events of the log_threshold trigger: for every enabled rule of that trigger, it asks each declared log source how many lines of the rule's signature arrived in the rule's window. When the count reached the threshold it asks which remote addresses sent them (logs.TopAddresses): every address that alone sent at least N lines is an event of its own with source_ip, so a ban rule bans each attacker and never an address for the lines of others; when none did (the lines are spread over many addresses, or name none) the event names the log source only, with source_ip empty. Each (source, signature, window, threshold, address or none) makes one event per burst: not again while the lines of that burst still count (its window and one 5-minute bucket). The evaluate job calls it before Evaluate; the Logs module off (or not wired) means no event, never an error.
func (*Service) Propose ¶
func (s *Service) Propose(ctx context.Context, in ProposeBody) (ProposeResult, error)
Propose is the one entry for an AI proposal. The gates run in the order of INV-15 (the mock web/src/features/response/ai.ts is the reference) and the whole decision is one write transaction under the service lock, so two proposals at once cannot both pass "already open" or the budget. A refusal is an error carrying the code and status of the mock and is recorded in resp_log; a note (suggestion or digest) is a normal result. Nothing here approves anything: a request is created pending, never pre-approved. With the module off nothing is read, written or published.
func (*Service) RecordLink ¶
func (s *Service) RecordLink(ctx context.Context, l LinkRecord) error
RecordLink stores the record of an approval link before the mail with it goes out (notify.TokenRecorder). Only the hash of the token id is kept. Only email carries a link in 13b.
func (*Service) RecordReplyCode ¶
func (s *Service) RecordReplyCode(ctx context.Context, c ReplyCodeRecord) error
RecordReplyCode stores the hash of one reply code before the message with it is sent (notify.TokenRecorder; 13b-8 reads it).
func (*Service) RegenerateToken ¶
RegenerateToken is POST /response/blocklist/token: the old address stops working at once. A token this box cannot open (#847) is replaced the same way, with one WARN and one audit row box-key.replace more.
func (*Service) Reject ¶
func (s *Service) Reject(ctx context.Context, who Actor, id, reason, remember string) (ActionRequest, error)
Reject is POST /response/actions/{id}/reject. For an AI request, remember (none, rule or memory) keeps the reason as a hint (INV-18) and the quality breaker looks at the decisions again (INV-15 (8)); a rule request has nothing to learn, so remember is ignored.
func (*Service) RequestFromIncident ¶
func (s *Service) RequestFromIncident(ctx context.Context, who Actor, id, actionID string) (ActionRequest, error)
RequestFromIncident is POST /response/incidents/{id}/request: ask for approval of one offered action on the incident's source. The source is read again here (the browser never sends it); the gates are those of RequestProposal without the AI ones. The request is pending: a person approves it.
func (*Service) RequestProposal ¶
func (s *Service) RequestProposal(ctx context.Context, who Actor, pid string) (ActionRequest, error)
RequestProposal is POST /response/proposals/{id}/request: ask for approval of one action proposed in an AI plan. The proposal holds a catalog action and typed values only: the change is rendered here, through the same planner and gates as a rule run (switch, breaker, maintenance window, never-touch, catalog, connection, type checks, escaping), so a stored plan can never carry text that runs. The request carries AI data, so the AI gates apply to it (part 13b; until then it cannot be approved).
func (*Service) ResetBreaker ¶
ResetBreaker is POST /response/breaker/reset: only an admin resumes response after the global circuit breaker (INV-12).
func (*Service) ResumeAI ¶
ResumeAI is POST /response/ai/resume: an admin clears the pause the quality breaker set. It is audited and logged.
func (*Service) Rollback ¶
Rollback is POST /response/actions/{id}/rollback: undo every executed action of the request with its rollback step. A device action is refused when execution is off (INV-7).
func (*Service) RunManual ¶
func (s *Service) RunManual(ctx context.Context, who Actor, ruleID, assetID string) (RunSummary, error)
RunManual is POST /response/rules/{id}/manual: run a manual-trigger rule on a chosen device. It still goes through every gate.
func (*Service) RunSchedules ¶
RunSchedules fires the enabled schedule rules that are due: one synthetic event per due run.
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(ctx context.Context, who Actor, in SettingsInput) (SettingsView, error)
SaveSettings is PUT /response/settings. It never touches the execution switch (INV-7), the breaker or the AI pause.
func (*Service) SendLinkCode ¶
SendLinkCode is POST /response/me/identities/{channel}/code (operator): a code mailed to the person's address on the email approval channel, or on a sendLink channel a new confirm link sent to the person's own listed ID (LinkSender).
func (*Service) SetAllowlist ¶
func (s *Service) SetAllowlist(ctx context.Context, who Actor, in []AllowEntry) ([]AllowEntry, error)
SetAllowlist is PUT /response/allowlist: replace the declared entries. The entries that count without being listed (the box's own addresses and MACs, its gateway and DNS servers, the inventory's routers and firewalls) are not stored when they come back as GET showed them (same value and label): the GUI sends back the whole list, and a stored copy would outlive a gateway that changed. The same value under a label the administrator wrote is a declared entry and is kept.
func (*Service) SetExecution ¶
func (s *Service) SetExecution(ctx context.Context, who Actor, enabled bool, phrase string) (SettingsView, error)
SetExecution is POST /response/execution. Turning it on needs an admin (the route), two-step sign-in on and the exact phrase; it records who accepted the risk and when (INV-7). Turning it off needs an admin too.
func (*Service) Settings ¶
func (s *Service) Settings(ctx context.Context) (SettingsView, error)
Settings is GET /response/settings.
func (*Service) Simulate ¶
func (s *Service) Simulate(ctx context.Context, who Actor, in RuleInput, eventID string) (Simulation, error)
Simulate is POST /response/rules/simulate: render exactly what a live run would do with the latest event of the trigger and execute nothing (executed is always 0). The rule can be saved or not.
func (*Service) StoreEvent ¶
StoreEvent records an event for the triggers to watch. A second event with the same id changes nothing.
func (*Service) Subscribe ¶
Subscribe registers the event handlers on bus and returns a function that removes them. A handler only records the event (a database write); the rules run in the evaluate job, so a handler never holds the publisher while it works.
func (*Service) Sweep ¶
Sweep expires the pending requests past their time, fails the items an approved request left behind, and undoes the executed changes whose undo time ended. Only the sweep job calls it: a read (GET) never sends a step to a device. A list of requests only expires what is past its time (sweepExpired), so a stale request never looks open.
func (*Service) Triggers ¶
func (s *Service) Triggers(ctx context.Context) ([]TriggerInfo, error)
Triggers is GET /response/triggers.
type Settings ¶
type Settings struct {
Execution bool `json:"execution"`
AcceptedBy *string `json:"accepted_by"`
AcceptedAt *string `json:"accepted_at"`
MaxPerHour int `json:"max_per_hour"`
ExpiryMin int `json:"expiry_min"`
ApprovalChannels []string `json:"approval_channels"`
BreakerMaxPerHour int `json:"breaker_max_per_hour"`
BreakerTrippedAt *string `json:"breaker_tripped_at"`
BreakerNotified []string `json:"breaker_notified"`
// StoppedAt is when the emergency stop was pressed, until an admin resumes (ResetBreaker). It blocks every step that touches a device, an undo
// included; the execution switch and the breaker do not block an undo.
StoppedAt *string `json:"stopped_at"`
MultiTargetMax int `json:"multi_target_max"`
Maintenance []Window `json:"maintenance"`
AI AiGates `json:"ai"`
}
Settings is the execution switch and the safety envelope.
type SettingsInput ¶
type SettingsInput struct {
MaxPerHour int `json:"max_per_hour"`
ExpiryMin int `json:"expiry_min"`
ApprovalChannels []string `json:"approval_channels"`
BreakerMaxPerHour int `json:"breaker_max_per_hour"`
MultiTargetMax int `json:"multi_target_max"`
Maintenance []Window `json:"maintenance"`
AI struct {
Triggers []string `json:"triggers"`
BudgetHour int `json:"budget_hour"`
BudgetDay int `json:"budget_day"`
} `json:"ai"`
}
SettingsInput is the body of PUT /response/settings. It has no execution field: the switch has its own endpoint.
type SettingsView ¶
type SettingsView struct {
Settings
Channels []ChannelView `json:"channels"`
}
SettingsView is Settings plus the channels.
type SimCondition ¶
SimCondition is one evaluated condition.
type SimStep ¶
type SimStep struct {
Action string `json:"action"`
Risk Risk `json:"risk"`
OK bool `json:"ok"`
Error *string `json:"error"`
Change *Change `json:"change"`
}
SimStep is one step of a simulation.
type Simulation ¶
type Simulation struct {
Event *EventView `json:"event"`
Matched bool `json:"matched"`
Conditions []SimCondition `json:"conditions"`
Steps []SimStep `json:"steps"`
Notes []string `json:"notes"`
Approvals int `json:"approvals"`
Executed int `json:"executed"`
}
Simulation is the answer of simulate: what a live run would do. Executed is always 0.
type Stat ¶
type Stat struct {
Sent int `json:"sent"`
Approved int `json:"approved"`
Rejected int `json:"rejected"`
Expired int `json:"expired"`
Pending int `json:"pending"`
AcceptanceRate *float64 `json:"acceptance_rate"`
MedianApproveMin *float64 `json:"median_approve_min"`
}
Stat is the approval statistics of a source.
type StepStatus ¶
type StepStatus string
StepStatus says how a step ended.
const ( StepOK StepStatus = "ok" StepNotSent StepStatus = "not_sent" // nothing reached the device StepConnectionChange StepStatus = "connection_changed" // the connection is not the version the request was made against; nothing was sent StepFailed StepStatus = "failed" // the device refused the step; as far as the answer shows nothing changed StepUnknown StepStatus = "unknown" // sent, outcome not known )
The ways a step ends. Anything else an Executor answers counts as StepUnknown: a step whose outcome is not understood is treated as one that may have been applied.
type Template ¶
type Template struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Trigger string `json:"trigger"`
Risk Risk `json:"risk"`
Approvals int `json:"approvals"`
Rule RuleInput `json:"rule"`
}
Template is a ready-made rule of the gallery.
type Tpl ¶
type Tpl struct {
CLI string `json:"cli"`
Method string `json:"method"`
Path string `json:"path"`
Body string `json:"body"`
Headers string `json:"headers"`
Expect string `json:"expect"`
}
Tpl is a template of one step of an action: a command, or an API call with a path, a JSON body and headers. Expect only means something on the read-back (verify): after the action its output must contain the text, after the undo it must not.
type TriggerField ¶
type TriggerField struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"`
Example string `json:"example"`
Choices []string `json:"choices"`
// Min and Max bound a number or port field: a condition value outside them is refused when the rule is saved.
Min *float64 `json:"min"`
Max *float64 `json:"max"`
}
TriggerField is a field a trigger provides.
type TriggerInfo ¶
type TriggerInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Fields []TriggerField `json:"fields"`
AIAllowed bool `json:"ai_allowed"`
AIEvidence []string `json:"ai_evidence"` // what proves it to the AI; empty = the AI may never use it
}
TriggerInfo describes a trigger.
type TwoStep ¶
TwoStep checks the two-step code of a person for one purpose. cmd/vedette adapts core/auth.VerifyTwoStep; its errors are API errors (400 code_required, invalid_code, wrong_code, 403 twofa_required, 429 with Retry-After, 503) and pass through unchanged (INV-16). A nil TwoStep means no code can be checked: a high-risk AI request is refused with 403 twofa_required.
type User ¶
type User struct {
ID string
Name string
Email string
Role string // viewer, operator or admin
TwoStep bool // two-step sign-in is on (INV-7)
Disabled bool
}
User is an account as this module needs it.
type Via ¶
type Via string
Via is how an approval was given.
const ( ViaApp Via = "app" ViaAuto Via = "auto" ViaEmail Via = "email" // an approval link in an email (13b-7) ViaSlack Via = "slack" // a Slack button ViaTelegram Via = "telegram" // a Telegram button ViaZaloPersonal Via = "zalo-personal" // a reply code in a personal Zalo chat )
The ways to approve. Chat approvals (slack, telegram, zalo-personal) are slice 13b-8 (DecideFromChat).
type WebhookTarget ¶
type WebhookTarget struct{ URL, SigningKey string }
WebhookTarget is where the webhook_call action posts: the URL (a secret) and the key that signs the body.
Source Files
¶
- ai.go
- allow.go
- blocklist.go
- catalog.go
- chat.go
- chatlimit.go
- data.go
- device.go
- devicelifecycle.go
- engine.go
- events.go
- exec.go
- handlers.go
- identity.go
- incident.go
- links.go
- logthreshold.go
- params.go
- planner.go
- planner_status.go
- plans.go
- propose.go
- readonly.go
- requests.go
- rules.go
- service.go
- settings.go
- store.go
- types.go
- webhook.go