Documentation
¶
Overview ¶
Package ai adds optional AI explanations through the Vercel AI Gateway's OpenAI-compatible API. It is off unless configured. Findings are redacted before anything leaves the process: evidence bodies and payloads are never sent, and hosts, emails, IPs, query strings and token-like values are masked in the text that is.
Index ¶
Constants ¶
const ( DefaultBaseURL = "https://ai-gateway.vercel.sh/v1" DefaultModel = "anthropic/claude-sonnet-5.5" // APIKeyEnv is the Gateway's standard environment variable. APIKeyEnv = "AI_GATEWAY_API_KEY" )
Defaults for the Vercel AI Gateway (OpenAI-compatible Chat Completions).
Variables ¶
var ErrDisabled = errors.New("ai: not configured (set ai.enabled and AI_GATEWAY_API_KEY)")
ErrDisabled is returned when AI is not configured.
Functions ¶
Types ¶
type Answer ¶
Answer is a model reply plus the exact redacted data that was sent, so users can see what left the process.
type Client ¶
Client calls a model through the Vercel AI Gateway.
type RedactedFinding ¶
type RedactedFinding struct {
CheckID string `json:"check_id"`
Title string `json:"title"`
Category string `json:"category"`
Severity string `json:"severity"`
Confidence string `json:"confidence"`
AssetKind string `json:"asset_kind"`
Asset string `json:"asset"` // host masked, query dropped
CWE []string `json:"cwe,omitempty"`
OWASP []string `json:"owasp,omitempty"`
What string `json:"what,omitempty"`
Why string `json:"why,omitempty"`
FixStacks []string `json:"fix_stacks,omitempty"`
Effort string `json:"effort,omitempty"`
}
RedactedFinding is everything about a finding that may be sent to a model.
func Finding ¶
func Finding(f core.Finding) RedactedFinding
Finding builds the redacted view of a finding. Evidence (request, response, matched payload, config lines) is deliberately omitted.
type TargetSummary ¶
type TargetSummary struct {
Target string `json:"target"` // the configured target name, not its URL
Environment string `json:"environment"`
Grade string `json:"grade"`
Score float64 `json:"score"`
Open map[string]int `json:"open_by_severity"`
Caps []string `json:"grade_caps,omitempty"`
TopFixes []RedactedFinding `json:"top_fixes,omitempty"`
}
TargetSummary is the redacted per-target input to a stakeholder summary.