Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

check if attribute is encrypted before checking type and add test #73

Merged
merged 5 commits into from
Aug 28, 2022

Conversation

fimac
Copy link
Contributor

@fimac fimac commented Aug 25, 2022

This PR fixes an issue where incorrect indexes are being created for anything other than a string type.

This is due to active record setting the type for all encrypted attributes to text.

More info here https://cipherstash.slack.com/archives/C01G7UGNQ3U/p1661470867621559

I have tested out Lockbox, and this doesn't have the same issue. The setup includes a step where you specify the type on the encrypted field in the model. In ActiveStash, it comes through as an ActiveModel type, with the actual type.

Key:
"age"
Value:
#<ActiveModel::Type::Integer:0x0000000146749ae0 @precision=nil, @scale=nil, @limit=8, @range=-9223372036854775808...9223372036854775808>

Copy link
Contributor

@freshtonic freshtonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great, feel free to merge once it works with Lockbox.

Copy link
Contributor

@coderdan coderdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some stylistic suggestions but otherwise LGTM.

lib/active_stash/stash_indexes.rb Outdated Show resolved Hide resolved
spec/active_stash/active_record_encryption_spec.rb Outdated Show resolved Hide resolved
spec/support/user4.rb Show resolved Hide resolved
@fimac fimac marked this pull request as ready for review August 28, 2022 22:22
@fimac fimac requested a review from a team as a code owner August 28, 2022 22:22
@fimac fimac changed the title check if attribute is encrypted before checking type and tests check if attribute is encrypted before checking type and add test Aug 28, 2022
@fimac fimac merged commit 0f69817 into main Aug 28, 2022
@fimac fimac deleted the debug-boolean-indexing branch August 28, 2022 23:39
freshtonic pushed a commit that referenced this pull request Dec 21, 2022
check if attribute is encrypted before checking type and tests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants