-
Notifications
You must be signed in to change notification settings - Fork 1
fix: dbcrypt config field race condition #263
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
Conversation
Scanning the following files:
Scan: 'pkg/dbcrypt/dbcrypt.go'Nothing detected in pkg/dbcrypt/dbcrypt.go Scan: 'pkg/dbcrypt/dbcrypt_test.go'Nothing detected in pkg/dbcrypt/dbcrypt_test.go |
Conventional Commits Report
🚀 Conventional commits found. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #263 +/- ##
==========================================
+ Coverage 55.90% 56.11% +0.20%
==========================================
Files 61 61
Lines 3225 3231 +6
==========================================
+ Hits 1803 1813 +10
+ Misses 1293 1291 -2
+ Partials 129 127 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| dataEncrypted := dataClear | ||
| err := cryptCustom.EncryptStruct(&dataEncrypted) | ||
| require.NoError(t, err) | ||
| require.NotEqual(t, dataClear, dataEncrypted, "password was not encrypted") | ||
|
|
||
| dataDefaultDecrypted := dataEncrypted | ||
| err = cryptDefault.DecryptStruct(&dataDefaultDecrypted) | ||
| require.Error(t, err) | ||
| assert.Equal(t, dataEncrypted, dataDefaultDecrypted) | ||
|
|
||
| dataCustomDecrypted := dataEncrypted | ||
| err = cryptCustom.DecryptStruct(&dataCustomDecrypted) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, dataClear, dataCustomDecrypted) |
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 would at least add comments about each test case intention, I think it would make it easier to comprehend. For me it would be also more logical to read if it would be in order:
cryptCustom.EncryptStruct()
...
cryptCustom.DecryptStruct()
...
cryptDefault.DecryptStruct()
so dividing test cases per DBCrypt instance, which could be even separate t.Run() testcases.
|
We are going to use a different approach and re-implement the entire package. See #267 for more details. |
What
Fixes race condition during setting
configfield of theDBCryptstruct in the dbcrypt package. In addition it addsNewfunction to allow creating preconfiguredDBCryptstruct instances, bypassing config loading altogether.Why
Race condition that can crash the application. Also it potentially have security implications.
References
Checklist