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

Ideas #40

Open
1 of 5 tasks
ankane opened this issue Jul 6, 2020 · 12 comments
Open
1 of 5 tasks

Ideas #40

ankane opened this issue Jul 6, 2020 · 12 comments

Comments

@ankane
Copy link
Owner

ankane commented Jul 6, 2020

3.0

  • Exclude blind index columns from serialized_hash (not great for inspect) - serialized_hash branch
  • Drop support for Active Record < 5.2 and Ruby < 2.6

Ideas

  • (waiting for AR release) add support for Active Record 6.1 - activerecord61 branch
  • Add support for update_column and update_columns - update_columns branch
  • Prefer sensitive: true or extra_sensitive: true over slow: true
@chmatos
Copy link

chmatos commented Dec 29, 2020

there is any way to do a select with order ? example: Customer.all.order(:name), where name is blinded.

@ankane
Copy link
Owner Author

ankane commented Dec 29, 2020

No, you'll need to do sorting in memory (Customer.all.sort_by(&:name)). There is the concept of order-preserving encryption, but it leaks significantly more information than blind indexing.

@chmatos
Copy link

chmatos commented Dec 30, 2020

ok, thanks a lot ankane, and congratulations for the gem.

@tddrmllr
Copy link

Is it possible to support ranges? i.e,

class Post
  encrypts :date, type: :date
  blind_index :date
end

Post.where(date: ..Date.today)
Post.where(date: Date.today..)
Post.where(date: Date.yesterday..Date.today)

Or is it a similar issue to using order?

@ankane
Copy link
Owner Author

ankane commented Mar 29, 2021

Since dates are discrete, you could pass an array of dates instead of a range. However, creating blind indexes on dates in general will leak a lot of information since it'll show which records have the same dates.

@mrjonesbot
Copy link

mrjonesbot commented Dec 14, 2021

This might be a dumb question, but I'm trying to LIKE search against an encrypted column using Blind index and it doesn't seem possible.

Example.

Candidate.joins(:profile).where("candidate_profiles.encrypted_inmate_number ILIKE ?", "%W45%")
=> ERROR: column candidate_profiles.encrtyped_inmate_number does not exist

(profile is an alias in this example)

The only value I'm able to search against is the _bidx, but that is obviously not searching against the encrypted value.

Is there any way to achieve this kind of LIKE search for encrypted values?

Didn't want to open a separate issue since this seems in line with the design of encrypting data.

update
I was able to move in a different direction to avoid needing to do this.

@ankane
Copy link
Owner Author

ankane commented Dec 14, 2021

fwiw, there's a section in the readme on this w/ alternative approaches.

@mrjonesbot
Copy link

fwiw, there's a section in the readme on this w/ alternative approaches.

Whoops, missed this in my haste 😬 . Appreciate the callout!

@ianrandmckenzie
Copy link

ianrandmckenzie commented May 23, 2022

Any chance of adding Sequel support or guiding me on how I might go about implementing it?

See #10, janko/rodauth-rails#108

@ankane
Copy link
Owner Author

ankane commented May 23, 2022

I don't have any plans to support Sequel, but you can check out model.rb and extensions.rb to see how it's done for Active Record. You could also use BlindIndex.generate_bidx to generate the blind index value manually before inserting into the database, and then again to query it.

# insert
users.insert(email_bidx: BlindIndex.generate_bidx("test@example.com", key: key))

# query
users.where(email_bidx: BlindIndex.generate_bidx("test@example.com", key: key))

@ianrandmckenzie
Copy link

Thanks for pointing me in the right direction, Andrew. This is needed for an active project, so I'll be diving in soon. If I'm feeling super ambitious, I may make a Sequel fork and try to remain as parallel as I can!

@ankane
Copy link
Owner Author

ankane commented May 24, 2022

No problem. Also, if you haven't already seen it, it looks like Sequel has a plugin for searchable encryption. https://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/ColumnEncryption.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants