-
Notifications
You must be signed in to change notification settings - Fork 73
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
ensure decode_password
function properly handles plaintext but valid base64 passwords
#5698
Conversation
…also valid base64
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
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.
some quick notes -
@@ -104,7 +104,12 @@ def test_str_to_b64_str() -> None: | |||
"password, expected", | |||
[ | |||
("Testpassword1!", "Testpassword1!"), | |||
( |
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.
this new test was failing before the fix
@@ -13,7 +13,7 @@ def decode_password(password: str) -> str: | |||
""" | |||
try: | |||
return b64_str_to_str(password) | |||
except Error: | |||
except (Error, UnicodeDecodeError): |
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.
decided to keep this minimal in scope - only catching the error i know can be thrown in the error case. handling more generic errors/exceptions would be more likely to lead to unintended side effects, IMO.
also didn't add any sort of logging here as it could get very noisy, but i'd be open to an argument for that
decode_password
function properly handles plaintext but valid base64 passwords
fides Run #11904
Run Properties:
|
Project |
fides
|
Branch Review |
refs/pull/5698/merge
|
Run status |
Failed #11904
|
Run duration | 01m 08s |
Commit |
8bb30a227c ℹ️: Merge 3730654f1a5b1a3146eaa6d866f1067ab146f926 into 7043171c4d6f3564c93e39b48abf...
|
Committer | Adam Sachs |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
1
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
3
|
Upgrade your plan to view test results. | |
View all changes introduced in this branch ↗︎ |
Tests for review
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5698 +/- ##
=======================================
Coverage 87.14% 87.14%
=======================================
Files 388 388
Lines 24034 24034
Branches 2594 2594
=======================================
Hits 20944 20944
Misses 2529 2529
Partials 561 561 ☔ View full report in Codecov by Sentry. |
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.
LGTM
failing tests look flaky to me, merging 👍 |
fides Run #11905
Run Properties:
|
Project |
fides
|
Branch Review |
main
|
Run status |
Passed #11905
|
Run duration | 00m 51s |
Commit |
bbba31d7fe: ensure `decode_password` function properly handles plaintext but valid base64 pa...
|
Committer | Adam Sachs |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
4
|
Upgrade your plan to view test results. | |
View all changes introduced in this branch ↗︎ |
Closes HJ-397
Description Of Changes
Handles the
UnicodeDecodeError
that is raised bydecode_password
if it is given a plaintext password that's also valid base64. The exception is caught, and the input string is returned as it was provided, under the assumption that it is a plaintext (and not base64-encoded) password.See issue description for more details. This impacts some user-related endpoints (e.g. reset password, accept invite) if the user provides a password that also happens to be valid base64. Notably, the utilities also ignore invalid base64 characters like
_
, so a value like e.g.Test_1234
is treated as valid base64, since the_
is ignored and its length of8
is a multiple of 4.Code Changes
UnicodeDecodeError
indecode_password
utility function, assuming input string is a plaintext passwordSteps to Confirm
Test_1234
(i think this was working before, because we send a base64 encoded password in the request from the UI in this workflow)Test_1234
, which i also confirmed was broken before:Pre-Merge Checklist
CHANGELOG.md
updatedmain
downgrade()
migration is correct and works