New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new 'redacted keys' config option to replace 'filters' #623
Conversation
This replaces 'filters' with slightly different semantics
The new redacted keys option can do everything filters can and more
@@ -5,24 +5,24 @@ Bugsnag\Handler should increase the memory limit by the configured amount when a | |||
$client = require __DIR__ . '/_prelude.php'; | |||
$client->setMemoryLimitIncrease(1024 * 1024 * 10); | |||
|
|||
ini_set('memory_limit', '2M'); | |||
Bugsnag\Handler::register($client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test could run OOM before installing the handler, so I've moved this to before we reduce the memory limit and bumped the limit a bit
@@ -29,6 +29,7 @@ jobs: | |||
with: | |||
php-version: ${{ matrix.php-version }} | |||
coverage: none | |||
extensions: intl, mbstring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPUnit requires mbstring so we can't run the tests without it
Goal
This PR adds a 'redacted keys' option, to replace the existing 'filters' option. Filters is problematic because it works with a case-insensitive string contains, which can easily cause false positives
Redacted keys has different semantics but can still express everything that filters could (and more!). Redacted keys can contain both strings and regexes, where string comparisons are case-insensitive and exact — i.e.
a
matchesa
andA
but notab
. Regexes can be used to emulate filters, e.g./a/i
will matcha
,A
andab
Redacted keys also attempts to match multi-byte strings by normalising strings and using multi-byte comparisons. This relies on the intl and mbstring extensions, so we fallback to
strcasecmp
if they are missing (we also trystrcasecmp
first as it's quicker than normalising + MB comparisons)Changeset
redactedKeys
with getters & setters in Client & Configurationfilters
option is now marked as deprecatedReport::shouldFilter
also usesredactedKeys
to check if keys should be filtered/redactedUtils::stringCaseEquals
method has been added. This does a unicode-aware, case-insensitive string match