Skip to content

Validate geocoding search query input (#527)#545

Open
maltehuebner wants to merge 1 commit into
mainfrom
fix/geocoding-validation-527
Open

Validate geocoding search query input (#527)#545
maltehuebner wants to merge 1 commit into
mainfrom
fix/geocoding-validation-527

Conversation

@maltehuebner

Copy link
Copy Markdown
Contributor

Addresses the input-validation half of #527.

Changes

  • TypeaheadController::searchAction now trims the query parameter and validates its length (2–128 chars). Missing/empty/over-long input returns HTTP 400 with a JSON error instead of the previous HTTP 500 (GeocodeQuery::create(null)TypeError, since Geocoder::query() is typed string).
  • Non-scalar array input (?query[]=x) is already rejected as 400 by Symfony's InputBag::get(), so no extra handling is needed.

Deliberately not implemented (deferred)

  • Rate limiting (symfony/rate-limiter). This requires adding the dependency plus a framework.rate_limiter config block and a boot-critical cache pool, and its behaviour can only be meaningfully verified against a running app with Redis. The container could not be booted in the review environment (the local vendor/ is missing symfony/runtime, so bin/console and WebTestCase cannot start), so I could not verify that the wiring compiles or that limiting actually triggers. Rather than commit unverifiable boot-critical config, this is left for a follow-up. Suggested config for the follow-up:
    # config/packages/rate_limiter.yaml
    framework:
        rate_limiter:
            search:
                policy: 'sliding_window'
                limit: 30
                interval: '1 minute'
    then inject RateLimiterFactoryInterface $searchLimiter and consume by client IP in searchAction, returning 429 when the limit is exceeded.
  • Route requirements. query is a query-string parameter, not a path segment, so route requirements do not apply.

Verification

Closes #527

🤖 Generated with Claude Code

The public /search/query proxy passed $request->query->get('query')
straight into Geocoder::query(string), so a missing parameter produced
a TypeError -> HTTP 500 instead of a 400. Add server-side validation:
trim the input and require a length between 2 and 128 characters,
returning HTTP 400 with a message otherwise. Non-scalar array input
(?query[]=x) is already rejected by Symfony's InputBag as a 400.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

[Mittel] Geocoding-/Such-Proxy ohne Eingabevalidierung und Rate-Limiting

1 participant