feat(middleware): enhance logger to sanitize new and old password fields
Updated the logger to include regex patterns for sanitizing "new_password" and "old_password" fields in JSON logs. Added a corresponding test case to verify the sanitization functionality.
This commit is contained in:
@@ -38,6 +38,11 @@ func TestSanitizeBody(t *testing.T) {
|
||||
in: `{"password":"p","token":"t"}`,
|
||||
want: `{"password":"***","token":"***"}`,
|
||||
},
|
||||
{
|
||||
name: "snake_case new_password and old_password",
|
||||
in: `{"email":"alice@example.com","new_password":"FreshPass9","old_password":"OldPass9"}`,
|
||||
want: `{"email":"alice@example.com","new_password":"***","old_password":"***"}`,
|
||||
},
|
||||
{
|
||||
name: "extra whitespace around colon",
|
||||
in: `{"apiKey" : "leak"}`,
|
||||
|
||||
Reference in New Issue
Block a user