feat(search): bound SearXNG response bodies - #250
Merged
Conversation
Coverage: 94.94% (was 94.72%)
Coverage: 94.90% (was 94.94%)
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 90 |
| Duplication | 4 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a centralized, byte-bounded response-body reader for SearXNG HTTP responses and updates search, instance capability discovery, and autocomplete flows to consume streamed bodies safely under explicit size/time limits.
Changes:
- Added
src/searxng-response.tsto enforce per-response byte ceilings (full reads and bounded previews), plus auxiliary body cancellation helpers. - Refactored search, HTML fallback,
/config, and/autocompleterto use bounded body reads and to avoid caching/health-success on failed/oversized/partial bodies. - Documented the new
SEARXNG_MAX_RESPONSE_BYTESenv var and expanded unit/integration/e2e tests to cover bounded streaming and timeout-through-body-consumption.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/suggestions.ts | Applies bounded body reads to autocomplete and keeps the request abort signal active during body consumption. |
| src/searxng-response.ts | New bounded response-body reader with preview mode, strict env parsing, and best-effort cancellation utilities. |
| src/search.ts | Refactors fetch handling to route responses through bounded readers for JSON, HTML fallback, and error previews; improves diagnostic URL redaction. |
| src/instance-info.ts | Bounds /config reads, cancels non-success bodies, and avoids logging sensitive URL components. |
| SECURITY.md | Documents response-body limit behavior and its security implications. |
| CONFIGURATION.md | Adds SEARXNG_MAX_RESPONSE_BYTES and clarifies deadline semantics through body streaming/decoding/parsing. |
| tests/unit/suggestions.test.ts | Adds unit coverage for suggestion byte limits, cancellation, malformed/partial bodies, and non-disclosure logging. |
| tests/unit/searxng-response.test.ts | New unit suite for bounded reader behavior, abort semantics, cancellation, and config parsing rules. |
| tests/unit/search.test.ts | Updates mocks to real Response bodies and adds coverage for bounded search/HTML fallback and non-caching on oversize/partial responses. |
| tests/unit/instance-info.test.ts | Adds coverage for bounded /config, negative caching on oversize/malformed, and timeout-through-body-consumption behavior. |
| tests/run-all.ts | Registers the new SearXNG response module test suite. |
| tests/integration/mcp-handlers.test.ts | Updates integration mocks to return real Response instances with readable bodies. |
| tests/helpers/mock-fetch.ts | Switches helper responses to real Response objects to better model single-use streamed bodies. |
| tests/e2e/timeout.e2e.ts | Adds e2e coverage ensuring SEARXNG_TIMEOUT_MS applies even when bodies stall after headers (JSON and HTML fallback). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage: 94.97% (was 94.90%)
Owner
Author
|
Review round 1 handling:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification