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

Use scrub_whitelist when scrubbing sidekiq job params #1074

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rollbar/plugins/sidekiq/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def self.job_scope(msg)
def self.scrub_params(params)
options = {
:params => params,
:config => Rollbar.configuration.scrub_fields
:config => Rollbar.configuration.scrub_fields,
:whitelist => Rollbar.configuration.scrub_whitelist
}

Rollbar::Scrubbers::Params.call(options)
Expand Down
29 changes: 29 additions & 0 deletions spec/rollbar/plugins/sidekiq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,35 @@
end
end

context 'with scrub_whitelist configured' do
let(:ctx_hash) do
{
:context => 'Job raised exception',
:job => job_hash
}
end

before do
reconfigure_notifier
allow(Rollbar.configuration)
.to receive(:scrub_fields)
.and_return(:scrub_all)
allow(Rollbar.configuration)
.to receive(:scrub_whitelist)
.and_return([:queue, :class])
end

it 'does not scrub the whitelisted fields' do
described_class.handle_exception(ctx_hash, exception)

expect(Rollbar.last_report[:request][:params]).to be_eql_hash_with_regexes(
'class' => job_hash['class'],
'queue' => job_hash['queue'],
'jid' => /\*+/
)
end
end

context 'with a sidekiq_threshold set' do
before do
Rollbar.configuration.sidekiq_threshold = 3
Expand Down