ankane / lockbox

Modern encryption for Ruby and Rails
MIT License
1.44k stars 68 forks source link

avoid super method for low-level attribute accessors #163

Closed ghost closed 2 years ago

ankane commented 2 years ago

Hey @xiao-maven, can you give more context on the change?

ghost commented 2 years ago

Ah sorry, meant to submit this internally on my fork rather than to upstream. I will close this, as this PR is not ready for a variety of reasons:

I made this PR to document for my teammates internally and forgot how the default PR behavior for forks works.

Context though if you're curious--I am in the process of partitioning a table that includes an encrypted column, and ran into an odd issue where the attribute reader and writer don't exist, so lockbox was throwing an exception when trying to call super on the wrapped accessors.

My model has an encrypted field called :data, declared as encrypts :data, type: :hash. If I modify lockbox to declare the :data attribute but not wrap the accessors, the underlying accessors still work but the methods aren't explicitly declared. Presumably getting handled inside method_missing somehow.

Since those methods aren't explicit before lockbox wraps them though, I'm getting method not found when lockbox tries to call super.

I haven't figured out yet why those accessors are explicit when my table is a single table but implicit when my table is partitioned, but switching to the read_attribute and write_attribute method works around the error.