Skip to content

Add request body redaction and size limits#21

Open
craigpotter wants to merge 1 commit into
mainfrom
feature/request-body-limits
Open

Add request body redaction and size limits#21
craigpotter wants to merge 1 commit into
mainfrom
feature/request-body-limits

Conversation

@craigpotter

Copy link
Copy Markdown
Collaborator

Overview of change

Closes the request/response asymmetry from the review pass: responses have excluded_response_body and max_response_size, but request bodies were always stored in full — login payloads, personal data, large uploads and all.

  • excluded_request_body — mirrors excluded_response_body: '*', connector classes, or request classes; matching bodies are stored as REDACTED. Empty by default (no behaviour change).
  • max_request_size — mirrors max_response_size: kilobytes, measured in bytes, default 100. Oversized bodies are stored as <Unsupported Barstool Request Content>.
  • No content-type gate on requests (unlike responses) — the application authored the body, so it is always loggable text.
  • Request bodies are now always persisted as strings. Saloon's standard body repositories are all Stringable; custom repositories that are not fall back to json_encode($body->all()) (previously a non-Stringable repository would have crashed the PDO insert).
  • Streamed and multipart placeholders unchanged.

README updated with matching sections; new JsonPostRequest test fixture.

Testing

Six new tests: JSON body stored as string, redaction via '*'/connector/request class, byte-measured size cap with a multibyte body, and null body passthrough. Full suite: 53 passed (191 assertions), PHPStan level 8 clean, Pint clean.

Request bodies were always stored in full with no redaction or size cap,
unlike responses. Adds excluded_request_body (mirroring
excluded_response_body: '*', connector or request classes -> REDACTED)
and max_request_size (kilobytes, byte-measured, default 100; oversized
bodies stored as a placeholder). Bodies are now always persisted as
strings, with a JSON fallback for custom non-Stringable repositories.
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