server

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddr = "127.0.0.1:4765"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivatePolicyProfileRequest added in v0.7.0

type ActivatePolicyProfileRequest struct {
	Profile policy.Profile `json:"profile"`
}

type Options added in v0.7.0

type Options struct {
	Judge                judge.Judge
	PolicyConfig         policy.Config
	PolicyConfigProvider PolicyConfigProvider
	ProviderPolicies     []ProviderPolicyBinding
	EndpointID           string
	CurrentSessionID     string
	Mode                 string
}

type PolicyConfigProvider added in v0.7.0

type PolicyConfigProvider interface {
	ActivePolicyConfig(context.Context) (guardpolicy.Config, error)
}

type PolicyProfileResponse added in v0.7.0

type PolicyProfileResponse struct {
	Profile            policy.Profile `json:"profile"`
	RecommendedProfile policy.Profile `json:"recommended_profile"`
	Version            string         `json:"version"`
	RulePack           string         `json:"rule_pack"`
	RulePackVersion    string         `json:"rule_pack_version"`
	ConfigDigest       string         `json:"config_digest"`
	ActivationID       string         `json:"activation_id"`
	Source             string         `json:"source"`
	Status             string         `json:"status"`
	LoadedAt           time.Time      `json:"loaded_at"`
}

type PolicyProvider added in v0.7.0

type PolicyProvider interface {
	DecideHook(context.Context, risk.HookEvent) (risk.RiskDecision, error)
}

type ProcessResponse

type ProcessResponse struct {
	Decision   risk.Decision `json:"decision"`
	Reason     string        `json:"reason"`
	ReasonCode string        `json:"reason_code"`
	EventID    string        `json:"event_id"`
}

type ProviderPolicyBinding added in v0.15.0

type ProviderPolicyBinding struct {
	Provider  string
	Snapshots providerpolicy.SnapshotProvider
	Classify  func(event risk.HookEvent) []providerpolicy.Request
}

ProviderPolicyBinding wires one provider's synced policy into the decision path: a snapshot source plus a classifier turning hook events into that provider's canonical policy requests (subject fields are filled in by the evaluator).

func GithubPolicyBinding added in v0.15.0

func GithubPolicyBinding(snapshots providerpolicy.SnapshotProvider) ProviderPolicyBinding

GithubPolicyBinding binds the GitHub classifier to a snapshot source.

func HubspotPolicyBinding added in v0.15.0

func HubspotPolicyBinding(snapshots providerpolicy.SnapshotProvider) ProviderPolicyBinding

HubspotPolicyBinding binds the HubSpot classifier to a snapshot source. The Cowork connector registry is resolved lazily per event from the hook cwd.

type RiskPolicyProvider added in v0.7.0

type RiskPolicyProvider struct {
	// contains filtered or unexported fields
}

func NewRiskPolicyProvider added in v0.7.0

func NewRiskPolicyProvider() RiskPolicyProvider

func NewRiskPolicyProviderWithJudge added in v0.7.0

func NewRiskPolicyProviderWithJudge(localJudge judge.Judge) RiskPolicyProvider

func NewRiskPolicyProviderWithOptions added in v0.7.0

func NewRiskPolicyProviderWithOptions(opts RiskPolicyProviderOptions) RiskPolicyProvider

func (RiskPolicyProvider) DecideHook added in v0.7.0

func (p RiskPolicyProvider) DecideHook(ctx context.Context, event risk.HookEvent) (risk.RiskDecision, error)

type RiskPolicyProviderOptions added in v0.7.0

type RiskPolicyProviderOptions struct {
	Judge                judge.Judge
	PolicyEngine         guardpolicy.Engine
	PolicyConfig         guardpolicy.Config
	PolicyConfigProvider PolicyConfigProvider
	ProviderPolicies     []ProviderPolicyBinding
	EndpointID           string
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(store *sqlite.Store) (*Server, error)

func NewServerWithOptions added in v0.7.0

func NewServerWithOptions(store *sqlite.Store, opts Options) (*Server, error)

func NewServerWithPolicy added in v0.7.0

func NewServerWithPolicy(store *sqlite.Store, policy PolicyProvider) (*Server, error)

NewServerWithPolicy creates a Guard server with an injected policy provider. A nil interface uses the default local risk policy; callers must not pass a typed-nil provider because it still satisfies the PolicyProvider interface.

func NewServerWithPolicyConfig added in v0.7.0

func NewServerWithPolicyConfig(store *sqlite.Store, policy PolicyProvider, policyStore *policyconfig.Store) (*Server, error)

func NewServerWithPolicyConfigAndOptions added in v0.8.0

func NewServerWithPolicyConfigAndOptions(store *sqlite.Store, policy PolicyProvider, policyStore *policyconfig.Store, opts Options) (*Server, error)

func OpenDefaultServer

func OpenDefaultServer(dbPath string) (*Server, func() error, error)

func OpenDefaultServerWithOptions added in v0.7.0

func OpenDefaultServerWithOptions(dbPath string, opts Options) (*Server, func() error, error)

func (*Server) EvaluateHook added in v0.7.0

func (s *Server) EvaluateHook(ctx context.Context, event risk.HookEvent) (risk.RiskDecision, error)

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) IngestEvent added in v0.7.0

func (s *Server) IngestEvent(ctx context.Context, event risk.HookEvent) (risk.RiskDecision, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

func (*Server) ProcessHookEvent

func (s *Server) ProcessHookEvent(ctx context.Context, event risk.HookEvent) (risk.RiskDecision, error)

func (*Server) RuntimeCore added in v0.7.0

func (s *Server) RuntimeCore() *runtimecore.Core

func (*Server) SetPayloadCaptureMode added in v0.15.0

func (s *Server) SetPayloadCaptureMode(mode payloadcapture.Mode)

SetPayloadCaptureMode forwards the org's payload-capture directive to the store, which reads it per recorded action. Called by the managed daemon's policy refresh cycle whenever a snapshot is fetched or restored from disk.

Jump to

Keyboard shortcuts

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