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

Sanitizer#filter_key? returns a warning for Numeric hash keys #530

Closed
dawson-conway opened this issue Mar 15, 2024 · 5 comments · Fixed by #533
Closed

Sanitizer#filter_key? returns a warning for Numeric hash keys #530

dawson-conway opened this issue Mar 15, 2024 · 5 comments · Fixed by #533
Assignees

Comments

@dawson-conway
Copy link

As currently defined, filter_key? calls =~ on its parameter. When sanitizing a hash, keys can technically be anything. =~ as defined on Object is deprecated. So the filter_key? parameter should either be converted to a string (could change behavior) or the filters should be skipped if the key doesn't have =~ defined itself, or in a superclass that is not Object

@dawson-conway dawson-conway changed the title Sanitizer#filter_key? returns a warning for Numeric keys Sanitizer#filter_key? returns a warning for Numeric hash keys Mar 15, 2024
@stympy
Copy link
Member

stympy commented Mar 21, 2024

Do you have code or config that can trigger the warning?

@dawson-conway
Copy link
Author

From our config:

request:
  filter_keys:
    - password
    - password_confirmation
    - card_number
    - card_number_unmasked
    - magnetic_track
    - magnetic_track_unmasked
    - security_code
    - security_code_unmasked
    - routing_number
    - routing_number_unmasked
    - account_number
    - account_number_unmasked
    - account_number_confirmation
    - account_number_confirmation_unmasked

I'm not sure what is exactly being passed in to trigger this (the stacktrace isn't showing up on honeybadger, maybe because it's triggered from within). The specific message is

DeprecationWarning: /var/www/current/vendor/bundle/ruby/2.7.0/gems/honeybadger-5.2.1/lib/honeybadger/util/sanitizer.rb:170: warning: deprecated Object#=~ is called on Integer; it always returns nil

@dawson-conway
Copy link
Author

I know that our application sometimes constructs arrays with integer keys (i.e. {1 => 'value', 2 => 'another'}) which seems like it would trigger this.

@stympy
Copy link
Member

stympy commented Mar 21, 2024

Thanks for the info! I'll take a look. :)

@stympy
Copy link
Member

stympy commented Mar 23, 2024

v5.8.0 has this fix

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 a pull request may close this issue.

2 participants