-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove password from logs (#3723)
- Loading branch information
1 parent
7f93f63
commit cb32ea1
Showing
4 changed files
with
36 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const maskAxiosResponse = (response: any) => { | ||
const configData = response?.config?.data ? JSON.parse(response.config.data) : undefined | ||
const maskedResponse = !configData | ||
? response | ||
: { | ||
...response, | ||
config: { ...response.config, data: maskData(configData) }, | ||
} | ||
|
||
return maskedResponse | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const maskData = (data: any) => { | ||
const maskedData = { ...data } | ||
if (data.password) { | ||
maskedData.password = "*******" | ||
} | ||
if (data.email) { | ||
const emailChunks = data.email.split("@") | ||
maskedData.email = emailChunks.length === 2 ? `****@${emailChunks[1]}` : data.email | ||
} | ||
return maskedData | ||
} |
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