extproc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ContentTypeSse = "text/event-stream"
)

SSE content type sentinel.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditRecorder

type AuditRecorder interface {
	Record(md models.Metadata, st models.MaskingState, maskedTexts []string)
	// RecordResponse enriches an existing record (by request ID) with the
	// masked model response texts; best-effort, gated, no-op if absent.
	RecordResponse(requestID string, maskedResponseTexts []string)
}

AuditRecorder persists per-request masking audit entries. Implementations must be non-blocking and fail-open (see internal/service/audit).

type Controller

type Controller struct {
	extprocv3.UnimplementedExternalProcessorServer
	// contains filtered or unexported fields
}

Controller implements the Envoy External Processor gRPC service.

func New

func New(
	cfg *config.Config,
	masker Masker,
	settingsProvider SettingsProvider,
	demaskerProvider DemaskerProvider,
	stateStore repository.MaskingStateStore,
	audit AuditRecorder,
) (*Controller, error)

New creates a new Controller. audit may be nil (audit trail disabled). The path map (GUARDRAILS_PATHS) is validated here; an invalid map is a boot-time error.

func (*Controller) Process

Process handles the Envoy external processing requests

type DemaskerFactory

type DemaskerFactory interface {
	Demasker() *demask.Demasker
	JSONDemasker() *demask.Demasker
}

DemaskerFactory creates request-scoped Demasker instances. JSONDemasker variants JSON-escape restored originals for use inside JSON string contexts (streamed tool-input fragments).

type DemaskerProvider

type DemaskerProvider interface {
	NewFactory(state models.MaskingState) *demask.Factory
}

DemaskerProvider creates request-scoped demasker factories from app-scoped dependencies.

type Masker

type Masker interface {
	Handle(ctx context.Context, cmd mask.Command) (mask.CommandResponse, error)
}

Masker masks request texts using guardrails regex rules.

type ProcessStep

type ProcessStep uint8
const (
	StepRequestHeaders ProcessStep = 1 << iota
	StepRequestBody
	StepRequestTrailers
	StepResponseHeaders
	StepResponseBody
	StepResponseTrailers
	StepAll ProcessStep = 0b1111111
)

type SettingsProvider

type SettingsProvider interface {
	Global() models.GuardrailsSettings
}

SettingsProvider supplies the current global guardrails settings.

type SseProcessor

type SseProcessor interface {
	ProcessChunk(ctx context.Context, body []byte, endOfStream bool) ([]byte, error)
}

Jump to

Keyboard shortcuts

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