Skip to content

Commit

Permalink
Use whitelist when scrubbing sidekiq job params (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkampjes authored Feb 7, 2022
1 parent a55812a commit 7415fa6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit 7415fa6

Please sign in to comment.