Repository navigation
feat(web-search): add SearXNG as bundled web search provider plugin - #57317
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d39f101d64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryThis PR adds SearXNG as a bundled web search provider plugin, following the existing DuckDuckGo extension pattern closely. The implementation is well-structured: it uses SearXNG's native JSON API (no HTML scraping), includes proper caching, content-wrapping security markers, full test coverage (unit + 3 contract tests), docs registration, and plugin config schema. The vast majority of non-SearXNG file changes are trivial import reorderings and formatter-driven whitespace fixes with no logic impact. Key concern:
Everything else looks good: the client, config resolution, test suite, and plugin metadata all follow established patterns correctly. Confidence Score: 4/5Safe to merge functionally — SearXNG works correctly when explicitly configured — but the auto-detection claim in docs and PR description does not match actual runtime behavior. The core implementation is solid and the provider works correctly when selected explicitly. The P1 concern is a discrepancy between the documented 'auto-detects via SEARXNG_BASE_URL' behavior and the actual runtime logic, which will always prefer DuckDuckGo (autoDetectOrder 100) over SearXNG (200) as the keyless fallback. Users relying on the documented auto-detection behavior will be silently redirected to DuckDuckGo. This warrants attention before merge but is not a security or data-loss issue. extensions/searxng/src/searxng-search-provider.ts — the autoDetectOrder and requiresCredential settings need to be reconciled with the auto-detection claim in the docs.
|
| Filename | Overview |
|---|---|
| extensions/searxng/src/searxng-search-provider.ts | Provider registration follows the DuckDuckGo pattern correctly, but autoDetectOrder: 200 combined with requiresCredential: false means SearXNG can never be runtime-auto-detected over DuckDuckGo (order 100), conflicting with the documented auto-detection claim. |
| extensions/searxng/src/searxng-client.ts | Client implementation is solid: JSON API endpoint, proper error handling, cache with normalization, content wrapping with wrapWebContent, and correct count slicing. |
| extensions/searxng/src/config.ts | Config resolution functions are clean and well-tested. Plugin config takes precedence over env var with proper trimming and trailing-slash normalization. |
| extensions/searxng/src/searxng-search-provider.test.ts | Comprehensive unit tests covering provider registration, credential metadata, argument mapping, base URL resolution, and autoDetectOrder. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/searxng/src/searxng-search-provider.ts
Line: 46
Comment:
**Auto-detection via `SEARXNG_BASE_URL` will not work as documented**
The PR description and docs claim SearXNG "auto-detects via `SEARXNG_BASE_URL` env var," but the runtime auto-detection logic in `src/web-search/runtime.ts` (`resolveWebSearchProviderId`) treats providers with `requiresCredential: false` as *keyless fallbacks* — it stores the first one it encounters (sorted by `autoDetectOrder`) and moves on. With DuckDuckGo at `autoDetectOrder: 100`, DDG is always stored as the keyless fallback before SearXNG (200) is reached. `SEARXNG_BASE_URL` is listed in `envVars`, but `hasEntryCredential` — the function that reads env vars — is never called for keyless providers (`requiresCredential: false`).
Concretely: a user who sets `SEARXNG_BASE_URL` without also explicitly setting `tools.web.search.provider: "searxng"` in `openclaw.json` will silently receive DuckDuckGo results, not SearXNG results.
For SearXNG to be auto-selected when `SEARXNG_BASE_URL` is present, one approach is to treat the base URL as a credential:
```ts
requiresCredential: true,
credentialPath: "plugins.entries.searxng.config.webSearch.baseUrl",
getCredentialValue: (searchConfig) =>
getScopedCredentialValue(searchConfig, "searxng") ??
process.env["SEARXNG_BASE_URL"],
```
Alternatively, if the intent is always to prefer explicit opt-in for SearXNG (which `autoDetectOrder: 200` implies), the docs and PR description should be corrected to remove the auto-detection claim so users know they must explicitly configure the provider.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "style: auto-format trailing comma and wh..." | Re-trigger Greptile
|
Addressed both review comments in db85698: P1 (auto-detection): Switched to P2 (path prefix): Replaced |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db856987da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed P1 from Codex review in fc64ead: Store base URL in plugin config: Added |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc64ead02c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed P2 from Codex review (SecretRef) in ff497a4: Accept SecretRef objects for baseUrl: Changed All 4 review comments now addressed:
|
🔒 Aisle Security AnalysisWe found 2 potential security issue(s) in this PR:
Vulnerabilities1. 🟠 SSRF via user-configurable SearXNG baseUrl fetched with private-network-allowed policy
DescriptionThe SearXNG web search provider builds a request URL from a configurable
Vulnerable code: const normalizedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
const url = new URL(`${normalizedBase}/search`);
...
const results = await withTrustedWebSearchEndpoint({ url: url.toString(), ... }, ...);And the trusted web tools guard explicitly allows private network targets: const WEB_TOOLS_TRUSTED_NETWORK_SSRF_POLICY: SsrFPolicy = {
dangerouslyAllowPrivateNetwork: true,
};RecommendationTreat
Example (conceptual): import { withStrictWebToolsEndpoint } from ".../web-guarded-fetch";
// Validate and parse
const parsed = new URL(baseUrl);
if (!['https:','http:'].includes(parsed.protocol)) throw new Error('Invalid baseUrl');
// additionally block private IPs/hostnames here
return await withStrictWebToolsEndpoint(
{ url: new URL('/search', parsed).toString(), timeoutSeconds, init: { method: 'GET', headers: { Accept: 'application/json' } } },
async ({ response }) => { /* ... */ }
);If internal/private access is truly required, restrict who can set 2. 🟡 Unbounded JSON response parsing in SearXNG client can cause memory exhaustion (DoS)
Description
Vulnerable code: const body = (await response.json()) as SearxngResponse;While error bodies are capped via RecommendationApply an explicit maximum size to successful responses before parsing JSON. Options:
const maxBytes = 1_000_000; // 1MB, tune as needed
const len = response.headers.get("content-length");
if (len && Number(len) > maxBytes) {
throw new Error(`SearXNG response too large (${len} bytes)`);
}
const { text, truncated } = await readResponseText(response, { maxBytes: 1_000_000 });
if (truncated) throw new Error("SearXNG response too large");
const body = JSON.parse(text) as SearxngResponse;Also consider documenting/requiring Analyzed PR: #57317 at commit Last updated on: 2026-03-30T09:59:14Z |
ff497a4 to
7eff513
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a051f35657
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
…penclaw#57317) * feat(web-search): add bundled searxng plugin * test(web-search): cover searxng config wiring * test(web-search): include searxng in bundled provider inventory * test(web-search): keep searxng ordering aligned * fix(web-search): sanitize searxng result rows --------- Co-authored-by: Vincent Koc <[email protected]>
Summary
extensions/searxng/, following the exactextensions/duckduckgo/patternformat=json) — no HTML scrapingSEARXNG_BASE_URLenv var; also configurable inopenclaw.jsonplugin configCloses #2317
Why
SearXNG is a self-hosted, open-source meta-search engine (aggregates Google, Bing, DuckDuckGo, etc.). It addresses three user pain points:
This is the highest-reaction open issue (26 👍) without an acceptable PR. Eight prior PRs attempted this but none were merged — they either used the wrong architecture (inlining into monolithic
web-search.ts) or shipped without tests.Test plan
pnpm tsgo— TypeScript check passespnpm build— build passes (plugin auto-discovered)pnpm check— lint + format passespnpm plugin-sdk:api:check— baseline regenerated and verifiedpnpm test -- extensions/searxng/— unit + contract tests (CI)docker run -d -p 8888:8080 searxng/searxng+SEARXNG_BASE_URL=http://localhost:8888 openclaw configure --section web→ select searxng → agentweb_searchreturns results