Documentation
¶
Index ¶
- Constants
- func ApprovedEmailDomainsFromConfig(b []byte) []string
- func BuiltinPresetsEnabledFromConfig(b []byte) bool
- func CanonicalPresidioRuleID(raw string) string
- func CompileDetectionScopes(eng *celenv.Engine, specs []DetectionScopeConfig) (map[categories.Category]CompiledScope, error)
- func DescribePresidioDeadLetter() (string, string)
- func DescribePresidioEntity(rawEntityType string) (string, string)
- func PresidioScoreThresholdFromConfig(b []byte) float64
- func PresidioScoreThresholdPtr(b []byte) *float64
- func ScanCELRules(eng *celenv.Engine, view MessageView, rules []CompiledCELRule) ([]scanners.Finding, error)
- func SourceCategories(source string) []categories.Category
- func WithApprovedEmailDomains(base []byte, v []string) ([]byte, error)
- func WithDetectionScopes(base []byte, v []DetectionScopeConfig) ([]byte, error)
- func WithPresidioScoreThreshold(base []byte, v *float64) ([]byte, error)
- type AccountIdentityConfig
- type AnalyzeBatch
- type AnalyzeBatchArgs
- type AnalyzeBatchResult
- type AnalyzerConfig
- type BuiltinPresetsConfig
- type CategoryScope
- type CategoryScopeMasks
- func (m CategoryScopeMasks) AdmitsAny(i int, cats []categories.Category) bool
- func (m CategoryScopeMasks) InScope(i int, cat categories.Category) bool
- func (m CategoryScopeMasks) RecommendedPrefilteredCount(cats []categories.Category) int
- func (m CategoryScopeMasks) Subset(messages []batchMessage, contents []string, cats []categories.Category) ([]batchMessage, []string, []int)
- type CategoryScopes
- type CompiledCELRule
- type CompiledScope
- type DetectionScopeConfig
- type DisabledRuleSet
- type EvalMessage
- type ExclusionSet
- type FetchUnanalyzed
- type FetchUnanalyzedArgs
- type FetchUnanalyzedResult
- type FindingSpan
- type MCPMatchLookup
- type MarkMessagesAnalyzed
- type MarkMessagesAnalyzedArgs
- type MessageVerdict
- type MessageView
- type PIIScanner
- type PolicyForAnalysis
- type PresidioClient
- type PresidioConfig
- type RecommendedSet
- type StubPIIScanner
- type ToolView
Constants ¶
const ( // SourceGitleaks is the policy source value for secret scanning. SourceGitleaks = gitleaks.Source // SourceCLIDestructive is the policy source value that flags tool calls // whose arguments contain a curated destructive CLI command pattern // (rm -rf, git push --force, DROP TABLE, ...). It is content-driven // instead of annotation-driven and applies to native tools (Bash, // run_terminal_cmd) as well as MCP-routed calls whose arguments happen to // carry a destructive payload. SourceCLIDestructive = clidestructive.Source // SourceAccountIdentity is the policy source value flagging sessions // authenticated with a non-corporate AI account. Unlike the content // scanners it inspects the chat's account attribution (personal-account // tracking data on user_accounts), not the message text. SourceAccountIdentity = accountidentity.Source // SourcePromptInjection is the policy source value for prompt injection scanning. SourcePromptInjection = promptinjection.Source // SourceNone marks the sentinel row for an analyzed message with no findings. SourceNone = "none" // PolicyTypeStandard evaluates configured detector sources. PolicyTypeStandard = "standard" // PolicyTypePromptBased evaluates a natural-language prompt with the judge. PolicyTypePromptBased = "prompt_based" )
const ( // DeadLetterRuleID is the rule id emitted for Presidio dead-letter // sentinel rows when a message could not be analyzed. DeadLetterRuleID = prefixPII + "dead_letter" )
const DefaultPresidioScoreThreshold = 0.5
DefaultPresidioScoreThreshold is the minimum recognizer confidence applied when a policy does not pin its own presidio_score_threshold.
const SourceCustom = "custom"
const SourcePresidio = "presidio"
SourcePresidio is the source label written on every risk_results row produced by the Presidio path, including dead-letter sentinels.
Variables ¶
This section is empty.
Functions ¶
func ApprovedEmailDomainsFromConfig ¶
ApprovedEmailDomainsFromConfig returns the configured corporate email domain allowlist, or nil when unset.
func BuiltinPresetsEnabledFromConfig ¶
BuiltinPresetsEnabledFromConfig reports whether scan-time suppression of catalog false positives is enabled. It defaults ON: absent/unset config returns true, and only an explicit stored false disables it.
func CanonicalPresidioRuleID ¶
CanonicalPresidioRuleID converts a Presidio entity type (UPPER_SNAKE) to the canonical `pii.<snake_case>` rule id (`MEDICAL_LICENSE` -> `pii.medical_license`).
func CompileDetectionScopes ¶
func CompileDetectionScopes(eng *celenv.Engine, specs []DetectionScopeConfig) (map[categories.Category]CompiledScope, error)
CompileDetectionScopes compiles a policy's specified per-category detection scopes. A specified category replaces its registry recommendation; a scope with no predicates (both CEL fields empty) is inert and admits every message surface.
func DescribePresidioDeadLetter ¶
DescribePresidioDeadLetter returns the canonical (rule_id, description) for a Presidio dead-letter sentinel row.
func DescribePresidioEntity ¶
DescribePresidioEntity returns the canonical (rule_id, description) for a Presidio finding. rawEntityType is Presidio's UPPER_SNAKE entity name.
func PresidioScoreThresholdFromConfig ¶
PresidioScoreThresholdFromConfig returns the configured presidio score threshold, or 0 when unset. Callers treat 0 as "apply the default" (see resolvePresidioScoreThreshold).
func PresidioScoreThresholdPtr ¶
PresidioScoreThresholdPtr returns the configured threshold as *float64 for API result mapping, nil when unset.
func ScanCELRules ¶
func ScanCELRules(eng *celenv.Engine, view MessageView, rules []CompiledCELRule) ([]scanners.Finding, error)
ScanCELRules evaluates custom detector rules over a message view.
func SourceCategories ¶
func SourceCategories(source string) []categories.Category
SourceCategories returns the categories a detector source can emit.
func WithApprovedEmailDomains ¶
WithApprovedEmailDomains returns analyzer_config JSON with account_identity.approved_email_domains set to v, or cleared when v is empty. Only fields known to AnalyzerConfig are round-tripped; any unrecognized keys in base are dropped.
func WithDetectionScopes ¶
func WithDetectionScopes(base []byte, v []DetectionScopeConfig) ([]byte, error)
WithDetectionScopes returns analyzer_config JSON with detection_scopes set to v, or cleared when v is empty. Only fields known to AnalyzerConfig are round-tripped; any unrecognized keys in base are dropped.
func WithPresidioScoreThreshold ¶
WithPresidioScoreThreshold returns analyzer_config JSON with presidio.score_threshold set to v, or cleared when v is nil. Only fields known to AnalyzerConfig are round-tripped; any unrecognized keys in base are dropped.
Types ¶
type AccountIdentityConfig ¶
type AccountIdentityConfig struct {
// ApprovedEmailDomains is the corporate email domain allowlist. When
// non-empty, sessions whose AI-account email domain is not in the list
// produce an identity.unapproved_domain finding. Empty means the domain
// rule is inert.
ApprovedEmailDomains []string `json:"approved_email_domains,omitempty"`
}
AccountIdentityConfig holds account_identity-scanner options.
type AnalyzeBatch ¶
type AnalyzeBatch struct {
// contains filtered or unexported fields
}
AnalyzeBatch scans a batch of messages against one risk policy and replaces that policy's stored results for the fetched message IDs.
func NewAnalyzeBatch ¶
func NewAnalyzeBatch( logger *slog.Logger, tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, db *pgxpool.Pool, piiScanner PIIScanner, promptInjectionScanner *promptinjection.Scanner, shadowMCPClient *shadowmcp.Client, mcpMatchLookup MCPMatchLookup, judge promptpolicy.Evaluator, flags feature.Provider, presidioPub gcp.Publisher[*riskv1.PresidioAnalysis], gitleaksPub gcp.Publisher[*riskv1.GitleaksAnalysis], promptInjectionPub gcp.Publisher[*riskv1.PromptInjectionAnalysis], promptPolicyPub gcp.Publisher[*riskv1.PromptPolicyAnalysis], customRulesPub gcp.Publisher[*riskv1.CustomRulesAnalysis], customRuleScanner *customruleanalyzer.Scanner, celEng *celenv.Engine, builtinPresets *presetlib.Library, ) (*AnalyzeBatch, error)
func (*AnalyzeBatch) Do ¶
func (a *AnalyzeBatch) Do(ctx context.Context, args AnalyzeBatchArgs) (_ *AnalyzeBatchResult, err error)
type AnalyzeBatchArgs ¶
type AnalyzeBatchArgs struct {
ProjectID uuid.UUID
OrganizationID string
RiskPolicyID uuid.UUID
PolicyVersion int64
MessageIDs []uuid.UUID
Sources []string
MessageTypes []string
PresidioEntities []string
// PresidioScoreThreshold is the per-policy minimum recognizer confidence
// (0.0-1.0). Do derives it from the refetched policy's analyzer_config, so it
// is not a caller input; zero means unset and the scanner applies
// DefaultPresidioScoreThreshold.
PresidioScoreThreshold float64
CustomRuleIds []string
// ApprovedEmailDomains is the account_identity corporate domain allowlist.
// Like PresidioScoreThreshold, Do derives it from the refetched policy's
// analyzer_config, so it is not a caller input.
ApprovedEmailDomains []string
// BuiltinPresetsEnabled toggles scan-time suppression of built-in catalog
// false positives. Do derives it from the refetched policy's analyzer_config
// (defaulting ON), so it is not a caller input.
BuiltinPresetsEnabled bool
// DetectionScopes are the policy's specified per-category detection scopes,
// each replacing its registry recommendation. Do derives it from the
// refetched policy's analyzer_config, so it is not a caller input.
DetectionScopes []DetectionScopeConfig
}
type AnalyzeBatchResult ¶
type AnalyzerConfig ¶
type AnalyzerConfig struct {
Presidio *PresidioConfig `json:"presidio,omitempty"`
BuiltinPresets *BuiltinPresetsConfig `json:"builtin_presets,omitempty"`
AccountIdentity *AccountIdentityConfig `json:"account_identity,omitempty"`
DetectionScopes []DetectionScopeConfig `json:"detection_scopes,omitempty"`
}
AnalyzerConfig is the opaque per-analyzer scanner configuration persisted on risk_policies.analyzer_config (JSONB), namespaced by analyzer. New per-scanner options live here rather than as a dedicated column each.
func ParseAnalyzerConfig ¶
func ParseAnalyzerConfig(b []byte) AnalyzerConfig
ParseAnalyzerConfig decodes the JSONB blob, returning a zero config for nil/empty/invalid input.
type BuiltinPresetsConfig ¶
type BuiltinPresetsConfig struct {
// Enabled toggles scan-time suppression of catalog false positives. Absent
// means "unset" — callers default to ON (see BuiltinPresetsEnabledFromConfig).
Enabled *bool `json:"enabled,omitempty"`
}
BuiltinPresetsConfig holds options for the built-in false-positive preset catalog applied at scan-time across all detection sources.
type CategoryScope ¶
type CategoryScope struct {
// contains filtered or unexported fields
}
CategoryScope is the single-message composition used by realtime enforcement: policy-specified detection scopes merged over registry recommendations, specified winning per category.
func NewCategoryScope ¶
func NewCategoryScope(policy CompiledScope, rec RecommendedSet, specified map[categories.Category]CompiledScope, enabled bool) CategoryScope
NewCategoryScope builds a single-message category scope. Its zero value is policy scope only.
func (CategoryScope) FilterFindings ¶
func (s CategoryScope) FilterFindings(view MessageView, findings []scanners.Finding) []scanners.Finding
FilterFindings drops findings whose classified category is out of scope.
func (CategoryScope) InScope ¶
func (s CategoryScope) InScope(view MessageView, cat categories.Category) bool
InScope reports whether view is in scope for cat.
func (CategoryScope) SourceInScope ¶
func (s CategoryScope) SourceInScope(view MessageView, source string) bool
SourceInScope reports whether view is in scope for at least one category the source can emit. Unknown sources are admitted so new scanner sources do not fail closed before they are added to sourceCategories.
type CategoryScopeMasks ¶
type CategoryScopeMasks struct {
// contains filtered or unexported fields
}
CategoryScopeMasks contains per-message policy and category scope exclusions.
func (CategoryScopeMasks) AdmitsAny ¶
func (m CategoryScopeMasks) AdmitsAny(i int, cats []categories.Category) bool
func (CategoryScopeMasks) InScope ¶
func (m CategoryScopeMasks) InScope(i int, cat categories.Category) bool
func (CategoryScopeMasks) RecommendedPrefilteredCount ¶
func (m CategoryScopeMasks) RecommendedPrefilteredCount(cats []categories.Category) int
func (CategoryScopeMasks) Subset ¶
func (m CategoryScopeMasks) Subset(messages []batchMessage, contents []string, cats []categories.Category) ([]batchMessage, []string, []int)
type CategoryScopes ¶
type CategoryScopes struct {
// contains filtered or unexported fields
}
CategoryScopes is the per-batch composition of per-category detection scopes: policy-specified scopes merged over registry recommendations, with the specified scope winning per category. The legacy policy scope still intersects while `scope_include`/`scope_exempt` remain on policy rows. Nil-safe zero value = policy scope only.
func NewCategoryScopes ¶
func NewCategoryScopes(policy CompiledScope, rec RecommendedSet, specified map[categories.Category]CompiledScope, enabled bool, metrics *riskMetrics) CategoryScopes
func (CategoryScopes) Masks ¶
func (s CategoryScopes) Masks(_ context.Context, messages []batchMessage) CategoryScopeMasks
Masks computes the policy-scope mask and per-category detection scope masks for the batch. Identical CEL programs are evaluated once per message and shared by every category using that program.
type CompiledCELRule ¶
type CompiledCELRule struct {
// contains filtered or unexported fields
}
CompiledCELRule is a custom rule whose detection predicate is compiled once.
func CompileCELRules ¶
func CompileCELRules(eng *celenv.Engine, rules []customrules.Rule) ([]CompiledCELRule, error)
CompileCELRules compiles each rule's detection predicate.
type CompiledScope ¶
type CompiledScope struct {
// contains filtered or unexported fields
}
CompiledScope is a policy's compiled scope predicates.
func CompileScope ¶
func CompileScope(eng *celenv.Engine, includeCEL, exemptCEL string) (CompiledScope, error)
CompileScope compiles a policy's scope predicates.
func (CompiledScope) Active ¶
func (s CompiledScope) Active() bool
Active reports whether the scope has any predicate to evaluate.
func (CompiledScope) Exempts ¶
func (s CompiledScope) Exempts(view MessageView) bool
Exempts reports whether a message is exempted.
func (CompiledScope) InScope ¶
func (s CompiledScope) InScope(view MessageView) (bool, error)
InScope reports whether a message passes include and does not match exempt.
func (CompiledScope) Includes ¶
func (s CompiledScope) Includes(view MessageView) bool
Includes reports whether a message is in scope.
type DetectionScopeConfig ¶
type DetectionScopeConfig struct {
Category string `json:"category"`
ScopeInclude string `json:"scope_include,omitempty"`
ScopeExempt string `json:"scope_exempt,omitempty"`
}
DetectionScopeConfig specifies one category's detection scope. A specified category replaces its registry recommendation; both fields empty means the category scans every message surface.
func DetectionScopesFromConfig ¶
func DetectionScopesFromConfig(b []byte) []DetectionScopeConfig
DetectionScopesFromConfig returns the policy's specified per-category detection scopes, or nil when none are specified.
type DisabledRuleSet ¶
type DisabledRuleSet struct {
// contains filtered or unexported fields
}
DisabledRuleSet is a lookup set of canonical rule_ids the policy author has unchecked within otherwise-enabled categories. The scanner pipeline calls FilterFindings after each scanner returns to drop matching findings before they reach the dedup/write path. Empty set is a no-op.
func NewDisabledRuleSet ¶
func NewDisabledRuleSet(disabled []string) DisabledRuleSet
NewDisabledRuleSet builds a lookup from the policy's disabled_rules column. nil and empty slices both produce a zero-cost no-op set.
func (DisabledRuleSet) Contains ¶
func (d DisabledRuleSet) Contains(ruleID string) bool
Contains reports whether ruleID is in the disabled set.
func (DisabledRuleSet) Empty ¶
func (d DisabledRuleSet) Empty() bool
Empty reports whether the set carries any disabled rule_ids.
func (DisabledRuleSet) FilterFindings ¶
func (d DisabledRuleSet) FilterFindings(in []scanners.Finding) []scanners.Finding
FilterFindings returns a new slice with findings whose RuleID is in the disabled set removed. Returns the input slice unchanged when the set is empty so callers can call this unconditionally.
type EvalMessage ¶
EvalMessage is a recorded chat message fed to the guardrail-eval replay. It is deliberately row-agnostic (built from primitive columns) so callers outside this package can drive the replay without importing the risk repo row type.
type ExclusionSet ¶
type ExclusionSet struct {
// contains filtered or unexported fields
}
ExclusionSet evaluates risk exclusions against findings. It mirrors DisabledRuleSet: the scanner pipeline calls FilterFindings to drop findings an exclusion suppresses before they reach the write path (going-forward suppression). The same matching logic is mirrored in SQL by the retroactive reconcile sweep so existing findings are flagged consistently.
An exclusion's rule_id_filter / source_filter narrow which findings it applies to; an empty filter means "any". match_type selects the comparison:
exact finding.Match == value regex value (RE2) matches finding.Match rule_id finding.RuleID == value source finding.Source == value entity_type finding.RuleID == "pii." + lower(value)
func NewExclusionSet ¶
func NewExclusionSet(exclusions []repo.RiskExclusion) ExclusionSet
NewExclusionSet builds a set from the enabled exclusions that apply to a policy (its own plus any global ones). A regex that fails to compile is skipped defensively — patterns are validated at create/update time.
func (ExclusionSet) Empty ¶
func (s ExclusionSet) Empty() bool
Empty reports whether the set carries any exclusions.
func (ExclusionSet) Excluded ¶
func (s ExclusionSet) Excluded(f scanners.Finding) bool
Excluded reports whether any exclusion suppresses the finding.
func (ExclusionSet) ExcludedBy ¶
ExcludedBy returns the id of the first exclusion that suppresses the finding, and whether one did. Rules are evaluated in the order they were loaded, so the returned id is the earliest-matching exclusion.
func (ExclusionSet) FilterFindings ¶
func (s ExclusionSet) FilterFindings(in []scanners.Finding) []scanners.Finding
FilterFindings returns a new slice with excluded findings removed. Returns the input unchanged when the set is empty so callers can call it unconditionally.
type FetchUnanalyzed ¶
type FetchUnanalyzed struct {
// contains filtered or unexported fields
}
FetchUnanalyzed retrieves all active policies for a project and the batch of chat message IDs that have not yet been marked as analyzed (risk_analyzed_at IS NULL) within the configured lookback window.
func NewFetchUnanalyzed ¶
func NewFetchUnanalyzed(logger *slog.Logger, tracerProvider trace.TracerProvider, db *pgxpool.Pool) *FetchUnanalyzed
func (*FetchUnanalyzed) Do ¶
func (a *FetchUnanalyzed) Do(ctx context.Context, args FetchUnanalyzedArgs) (_ *FetchUnanalyzedResult, err error)
type FetchUnanalyzedArgs ¶
type FetchUnanalyzedResult ¶
type FetchUnanalyzedResult struct {
MessageIDs []uuid.UUID
Policies []PolicyForAnalysis
}
type FindingSpan ¶
type FindingSpan struct {
Match string `json:"match"`
// Field is the author-facing message field the span matched.
Field string `json:"field,omitempty"`
// Path is the gjson sub-path within Field for `.get(...)` matches.
Path string `json:"path,omitempty"`
StartPos int `json:"start_pos"`
EndPos int `json:"end_pos"`
}
FindingSpan is one matched span attributed to a finding.
type MCPMatchLookup ¶
type MCPMatchLookup interface {
LookupMCPMatchesByToolCallID(ctx context.Context, projectID uuid.UUID, toolCallIDs []string) (map[string]string, error)
}
MCPMatchLookup resolves stored tool-call IDs to MCP match strings. It is the risk_analysis-facing name for shadowmcpscan.MatchLookup, kept here because it is part of the NewAnalyzeBatch constructor signature.
type MarkMessagesAnalyzed ¶
type MarkMessagesAnalyzed struct {
// contains filtered or unexported fields
}
MarkMessagesAnalyzed sets risk_analyzed_at on a batch of chat messages after all active policies have completed analysis (fan-in step).
func NewMarkMessagesAnalyzed ¶
func NewMarkMessagesAnalyzed(logger *slog.Logger, tracerProvider trace.TracerProvider, db *pgxpool.Pool) *MarkMessagesAnalyzed
func (*MarkMessagesAnalyzed) Do ¶
func (a *MarkMessagesAnalyzed) Do(ctx context.Context, args MarkMessagesAnalyzedArgs) (err error)
type MessageVerdict ¶
type MessageVerdict struct {
Index int
Type message.Type
ToolName string
LatencyMs int64
promptpolicy.Verdict
}
MessageVerdict is the judge's verdict for one in-scope EvalMessage. Index points back into the input slice so callers can attach message metadata.
func EvalPromptGuardrail ¶
func EvalPromptGuardrail( ctx context.Context, logger *slog.Logger, judge promptpolicy.Evaluator, eng *celenv.Engine, orgID, projectID, prompt string, cfg promptpolicy.Config, messages []EvalMessage, messageTypes []string, includeCEL, exemptCEL string, ) ([]MessageVerdict, error)
EvalPromptGuardrail replays a prompt_based guardrail against a sequence of chat messages and returns one verdict per in-scope message, ordered by input index. It reuses the exact role-to-type mapping, tool-call flattening, and judge prompt the batch analyzer runs, so a workbench replay matches production judging. It performs no writes, enforcement, or outbox side effects.
Scoping is by message_types and CEL scope predicates; when both are empty every supported message is judged.
type MessageView ¶
MessageView is the structured input the CEL engine evaluates against.
type PIIScanner ¶
type PIIScanner interface {
// AnalyzeBatch sends multiple texts to the PII analyzer and returns
// findings for each. The outer slice is indexed by input position.
// When entities is non-empty, only those entity types are detected.
//
// scoreThreshold is the minimum recognizer confidence a match must clear
// to be returned. A value <=0 or >1 is treated as unset and the default
// (DefaultPresidioScoreThreshold) is applied.
//
// Permanent per-message failures surface as a single Finding with
// DeadLetterReason populated rather than as an error; the returned
// error is non-nil only on outer-ctx cancellation.
AnalyzeBatch(ctx context.Context, texts []string, entities []string, scoreThreshold float64, onProgress func()) ([][]scanners.Finding, error)
}
PIIScanner detects personally identifiable information in text.
type PolicyForAnalysis ¶
type PolicyForAnalysis struct {
ID uuid.UUID
OrganizationID string
Version int64
Sources []string
MessageTypes []string
PresidioEntities []string
CustomRuleIds []string
}
PolicyForAnalysis carries the policy metadata the coordinator needs to construct AnalyzeBatchArgs for each active policy.
type PresidioClient ¶
type PresidioClient struct {
// contains filtered or unexported fields
}
PresidioClient is the production PIIScanner implementation, calling the Presidio Analyzer HTTP API.
AnalyzeBatch fans the input texts out to per-text goroutines and retries each one up to retryMaxAttempts times. Total in-flight HTTP request bytes are bounded by a process-shared byte-budget semaphore, and while blocked on the semaphore the client calls onProgress on a fixed cadence so the Temporal activity heartbeat stays alive.
Presidio is a trusted cluster-internal service, so the client uses an unsafe guardian policy with an empty blocklist. The default policy blocks RFC 1918 private ranges (10.0.0.0/8) which Kubernetes ClusterIPs fall into.
func NewPresidioClient ¶
func NewPresidioClient(baseURL string, tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, logger *slog.Logger) *PresidioClient
NewPresidioClient creates a client pointing at the given base URL.
func (*PresidioClient) AnalyzeBatch ¶
func (p *PresidioClient) AnalyzeBatch(ctx context.Context, texts []string, entities []string, scoreThreshold float64, onProgress func()) (_ [][]scanners.Finding, err error)
AnalyzeBatch fans the input texts out to per-text goroutines, retries each up to maxAttempts times against /analyze, and returns a results slice indexed by input position. Texts that exhaust the retry budget are returned as a single Finding with DeadLetterReason set so the caller can persist a dead-letter row.
Returns a non-nil error only on outer-ctx cancellation. Per-message failures surface as DeadLetterReason sentinels so the rest of the batch can still write.
type PresidioConfig ¶
type PresidioConfig struct {
// ScoreThreshold is the minimum recognizer confidence (0.0-1.0) a match must
// clear. Absent means "unset" — the scanner applies DefaultPresidioScoreThreshold.
ScoreThreshold *float64 `json:"score_threshold,omitempty"`
}
PresidioConfig holds presidio-scanner options.
type RecommendedSet ¶
type RecommendedSet struct {
// contains filtered or unexported fields
}
RecommendedSet holds the registry's scopes compiled once against the shared celenv engine. Built in the AnalyzeBatch constructor; a bad registry entry fails fast at worker boot.
func CompileRecommended ¶
func CompileRecommended(eng *celenv.Engine) (RecommendedSet, error)
CompileRecommended compiles the centrally maintained category scope registry.
type StubPIIScanner ¶
type StubPIIScanner struct{}
StubPIIScanner is a no-op implementation for environments without Presidio.
type ToolView ¶
ToolView is one tool invocation surfaced from a message's recorded tool calls.
func NewToolView ¶
NewToolView destructures a tool-call name and pairs it with raw arguments.
Source Files
¶
- analyze_batch.go
- analyzer_config.go
- batch_messages.go
- batch_publish.go
- batch_scanners.go
- builtin.go
- category_scopes.go
- celadapter.go
- disabled_rules.go
- eval_guardrail.go
- exclusions.go
- fetch_unanalyzed.go
- finding.go
- mark_analyzed.go
- message_view.go
- metrics.go
- presidio.go
- prompt_judge_batch.go
- risk_result_writer.go
- rules.go
- scan_account_identity.go
- scan_custom_rules.go
- scan_gitleaks.go
- scan_presidio.go
- scan_prompt_injection.go
- scan_tool_calls.go
- sources.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package presidiotest provides an in-process mock of the Presidio Analyzer HTTP API.
|
Package presidiotest provides an in-process mock of the Presidio Analyzer HTTP API. |