Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was 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
fimac merged 5 commits into
mainfrom
debug-boolean-indexing
Aug 28, 2022
Merged

check if attribute is encrypted before checking type and add test#73
fimac merged 5 commits into
mainfrom
debug-boolean-indexing

Conversation

@fimac

@fimac fimac commented Aug 25, 2022

Copy link
Copy Markdown
Contributor

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>

@freshtonic freshtonic left a comment

Copy link
Copy Markdown
Contributor

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.

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread lib/active_stash/stash_indexes.rb Outdated
Comment thread spec/active_stash/active_record_encryption_spec.rb Outdated
Comment thread spec/support/user4.rb
@fimac fimac force-pushed the debug-boolean-indexing branch from c7d690d to 2715113 Compare August 28, 2022 22:13
@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