feat(ai): provider-neutral AI layer and AI mitigation advice on findings #67
Loading…
Reference in a new issue
No description provided.
Delete branch "james/ai-mitigation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds AI provider settings (Anthropic API, OpenAI API, custom OpenAI-compatible/local endpoint) and per-finding AI mitigation advice. Keys encrypted and never returned; SSRF-guarded; monthly token limit; usage log. Advice runs in the background, is stored separately from the finding's mitigation, and is applied only on request. See commit message for details.
Adds internal/ai with one Provider interface and three backends, configured per organization under System Settings -> AI: - Anthropic API via the official Go SDK (streamed, structured output, claude-opus-5-5 by default, server-side refusal fallbacks on models that support them) - OpenAI API (Chat Completions with strict json_schema) - any OpenAI-compatible endpoint (Ollama, vLLM, llama.cpp, LM Studio, LiteLLM); falls back to describing the schema in the prompt when a local server rejects response_format The service enforces an optional monthly token limit and a small concurrency cap, and records every request (feature, user, model, tokens, outcome) in ai_usages. API keys are SecretBox-encrypted and never returned; changing the provider or base URL drops a stored key unless a new one is sent, so a key can't be pointed at a new endpoint without re-entering it. All calls go through the outbound SSRF guard, so a local model on a private address needs BALAM_OUTBOUND_ALLOW. First feature: per-finding mitigation advice. Writers generate it from the finding, its product, scan type, endpoints and matching SBOM components; the model returns urgency, steps, fixed version, workarounds, verification, references and a false-positive hint. Generation runs in the background (models can exceed the 60s write timeout) and the UI polls. Advice is kept separate from Finding.Mitigation, marked stale when the finding changes, and copied over only on request. Scanner text is passed as delimited data with instructions not to follow it, and reference links are filtered to http(s). Endpoints: GET /ai/status, GET/PUT /ai/settings, POST /ai/settings/test, GET /ai/usage (admin); GET/POST /findings/{id}/advice, POST /findings/{id}/advice/apply.🔎 ojo scan results
No findings.
Codecov Results 📊
✅ Patch coverage is 100.00%. Project has 5221 uncovered lines.
Generated by Codecov Action