Skip to content

feat(search): add vulnerabilities vertical with NVD and OSV engines#217

Open
Oscar-SR wants to merge 4 commits into
KnockOutEZ:mainfrom
Oscar-SR:feat/vulnerability-vertical
Open

feat(search): add vulnerabilities vertical with NVD and OSV engines#217
Oscar-SR wants to merge 4 commits into
KnockOutEZ:mainfrom
Oscar-SR:feat/vulnerability-vertical

Conversation

@Oscar-SR

@Oscar-SR Oscar-SR commented Jul 20, 2026

Copy link
Copy Markdown

What & why

Adds a dedicated vulnerabilities search vertical with two new engine adapters (NVD and OSV), so queries containing CVE/GHSA identifiers or vulnerability-related keywords are routed to authoritative vulnerability databases instead of general web search engines.

Previously, searching for "CVE-2024-21626" or "python vulnerability log4j" would fall through to general engines like Bing and DuckDuckGo, yielding inconsistent results. This change gives Wigolo users direct access to structured, sourced vulnerability data from NIST NVD and OSV.dev.

Changes

  • src/search/core/intent-router.ts: Extended Vertical type with vulnerabilities; added VULN_RE regex and CVE/GHSA pattern matching before the code and general branches so vulnerability queries take priority
  • src/search/engines/nvd.ts: New engine adapter for the NIST NVD CVE API 2.0; supports keyword search, client-side date filtering; no API key required
  • src/search/engines/osv.ts: New engine adapter for the OSV.dev API; supports direct CVE/GHSA lookups and heuristic package+ecosystem extraction (PyPI, npm, Go, crates.io, Maven, etc.)
  • src/search/core/verticals/vulnerabilities.ts: New vertical definition mapping NVD (weight 1.2, high quality) and OSV (weight 0.9, medium quality) with date filter support
  • src/search/core/orchestrator.ts: Registered vulnerabilities case in getEntriesForVertical() and added import
  • src/search/core/engine-health.ts: Registered in verticalPools() for diagnostics
  • tests/unit/search/core/vuln-routing.test.ts: 5 tests for routing accuracy and edge cases
  • tests/unit/search/engines/nvd.test.ts: 7 tests for response parsing, date filtering, error handling
  • tests/unit/search/engines/osv.test.ts: 11 tests for package extraction, ID lookups, 404 handling, date filtering

Testing

  • npm test passes (23 new tests across 3 files)
  • npm run lint passes
  • Added/updated tests for the new behavior

Checklist

  • Follows Conventional Commits
  • Focused change (no unrelated refactoring)
  • I have read CONTRIBUTING.md and agree to its contribution terms

Summary by CodeRabbit

  • New Features
    • Added a vulnerability-focused search category that recognizes CVE/GHSA identifiers and security-related query language to route results.
    • Introduced vulnerability search engines for NVD and OSV, supporting identifier and package-based lookups, optional date filtering, result limits, and normalized output.
    • Updated engine health/probing and engine quality tiering to include vulnerabilities.
  • Tests
    • Added intent-routing tests for CVE/GHSA and vulnerability keywords (including override/precedence behavior).
    • Added unit tests for NVD and OSV query handling, parsing, date filtering, and HTTP/error scenarios.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d96deb03-841b-4e77-bd59-aac13ca7957e

📥 Commits

Reviewing files that changed from the base of the PR and between cc18bbf and c6d302d.

📒 Files selected for processing (5)
  • src/search/core/intent-router.ts
  • src/search/engines/nvd.ts
  • src/search/engines/osv.ts
  • tests/unit/search/engines/nvd.test.ts
  • tests/unit/search/engines/osv.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/unit/search/engines/nvd.test.ts
  • tests/unit/search/engines/osv.test.ts
  • src/search/core/intent-router.ts
  • src/search/engines/osv.ts

📝 Walkthrough

Walkthrough

Changes

The search system adds a vulnerabilities vertical with intent classification, NVD and OSV engines, lazy engine registration, orchestration dispatch, engine health visibility, quality tiers, date filtering, and unit tests.

Vulnerability search

