Skip to content

Commit 4fcc1dd

Browse files
authored
Merge pull request rails#55676 from rails/fxn/encryption-compression-threshold
Document THRESHOLD_TO_JUSTIFY_COMPRESSION cannot be changed.
2 parents a090707 + 853e639 commit 4fcc1dd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

activerecord/lib/active_record/encryption/encryptor.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ def compress? # :nodoc:
9494
private
9595
DECRYPT_ERRORS = [OpenSSL::Cipher::CipherError, Errors::EncryptedContentIntegrity, Errors::Decryption]
9696
ENCODING_ERRORS = [EncodingError, Errors::Encoding]
97+
98+
# This threshold cannot be changed.
99+
#
100+
# Users can search for attributes encrypted with `deterministic: true`.
101+
# That is possible because we are able to generate the message for the
102+
# given clear text deterministically, and with that perform a regular
103+
# string lookup in SQL.
104+
#
105+
# Problem is, messages may have a "c" header that is present or not
106+
# depending on whether compression was applied on encryption. If this
107+
# threshold was modified, the message generated for lookup could vary
108+
# for the same clear text, and searches on exisiting data could fail.
97109
THRESHOLD_TO_JUSTIFY_COMPRESSION = 140.bytes
98110

99111
def default_key_provider

0 commit comments

Comments
 (0)