Encoded Sensitive Data (base64)

276 views
Skip to first unread message

Roland Moriz

unread,
Feb 11, 2013, 8:01:49 AM2/11/13
to VCR Rubygem
Hello,

in one of my latest projects I'm using VCR to record SOAP calls done
using Savon2+httpi (with net-http backend). It works great but I just
run into a problem: One SOAP response delivers a lot of base64 encoded
data back, including some sensitive information.

The encoding makes "filter_sensitive_data" to not find and replace the
sensitive data.

Is there a way to hook in some user provided "serialize/deserialize"
logic into the process so I can use filter_sensitive_data?

Thanks
Roland

Myron Marston

unread,
Feb 12, 2013, 2:08:29 AM2/12/13
to VCR Rubygem
filter_sensitive_data simply wraps a more flexible, fundamental
API...before record/playback hooks:

https://github.com/vcr/vcr/blob/v2.4.0/lib/vcr/configuration.rb#L218-L231

You can write your own hooks. It could be something like:

VCR.configure do |c|
c.before_record do |interaction|
decoded_body = Base64.decode(interaction.response.body)
decoded_body.gsub!(ENV['PASSWORD']), '<PASSWORD>')
interaction.response.body = Base64.encode(decoded_body)
end

c.before_playback do |interaction|
decoded_body = Base64.decode(interaction.response.body)
decoded_body.gsub!('<PASSWORD>', ENV['PASSWORD'])
interaction.response.body = Base64.encode(decoded_body)
end
end

HTH,
Myron
Reply all
Reply to author
Forward
0 new messages