Layer / File(s) Summary
Intent contracts and classification
src/types.ts, src/search/core/intent-router.ts, tests/unit/search/core/vuln-routing.test.ts
Vulnerability identifiers and security-related queries route to the new vertical, which is added to shared intent and category types.
NVD and OSV engines
src/search/engines/nvd.ts, src/search/engines/osv.ts, tests/unit/search/engines/*
NVD and OSV requests are normalized into search results with timeout handling, HTTP errors, result limits, and date filtering.
Vertical registration and dispatch
src/search/core/verticals/vulnerabilities.ts, src/search/core/orchestrator.ts, src/search/core/engine-health.ts, src/search/core/engine-quality.ts
Wrapped NVD and OSV engines are lazily registered, dispatched for vulnerability searches, included in health inspection, and assigned quality tiers.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant IntentRouter
  participant Orchestrator
  participant NVD
  participant OSV
  Client->>IntentRouter: vulnerability query
  IntentRouter-->>Orchestrator: vulnerabilities vertical
  Orchestrator->>NVD: search(query, options)
  Orchestrator->>OSV: search(query, options)
  NVD-->>Orchestrator: normalized results
  OSV-->>Orchestrator: normalized results
  Orchestrator-->>Client: vulnerability search results
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a new vulnerabilities search vertical backed by NVD and OSV engines.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/search/engines/osv.ts (1)

115-154: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

extractQuery's noise-stripping is too narrow — generic vulnerability queries dispatch garbage package lookups.

Tracing the routing test's own example queries through this heuristic: "recent exploit in openssl" → package name "recent in openssl"; "microsoft patch tuesday" → package name "microsoft patch tuesday"; "what is cwe-79" → package name "what is cwe-79". None of these are plausible OSV package names — this fires a POST to /v1/query that will reliably return nothing, on what looks like the majority of non-ID vulnerability queries.

Consider bailing out (return null) when no known ecosystem token was found and the remaining "package name" still has more than 1-2 tokens, or extend noiseRe with a broader stop-word list.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/search/engines/osv.ts` around lines 115 - 154, Update extractQuery so
generic vulnerability questions do not become OSV package lookups: after
tokenization, require a recognized ecosystem or a plausible one-to-two-token
package name, and return null for longer package names without an ecosystem.
Preserve valid ID extraction and ecosystem-qualified package queries.
src/search/engines/nvd.ts (1)

29-62: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Use NVD's exact CVE lookup path for bare CVE queries instead of always falling back to keywordSearch.

For canonical IDs, query cveIds directly; the fuzzy search is less precise and can miss the exact record. It also avoids unnecessary load on NVD for the most common exact-ID path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/search/engines/nvd.ts` around lines 29 - 62, Update search in the NVD
engine to detect canonical bare CVE IDs and send them via the cveIds query
parameter instead of keywordSearch. Preserve keywordSearch for all other
queries, while retaining the existing result limits, request flow, parsing, and
date filtering.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/search/core/intent-router.ts`:
- Around line 34-35: The GHSA detection in the intent-routing logic only
recognizes standalone IDs, so embedded GHSA queries miss the vulnerabilities
route. Update the GHSA matching used by the router to detect valid GHSA IDs
within longer queries, while preserving the existing ID format validation, and
add a routing test for a query such as “explain GHSA-abcd-1234-efgh” that
expects vulnerabilities.

---

Nitpick comments:
In `@src/search/engines/nvd.ts`:
- Around line 29-62: Update search in the NVD engine to detect canonical bare
CVE IDs and send them via the cveIds query parameter instead of keywordSearch.
Preserve keywordSearch for all other queries, while retaining the existing
result limits, request flow, parsing, and date filtering.

In `@src/search/engines/osv.ts`:
- Around line 115-154: Update extractQuery so generic vulnerability questions do
not become OSV package lookups: after tokenization, require a recognized
ecosystem or a plausible one-to-two-token package name, and return null for
longer package names without an ecosystem. Preserve valid ID extraction and
ecosystem-qualified package queries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dc58e892-f570-4794-9bc9-82a655e1bfed

📥 Commits

Reviewing files that changed from the base of the PR and between 180ac3d and 6b9a0bf.

📒 Files selected for processing (11)
  • src/search/core/engine-health.ts
  • src/search/core/engine-quality.ts
  • src/search/core/intent-router.ts
  • src/search/core/orchestrator.ts
  • src/search/core/verticals/vulnerabilities.ts
  • src/search/engines/nvd.ts
  • src/search/engines/osv.ts
  • src/types.ts
  • tests/unit/search/core/vuln-routing.test.ts
  • tests/unit/search/engines/nvd.test.ts
  • tests/unit/search/engines/osv.test.ts

Comment thread src/search/core/intent-router.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant