Skip to content

feat: add --explain flag for LLM-powered vulnerability explanations #328

@sonukapoor

Description

@sonukapoor

Summary

Add an opt-in --explain flag that enriches scan findings with plain-English AI explanations, helping developers understand what a vulnerability does and whether they are at risk.

Behaviour

  • cve-lite . --explain — fetches explanations for all findings at or above --min-severity and renders them inline beneath each finding
  • cve-lite . --explain 2 — explains finding by index number
  • cve-lite . --explain CVE-2021-23337 — explains by CVE/OSV ID
  • Explanations fetched in parallel, concurrency capped at 3
  • --explain is mutually exclusive with --offline
  • Config-driven: global ~/.cve-lite/config.json and/or project .cve-lite.json
  • No new npm dependencies — uses Node's built-in fetch

New files

  • src/llm/config.ts — config loader (global + project, project overrides global)
  • src/llm/client.ts — thin HTTPS client for Claude API (retries on 429, timeout handling)
  • src/llm/explainer.ts — prompt builder + concurrency-capped explainer

Output

Terminal: 🤖 emoji prefix inline beneath each finding
HTML report: expandable AI Explanation section
JSON: explanation: string | null field per finding

Config format

{
  "llm": {
    "provider": "claude",
    "providers": {
      "claude": { "apiKey": "sk-ant-..." }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions