Skip to content
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

Not setting 'bugsnag_filterfields' option will filter everything #61

Closed
fiskhandlarn opened this issue Oct 13, 2022 · 3 comments
Closed

Comments

@fiskhandlarn
Copy link
Contributor

Describe the bug

if the 'bugsnag_filterfields' option isn't set, get_option('bugsnag_filterfields') will return false. this will make Bugsnag_Wordpress::filterFields return [""] (i.e. an array with one item containing an empty string (array(1) { [0]=> string(0) "" })). further down the line this array will make Error::cleanupObj believe that all values should be filtered, because https://github.com/bugsnag/bugsnag-php/blob/2.10/src/Bugsnag/Error.php#L386 will always be true (since strpos($key, "") will always return 0, and 0 is !== false).

my suggestion would be to rewrite https://github.com/bugsnag/bugsnag-wordpress/blob/master/bugsnag.php#L156 to
if ($filter_fields === '' || $filter_fields === false) {
or maybe even better
if (empty(trim($filter_fields ?? ''))) {
(to catch the case where the user has written just whitespace in the wp-admin (perhaps this line must be rewritten to support older php versions though). i could make a pr for this if you want?

pls note that setting 'bugsnag_filterfields' to "whatever\n" will yield the same problems since Bugsnag_Wordpress::filterFields then will return ["whatever",""] and then filter everything out based on the second item in the array. you should probably take a look at https://github.com/bugsnag/bugsnag-wordpress/blob/master/bugsnag.php#L160 and make sure it doesn't return any empty strings in the array.

Steps to reproduce

  1. do nothing
  2. trigger an error
  3. see the error in the dashboard with all custom fields and request and cookies set to [FILTERED]

Environment

  • Bugsnag version: 1.6.1
  • PHP version: 8
  • Wordpress version: 6.0.2
@fiskhandlarn
Copy link
Contributor Author

fiskhandlarn commented Oct 13, 2022

a possible workaround for this would of course be to set all options in the database upon install. since it's possible to set the other options via filters i think it's dangerous to assume that all users will submit the form on /wp-admin/options-general.php?page=bugsnag (and thus invoke Bugsnag_Wordpress::updateNetworkSettings setting the default values). this will of course not solve the problem with newlines as described above though.

@yousif-bugsnag
Copy link

Thanks for the report and workaround @fiskhandlarn !

This issue was resolved via a support ticket, but for the benefit of future travellers: it should be possible to work around the issue by setting the option to ""

@fiskhandlarn
Copy link
Contributor Author

fiskhandlarn commented Dec 2, 2022

it was me who filed the support ticket, and the issue still persists in the current version of this plugin, although i got great help by the support staff. :)

my tip for future travellers: try and implement https://github.com/bugsnag/bugsnag-php into your application instead.

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

No branches or pull requests

2 participants