logstash-plugins/logstash-filter-cipher

base64 seems to not work even when enabled

focusaurus opened this issue · 8 comments

I'm running version 0.1.5 of this filter. Here's my filter spec:

cipher {
  algorithm => "aes-256-cbc"
  # base64 seems to not actually work
  base64 => true
  mode => "encrypt"
  key => "redacted"
  iv => "redacted"
  source => "some_secret_plaintext"
  target => "some_secret_ciphertext"
  remove_field => ["message", "some_secret_plaintext"]
}

But the "some_secret_ciphertext" comes out in straight binary:

"some_secret_ciphertext":"PUÌþö#·\u000Fø%¹\f¸\u001Dt "

Consistently reproducible for me. I looked briefly at the code and at a glance it seemed like it should work. Not sure what's going wrong.

Just by reading the code I think you are right.
it seems that line 106 is an exact copy-paste of line 102 but should be replaced to work on the result variable instead of the data variable
result = Base64.encode64(result) if @base64 == true
Can you please try this ?

Pretty sure fix for this and other things have been sitting in this PR forever, prior to this new repo

#3

Been using this patch in prod for over a year, works fine

Original fix @ 10f3e23

@bitsofinfo I confirmed using the patched version from #3 works well for me. Would love to see that merged and a new release published.

Cool, glad it worked, please comment on #3 maybe it will get moving :)

@focusaurus I also recommend you don't use the static IV, if you are using the patch, be sure to use the random IV functionality.

Added PR #7 to fix base64 issue

jsvd commented

closing since pr #3 has been merged