reidmorrison / symmetric-encryption

Symmetric Encryption for Ruby Projects using OpenSSL
https://logger.rocketjob.github.io/
Apache License 2.0
476 stars 92 forks source link

Error saving :decimal attribute #129

Closed jersingh closed 4 years ago

jersingh commented 5 years ago

Encrypting many fields successfully in a model/table (PostgreSQL) with various types: :string, :boolean, :integer, and :date. I have one field that is :decimal type and it's the only field that fails when updating.

I'm calling some ajax to save individual attributes like this:

object.update_attribute(attr, value)

Stack trace caught in a rescue block when saving the :decimal:

wrong number of arguments (given 1, expected 0)

Here's my rails model symmetric-encryption definition:

attribute :rent_amount, :encrypted, random_iv: false, type: :decimal

I can change the type to :integer or :float and updates without issue. Just cannot save a :decimal.

My environment:

jersingh commented 5 years ago

Any takers?

I've posted on SO if that is a more appropriate place to ask for help.

https://stackoverflow.com/questions/56763756/rocketjob-symmetric-encryption-error-saving-decimal-attribute

michaelsalexander83 commented 5 years ago

Did you change the column to "string" ? each column should be in string format even when other format. May I ask how did you implement the gem? Im trying to implement myself but getting ArgumentError: Unknown type :encrypted for attribute :name, :encrypted, random_iv: false, type: :string and havent not been able to resolve this.

jersingh commented 5 years ago

@michaelsalexander83 I do have my column type set to string.

I basically followed instructions here but this is how I set things up. I'm using version 4.3.0:

I was then able to encrypt anything I needed to but :decimal fields.

Here's a sample of how I set up one of my models:

if Rails.application.config.encryption_mode # I set this in my environments
  # these work just dandy
  attribute :dob, :encrypted, random_iv: true, type: :date
  attribute :customer_since, :encrypted, random_iv: true, type: :date
  attribute :years_at_previous_residence, :encrypted, random_iv: true, type: :integer

  # fails with: wrong number of arguments (given 1, expected 0)
  # attribute :rent_amount, :encrypted, random_iv: false, type: :decimal
end

Hope this helps!

Just a quick note. No disrespect intended to the contributors, but I'm a little disappointed not one of the nineteen contributors can jump in to help. I understand the open source software process is a volunteer system and the time and effort involved in producing such a quality gem as this is greatly appreciated, but a system as critical as encryption is really important. I may need to use another library if I can't get my issue resolved.

Cheers!

reidmorrison commented 4 years ago

Just a quick note. No disrespect intended to the contributors, but I'm a little disappointed not one of the nineteen contributors can jump in to help. I understand the open source software process is a volunteer system and the time and effort involved in producing such a quality gem as this is greatly appreciated, but a system as critical as encryption is really important. I may need to use another library if I can't get my issue resolved.

Wow, such a typical response from an over entitled late adopter. This gem was written and is maintained by exactly 1 person in his "free" time. All other contributions are from people that instead of abusing the author, took the took the time and contributed by submitting a pull request.

Please use some other gem since you clearly do not appreciate the "free" time I put in to creating and maintaining this open source gem.