Skip to content

Commit 3bf20dc

Browse files
committed
fix(Logger): Improve log redaction
see #1799 Signed-off-by: Marcel Klehr <[email protected]>
1 parent 1b4bd8b commit 3bf20dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/Logger.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class Logger {
3636

3737
static async anonymizeLogs(logs) {
3838
const regex = /\[(.*?)\]\((.*?)\)|\[(.*?)\]/g
39-
return Parallel.map(logs, async(entry) => {
39+
const newLogs = await Parallel.map(logs, async(entry) => {
4040
return Logger.replaceAsync(entry, regex, async(match, p1, p2, p3) => {
4141
if (p1 && p2) {
4242
const hash1 = await Crypto.sha256(p1)
@@ -48,6 +48,10 @@ export default class Logger {
4848
}
4949
})
5050
}, 1)
51+
const regex2 = /url=https?%3A%2F%2F.*$|url=https?%3A%2F%2F[^ ]*/
52+
const regex3 = /https?:\/\/[^ /]*\//
53+
return newLogs
54+
.map(line => line.replace(regex2, '###url###').replace(regex3, '###server###'))
5155
}
5256

5357
static async replaceAsync(str, regex, asyncFn) {

0 commit comments

Comments
 (0)