-
Notifications
You must be signed in to change notification settings - Fork 902
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
Fix the issue that unencrypted plaintext values are versioned with ActiveRecord encryption (since Rails 7) #1422
Fix the issue that unencrypted plaintext values are versioned with ActiveRecord encryption (since Rails 7) #1422
Conversation
…module method There will be multiple places calling this method to determine different behaviours based on the ActiveRecord version that PaperTrail is running on. PR: paper-trail-gem#1422
Since Rails 7, ActiveRecord introduces a built-in encryption mechanism. We need to serialise these values otherwise plaintext values instead of ciphertext are versioned, which makes the encryption meaningless. PR: paper-trail-gem#1422
578eaac
to
8f13bfc
Compare
Since Rails 7, ActiveRecord introduces a built-in encryption mechanism. We need to serialise these values otherwise plaintext values instead of ciphertext are versioned, which makes the encryption meaningless. PR: paper-trail-gem#1422
8f13bfc
to
c765492
Compare
No uncovered lines were added, but more lines were added therefore the denominator got bigger and the coverage dropped a little ¯\_(ツ)_/¯ PR: paper-trail-gem#1422
@jaredbeck Sorry for pinging, could this be looked at please? I imagine this would be stopping lots of users from upgrading to Rails 7. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, Hector.
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests
# ActiveRecord since 7.0 has a built-in encryption mechanism | ||
@encrypted_attributes = | ||
if PaperTrail.active_record_gte_7_0? | ||
@item_class.encrypted_attributes&.map(&:to_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly, it seems that rails does not initialize encrypted_attributes
to an empty array, and so the safe-navigation operator is warranted.
@jaredbeck Thanks for reviewing and merging this! Could I ask about the plan for the new release please? We have been using a monkey patch in production. It'd be good if we could get off the monkey patch and use a released version. |
@FunnyHector @jaredbeck could we get a new release including this fix? We need it, I could reference the git commit we want temporarily but I'd prefer official releases 🙂 |
Released in 15.0.0 |
Since Rails 7, ActiveRecord introduces a built-in encryption mechanism. When versioning encrypted attributes for JSON columns on PostgreSQL, currently the unencrypted values are saved. This makes the encryption meaningless, and stops people from upgrading to Rails 7.
This PR is mainly from the patch that @vccoffey posted at #1392 (comment). Thanks for the original idea.
Fixes #1392.
Check the following boxes:
master
(if not - rebase it).code introduces user-observable changes.
and description in grammatically correct, complete sentences.