-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Geoconfig and API settings models: AES CBC encryption read and write #35642
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c026c1
feat: set password and client secret with cbc algorithm but continue …
Jtang-1 36b9977
feat: set last_token_aes using cbc encryption with prefix. On read, u…
Jtang-1 4c49627
feat: raise exception if decryption of original value fails during th…
Jtang-1 25f6a04
feat: GeoConfig, set api token with cbc algorithm but continue readin…
Jtang-1 0e98462
test: update to check for aes-cbc prefix
Jtang-1 a9bd69c
test: update to check for "aes-cbc" prefix
Jtang-1 1e7f473
refactor: consolidate where constant is defined
Jtang-1 bc3d6a6
bug + test: string needs to be parsed to dictionary + add tests for s…
Jtang-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If there is no
existing_prefix
, then it means the text is not encrypted, so we should not decrypt it right? Can this try except block moved to the first if block, when text starts withexisting_prefix
?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.
No that's not the case. The expectation is that the
encrypted_text
passed toreencrypt_ecb_to_cbc_mode
is encrypted. Theexisting_prefix
is only to handle situations where the encrypted text is prefixed such that the prefix can be stripped.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.
Or maybe we don't need
existing_prefix
at all? Shouldn't this function be able to take in any text, determine if and how is encrypted then do whatever needs to return a cbc encrypted string?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.
Is there a case that the text is encrypted without any prefix?
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.
Yes, it depends on the model.
If we remove the
existing_prefix
, then we would need to handle stripping prefix on the higher level function that callsreencrypt_ecb_to_cbc_mode
and pass only the encrypted text. Is that what you're suggesting?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.
I see. If there is such case, then
existing_prefix
is still required. I was suggesting refactoring, because I see logic like, check whether encrypted_text is empty string, is repeated in bothreencrypt_ecb_to_cbc_mode
and_reencrypt_or_encrypt_value_with_cbc
(the latter function is from the migration PR #35641 ). Besides, if the prefix is CBC, then we do nothing and return the text, this logic can also be included inreencrypt_ecb_to_cbc_mode
. So the function in the migration PR can be simplified. But this is not a hard block. It's just my personal preference to make the code looks cleaner. I'll approve the PR.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.
I see what you mean by some repeated logic. I think when we initially wrote
reencrypt_ecb_to_cbc_mode
, I wasn't expecting to have to handle fields where some value were encrypted and some values weren't. I thought the only scenario would be fields where all the values were encrypted but some values were prefixed while some weren't. I don't think this distinction can be handled withinreencrypt_ecb_to_cbc_mode
and has to be handled by the caller.