Documentation
¶
Index ¶
- Constants
- func DecodeBase64URL(seg string) ([]byte, error)
- func EstimateLLMCost(model string, promptTokens, completionTokens int) float64
- func IsValidLuhn(number string) bool
- func ParseAndInspectJWT(tokenString, requestID, url, method, location string) (*JWTDetails, []*Finding)
- type ACMatch
- type AhoCorasickMatcher
- type AhoCorasickNode
- type AhoCorasickSecretsRule
- type AnalysisWorkerPool
- type BlocklistEntry
- type CORSRule
- type CookieSecurityRule
- type CustomRule
- type CustomRuleConfig
- type CustomRulesDocument
- type Finding
- type GraphQLRule
- type IPBlocklistRule
- type InsecureAuthRule
- type JWTDetails
- type JWTSecurityRule
- type LLMCallTelemetry
- type LLMProvider
- type LLMRule
- type PIIRule
- type RadixNode
- type RadixTrie
- type ResultHandler
- type Rule
- type SecretSignature
- type SecretsRule
- type SecurityHeadersRule
- type SecurityRulesEngine
- type StackTraceRule
Constants ¶
const ( SeverityCritical = "CRITICAL" SeverityHigh = "HIGH" SeverityMedium = "MEDIUM" SeverityLow = "LOW" SeverityInfo = "INFO" )
Severity levels for security findings.
Variables ¶
This section is empty.
Functions ¶
func DecodeBase64URL ¶
DecodeBase64URL decodes base64url data with or without padding.
func EstimateLLMCost ¶
EstimateLLMCost calculates approximate API expenses based on standard 2026 pricing rates.
func IsValidLuhn ¶
IsValidLuhn implements the Luhn formula (mod 10 checksum) used by credit card issuers.
func ParseAndInspectJWT ¶
func ParseAndInspectJWT(tokenString, requestID, url, method, location string) (*JWTDetails, []*Finding)
ParseAndInspectJWT parses, extracts, and runs security lint checks on a JWT token.
Types ¶
type ACMatch ¶
type ACMatch struct {
Signature *SecretSignature
EndIndex int
Snippet string
}
ACMatch records the detection of a secret pattern in the scanned payload.
type AhoCorasickMatcher ¶
type AhoCorasickMatcher struct {
// contains filtered or unexported fields
}
AhoCorasickMatcher provides deterministic O(N + M) streaming multi-keyword secret matching.
func NewAhoCorasickMatcher ¶
func NewAhoCorasickMatcher(signatures []*SecretSignature) *AhoCorasickMatcher
NewAhoCorasickMatcher builds and compiles an automaton from a list of signatures.
func (*AhoCorasickMatcher) ScanBytes ¶
func (m *AhoCorasickMatcher) ScanBytes(data []byte) []ACMatch
ScanBytes performs deterministic linear O(N) multi-pattern search over raw bytes without allocation.
type AhoCorasickNode ¶
type AhoCorasickNode struct {
// contains filtered or unexported fields
}
AhoCorasickNode represents a node in the Aho-Corasick automaton trie.
type AhoCorasickSecretsRule ¶
type AhoCorasickSecretsRule struct {
// contains filtered or unexported fields
}
AhoCorasickSecretsRule wraps the matcher into the standard DevProxy analysis.Rule interface.
func NewAhoCorasickSecretsRule ¶
func NewAhoCorasickSecretsRule() *AhoCorasickSecretsRule
NewAhoCorasickSecretsRule creates a new rule instance.
func (*AhoCorasickSecretsRule) Evaluate ¶
func (r *AhoCorasickSecretsRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*AhoCorasickSecretsRule) Name ¶
func (r *AhoCorasickSecretsRule) Name() string
type AnalysisWorkerPool ¶
type AnalysisWorkerPool struct {
// contains filtered or unexported fields
}
AnalysisWorkerPool manages background worker threads pulling from the ring buffer.
func NewAnalysisWorkerPool ¶
func NewAnalysisWorkerPool(rb *ringbuffer.RingBuffer, engine *SecurityRulesEngine, handler ResultHandler, workers int) *AnalysisWorkerPool
NewAnalysisWorkerPool creates a new pool of analysis workers.
func (*AnalysisWorkerPool) Start ¶
func (p *AnalysisWorkerPool) Start()
Start spawns the background worker goroutines.
func (*AnalysisWorkerPool) Stats ¶
func (p *AnalysisWorkerPool) Stats() (analyzed uint64, findings uint64, avgScanMicroseconds float64)
Stats returns performance metrics of the analysis pool.
func (*AnalysisWorkerPool) Stop ¶
func (p *AnalysisWorkerPool) Stop()
Stop gracefully shuts down the worker pool.
type BlocklistEntry ¶
BlocklistEntry holds metadata for matched CIDRs.
type CORSRule ¶
type CORSRule struct{}
--- Rule 5: Dangerous CORS Configurations ---
func NewCORSRule ¶
func NewCORSRule() *CORSRule
func (*CORSRule) Evaluate ¶
func (r *CORSRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
type CookieSecurityRule ¶
type CookieSecurityRule struct{}
--- Rule 2: Insecure Cookie Configuration ---
func NewCookieSecurityRule ¶
func NewCookieSecurityRule() *CookieSecurityRule
func (*CookieSecurityRule) Evaluate ¶
func (r *CookieSecurityRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*CookieSecurityRule) Name ¶
func (r *CookieSecurityRule) Name() string
type CustomRule ¶
type CustomRule struct {
// contains filtered or unexported fields
}
CustomRule evaluates traffic against user-defined regexes from YAML.
func NewCustomRule ¶
func NewCustomRule(cfg CustomRuleConfig) (*CustomRule, error)
NewCustomRule constructs a CustomRule from config.
func (*CustomRule) Evaluate ¶
func (r *CustomRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*CustomRule) Name ¶
func (r *CustomRule) Name() string
type CustomRuleConfig ¶
type CustomRuleConfig struct {
Name string `yaml:"name"`
Category string `yaml:"category"`
Severity string `yaml:"severity"`
Regex string `yaml:"regex"`
Description string `yaml:"description"`
Remediation string `yaml:"remediation"`
Location string `yaml:"location"` // "all", "request_body", "response_body", "headers", "url"
}
CustomRuleConfig represents a single rule definition in YAML.
type CustomRulesDocument ¶
type CustomRulesDocument struct {
Rules []CustomRuleConfig `yaml:"rules"`
}
CustomRulesDocument is the top-level YAML file format.
type Finding ¶
type Finding struct {
ID string `json:"id"`
RequestID string `json:"request_id"`
Timestamp time.Time `json:"timestamp"`
Severity string `json:"severity"`
Category string `json:"category"`
RuleName string `json:"rule_name"`
Title string `json:"title"`
Description string `json:"description"`
Evidence string `json:"evidence"`
Location string `json:"location"` // e.g. "Response Header: Set-Cookie", "Request Body", etc.
Remediation string `json:"remediation"`
URL string `json:"url"`
Method string `json:"method"`
}
Finding represents a detected vulnerability or security misconfiguration.
type GraphQLRule ¶
type GraphQLRule struct{}
GraphQLRule passively inspects GraphQL queries and responses for security anti-patterns.
func NewGraphQLRule ¶
func NewGraphQLRule() *GraphQLRule
NewGraphQLRule creates a new rule instance.
func (*GraphQLRule) Evaluate ¶
func (r *GraphQLRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*GraphQLRule) Name ¶
func (r *GraphQLRule) Name() string
type IPBlocklistRule ¶
type IPBlocklistRule struct {
// contains filtered or unexported fields
}
--- Rule 7: Radix Trie IP/CIDR Blocklist ---
func NewIPBlocklistRule ¶
func NewIPBlocklistRule(trie *RadixTrie) *IPBlocklistRule
func (*IPBlocklistRule) Evaluate ¶
func (r *IPBlocklistRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*IPBlocklistRule) Name ¶
func (r *IPBlocklistRule) Name() string
type InsecureAuthRule ¶
type InsecureAuthRule struct{}
--- Rule 6: Insecure Authentication over Cleartext HTTP ---
func NewInsecureAuthRule ¶
func NewInsecureAuthRule() *InsecureAuthRule
func (*InsecureAuthRule) Evaluate ¶
func (r *InsecureAuthRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*InsecureAuthRule) Name ¶
func (r *InsecureAuthRule) Name() string
type JWTDetails ¶
type JWTDetails struct {
Raw string `json:"raw"`
Header map[string]interface{} `json:"header"`
Payload map[string]interface{} `json:"payload"`
Signature string `json:"signature"`
Algorithm string `json:"algorithm"`
Type string `json:"type"`
Subject string `json:"subject,omitempty"`
Issuer string `json:"issuer,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
IssuedAt *time.Time `json:"issued_at,omitempty"`
IsExpired bool `json:"is_expired"`
Findings []*Finding `json:"findings"`
}
JWTDetails contains decoded structure and security evaluation of a JSON Web Token.
type JWTSecurityRule ¶
type JWTSecurityRule struct{}
JWTSecurityRule passively inspects all HTTP requests and responses for JWT tokens.
func NewJWTSecurityRule ¶
func NewJWTSecurityRule() *JWTSecurityRule
NewJWTSecurityRule creates a new rule instance.
func (*JWTSecurityRule) Evaluate ¶
func (r *JWTSecurityRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*JWTSecurityRule) Name ¶
func (r *JWTSecurityRule) Name() string
type LLMCallTelemetry ¶
type LLMCallTelemetry struct {
Provider LLMProvider `json:"provider"`
Model string `json:"model"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
EstimatedCostUSD float64 `json:"estimated_cost_usd"`
IsStreaming bool `json:"is_streaming"`
IsLocal bool `json:"is_local"`
}
LLMCallTelemetry encapsulates extracted token counts and cost estimates.
type LLMProvider ¶
type LLMProvider string
LLMProvider identifies the AI/LLM vendor or engine.
const ( ProviderOpenAI LLMProvider = "OpenAI" ProviderAnthropic LLMProvider = "Anthropic" ProviderGemini LLMProvider = "Google Gemini" ProviderOllama LLMProvider = "Ollama (Local)" ProviderGroq LLMProvider = "Groq" ProviderMistral LLMProvider = "Mistral AI" ProviderGeneric LLMProvider = "Generic LLM" )
type LLMRule ¶
type LLMRule struct {
// contains filtered or unexported fields
}
LLMRule passively inspects AI/LLM transactions for token usage, costs, and prompt data leaks.
func NewLLMRule ¶
func NewLLMRule() *LLMRule
NewLLMRule initializes a new AI/LLM traffic inspector rule.
func (*LLMRule) Evaluate ¶
func (r *LLMRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
Evaluate returns prompt-leak, token-consumption, and telemetry findings for recognized LLM traffic, or nil when the event is not an LLM call.
type PIIRule ¶
type PIIRule struct{}
PIIRule passively scans for plaintext financial credentials and sensitive identity numbers.
func (*PIIRule) Evaluate ¶
func (r *PIIRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
type RadixNode ¶
type RadixNode struct {
// contains filtered or unexported fields
}
RadixNode is a node in the bitwise Radix Trie for IP/CIDR matching.
type RadixTrie ¶
type RadixTrie struct {
// contains filtered or unexported fields
}
RadixTrie implements a bitwise Radix Trie for ultra-fast IP/CIDR matching with zero allocations during lookup.
func DefaultBlocklistTrie ¶
func DefaultBlocklistTrie() *RadixTrie
DefaultBlocklistTrie returns a RadixTrie populated with standard sensitive networks (cloud metadata endpoints, internal RFC1918 networks, etc.)
type ResultHandler ¶
type ResultHandler interface {
HandleResult(event *ringbuffer.TrafficEvent, findings []*Finding)
}
ResultHandler is a callback interface for analyzed events and findings.
type Rule ¶
type Rule interface {
Name() string
Evaluate(event *ringbuffer.TrafficEvent) []*Finding
}
Rule defines the interface for evaluating traffic events.
func LoadCustomRulesFromFile ¶
LoadCustomRulesFromFile parses a YAML rules file and compiles each custom rule.
func LoadCustomRulesFromYAML ¶
LoadCustomRulesFromYAML parses YAML bytes into a list of Rule instances.
type SecretSignature ¶
type SecretSignature struct {
ID string `json:"id"`
Pattern string `json:"pattern"`
Category string `json:"category"`
Severity string `json:"severity"`
Description string `json:"description"`
Remediation string `json:"remediation"`
}
SecretSignature defines a sensitive token pattern for Aho-Corasick multi-string scanning.
func DefaultSecretSignatures ¶
func DefaultSecretSignatures() []*SecretSignature
DefaultSecretSignatures provides industry-standard secret patterns for zero-latency detection.
type SecretsRule ¶
type SecretsRule struct {
// contains filtered or unexported fields
}
--- Rule 1: Secrets & Exposed Credentials ---
func NewSecretsRule ¶
func NewSecretsRule() *SecretsRule
func (*SecretsRule) Evaluate ¶
func (r *SecretsRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*SecretsRule) Name ¶
func (r *SecretsRule) Name() string
type SecurityHeadersRule ¶
type SecurityHeadersRule struct{}
--- Rule 4: Missing Security Headers & Information Disclosure ---
func NewSecurityHeadersRule ¶
func NewSecurityHeadersRule() *SecurityHeadersRule
func (*SecurityHeadersRule) Evaluate ¶
func (r *SecurityHeadersRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*SecurityHeadersRule) Name ¶
func (r *SecurityHeadersRule) Name() string
type SecurityRulesEngine ¶
type SecurityRulesEngine struct {
// contains filtered or unexported fields
}
SecurityRulesEngine coordinates and executes security inspection rules on traffic events.
func NewSecurityRulesEngine ¶
func NewSecurityRulesEngine() *SecurityRulesEngine
NewSecurityRulesEngine creates a fully loaded rules engine with built-in security checks.
func (*SecurityRulesEngine) AddRule ¶
func (e *SecurityRulesEngine) AddRule(rule Rule)
AddRule registers a single additional rule.
func (*SecurityRulesEngine) AddRules ¶
func (e *SecurityRulesEngine) AddRules(rules []Rule)
AddRules registers multiple additional rules (e.g. from custom YAML).
func (*SecurityRulesEngine) Analyze ¶
func (e *SecurityRulesEngine) Analyze(event *ringbuffer.TrafficEvent) []*Finding
Analyze runs all rules against a traffic event and returns any findings.
type StackTraceRule ¶
type StackTraceRule struct {
// contains filtered or unexported fields
}
--- Rule 3: Verbose Stack Traces in Responses ---
func NewStackTraceRule ¶
func NewStackTraceRule() *StackTraceRule
func (*StackTraceRule) Evaluate ¶
func (r *StackTraceRule) Evaluate(event *ringbuffer.TrafficEvent) []*Finding
func (*StackTraceRule) Name ¶
func (r *StackTraceRule) Name() string