refa(plug): consolidate access to the plug scrubber#1069
Open
solnic wants to merge 21 commits into
Open
Conversation
6d67fda to
d234d46
Compare
…hing
Collapses the scrubbing entry points onto a single `scrub` surface driven
by clause-level pattern matching:
* `scrub/1` is now a lenient, shallow dispatcher — `Plug.Conn` routes
through the registered conn scrubbers, a plain map is scrubbed
recursively, and anything else (binaries, lists, unrelated structs,
scalars) is returned unchanged. This is suitable for callers that scrub
values of unknown shape.
* `scrub/2` carries the recursive logic via typed clauses (map, struct,
list, credit-card binary, passthrough) instead of a private
`cond`-based helper. The map clause redacts sensitive keys and scrubs
the remaining values in turn.
Removes the `scrub_value/1` and private `scrub_pair/3` helpers, both now
expressed as `scrub` clauses.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4b4dd34 to
e05c35a
Compare
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Make Sentry.Scrubber's intrinsic :url default actually redact sensitive query parameters (via scrub_url/1) instead of returning the URL unchanged — a sensible default for a scrubbing module. A nil :url_scrubber still disables scrubbing (nil_scrubber(:url) now returns the request URL directly rather than delegating to the scrubbing default). Sentry.PlugContext keeps its historical behavior of NOT scrubbing URLs unless a :url_scrubber is configured: call/2 now defaults :url_scrubber to the local no-op default_url_scrubber/1 (via Keyword.put_new) when the user passes none. An explicit url_scrubber: nil or a custom scrubber is preserved. This also wires up default_url_scrubber/1, which was otherwise orphaned. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e05c35a to
6453968
Compare
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.
This encapsulates scrub-related logic fully in the
Sentry.Scrubberand expands its interface to make it easily usable standalone and introduces a "current scrubber" concept, so that customized scrubbers are actually respected and used across processes.This will also make it simpler to implement the new spec that replaces "default PII" concept later this year.
The public API remains the same, which means that plug options accept the same keys which result in the same behavior and the original default scrubbing functions are still there (
PlugContext.default_*_scrubberones). To be honest, I'd deprecate them and shift entire scrubbing stuff to theScrubbereventually. Something to consider.These improvements make fixes here #1068 and here #1070 trivial, which is the actual biggest reason why I've done this.
Basic examples
Web-related scrubbing helpers
Stored scrubber instance
This stuff is used internally by the
PlugContext: