Skip to content

Release 2.10

Choose a tag to compare

@igorpocta igorpocta released this 28 Oct 14:14
· 11 commits to main since this release

What's Changed

Quarterly security and correctness audit: 58 commits, tests 1445 → 1637. Some fixes change behaviour - read "Check before upgrading".

Dependencies

  • igorpocta/data-mapper → airora/data-mapper ^1.16 (renamed package, namespace Pocta\DataMapper unchanged, replace: igorpocta/data-mapper)
  • symfony/cache → ^6.4.40 || ^7.4.12 (CVE-2026-45073, SQL injection in PdoAdapter::doClear())
  • squizlabs/php_codesniffer (dev) → ^4.0.2 (CVE-2026-67434)
  • symfony/lock added as optional (suggest) for atomic rate limiting

⚠️ Check before upgrading

Change What to check
#[Hidden] endpoints are now routable (hidden only from OpenAPI, as documented) any #[Hidden] used as an on/off switch - protect with #[Authorize] or middleware
#[Authorize] is inherited from parent controllers (AND) child controllers may start returning 403
Middleware priorities: BasicAuthMiddleware 250 → 460 (after RateLimit), EnforceHttpsMiddleware 499 → 20 custom middleware with priority 20-499
{class: Foo} middleware without priority uses #[MiddlewarePriority] (was fixed 10); Foo(arg: ...) no longer breaks DI ordering of such middleware
Path parameters are URL-decoded (john%20doe → john doe) code decoding path params itself (would double-decode)
FileResponse::fromResource() rewinds seekable handles and sends the whole file code relying on fseek() before fromResource()
FileResponse adds CSP: sandbox to every type except passive ones (PDF, images except SVG, audio, video, fonts, text, CSV, JSON, archives, office docs) inline HTML reports / interactive SVG relying on scripts
Date-only DateTimeImmutable parameter (2024-05-01) = midnight (was current time) date range filters
ApiResponse::list() always emits a JSON array (was an object for non-sequential keys) clients handling the object form
X-HTTP-Method-Override applies to POST only clients overriding GET/PUT (overridableMethods: restores it)
Client X-Request-ID must match [A-Za-z0-9._:=-]{1,128}, otherwise a new UUID is generated proxies sending other characters
JSON body for DTOs: depth limit 64 (jsonDepth), scalar bodies → 400 (was 500), non-empty JSON list → 422 deeply nested payloads (raise DataMapperSerializer(jsonDepth: N))
Router basePath strips only on a segment boundary (/apiv2 no longer → /v2); /api/api/... unchanged clients calling /apiXXX
Invalid trustedProxies entries fail DI compilation / RateLimitMiddleware constructor (an empty prefix used to trust all IPs) api.trustedProxies, RateLimit trustedProxies
$_SERVER['HTTPS'] = 'off' is treated as plain HTTP IIS / proxies setting HTTPS=off behind TLS
ApiTestClient passes the query string to controllers tests calling URLs with ?query

OpenAPI changes (regenerate and diff your spec)

  • Colliding schema names get a namespace prefix (OrderItemDto, InvoiceItemDto) instead of overwriting each other; inline oneOf/ref and multipart refs point to the right class; classes referenced only from inline request bodies are registered (no more dangling $ref). Pin a name with #[Schema(name: '...')].
  • Colliding generated operationIds are made unique (adminUserList / frontUserList, pingCheckGet / pingCheckPost, aliases contactList, contactList2 numbered by path). Explicit ids never change.
  • #[MapProperty(name: 'user_name')] is documented as user_name (matches the wire).
  • Valid OpenAPI 3.0 for array (items: {}), mixed ({}) and ?self ($ref).
  • Parameter attributes without type: take the type and required-ness from the method signature (#[PathParameter(name: 'id')] int $id = integer; method-level #[QueryParameter(name: 'limit')] + int $limit = required, missing → 400 instead of 500).
  • Arguments with their own attribute no longer produce a bogus query parameter; #[Hidden] on a DTO property hides it from the schema.
  • #[OutputOnly] → readOnly, #[InputOnly] → writeOnly, #[Ignore] → omitted.

Fixes

  • Router cache references endpoints by a stable key (adding/moving an endpoint no longer calls the wrong method)
  • Multipart: doc[main] / doc[0][1] no longer fatal; invalid enum value → 422 (was 500); int-backed enums work; empty value for nullable properties → null; #[OutputOnly] / #[Ignore] are not hydrated
  • sanitizeFilename() never cuts a UTF-8 character and limits names to 255 bytes (long non-ASCII names no longer hit ENAMETOOLONG)
  • Empty CONTENT_LENGTH (nginx fastcgi_params) no longer returns 400
  • ?int $limit without default → null when missing; header/cookie argument attributes are injected; hyphenated path variables {user-id} work
  • CORS: Vary: Origin on every whitelisted response, merged with the app's Vary
  • IpMatcher rejects malformed CIDR prefixes and IPs with a trailing newline
  • ApiApplication without an error handler no longer returns 200 for exceptions

New (optional)

  • Atomic rate limiting: RateLimitMiddleware(..., lockFactory: ...) with symfony/lock
  • Parameter attributes on arguments: get(#[HeaderParameter(name: 'X-API-Key')] string $apiKey)
  • #[Schema(name: '...')] for stable schema names
  • MethodOverrideMiddleware(overridableMethods: [...])
  • ApiTestClient::withServerParams(), request(serverParams:)
  • data-mapper 1.16 direction attributes #[OutputOnly], #[InputOnly], #[Ignore] in JSON, multipart and OpenAPI
  • Opt-in DTO hardening via the existing serializer option: DataMapperSerializer(MapperOptions(publicPropertiesOnly: true, symmetricPropertyPaths: true)) - see docs/security.md (changes responses, off by default)

Known limitations (unchanged, see docs/security.md)

5xx messages are returned verbatim, LoggingMiddleware logs full URIs, /openapi.json has no access control, 429/413 responses lack CORS headers, multipart still casts invalid scalars ("abc" → 0; planned for the next major).

Full Changelog: v2.9.1...v2.10