-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic sanitization to logs (#41)
- Loading branch information
1 parent
0b2d662
commit 2769769
Showing
5 changed files
with
66 additions
and
6 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
ca-certificates=20230311 | ||
chromium=115.0.5790.102-2 | ||
chromium-driver=115.0.5790.102-2 | ||
chromium-sandbox=115.0.5790.102-2 | ||
ffmpeg=7:6.0-4 | ||
chromium=115.0.5790.170-1 | ||
chromium-driver=115.0.5790.170-1 | ||
chromium-sandbox=115.0.5790.170-1 | ||
ffmpeg=7:6.0-5 | ||
fonts-recommended=1 | ||
pulseaudio=16.1+dfsg1-2+b1 | ||
wget=1.21.3-1+b2 | ||
xvfb=2:21.1.7-3 | ||
xvfb=2:21.1.8-1 |
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,13 @@ | ||
package main | ||
|
||
import ( | ||
"regexp" | ||
) | ||
|
||
var ( | ||
icePasswordRE = regexp.MustCompile(`ice-pwd:[\w|\+|/]+`) | ||
) | ||
|
||
func sanitizeConsoleLog(str string) string { | ||
return icePasswordRE.ReplaceAllString(str, "ice-pwd:XXX") | ||
} |
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,40 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSanitizeConsoleLog(t *testing.T) { | ||
tcs := []struct { | ||
name string | ||
input string | ||
expected string | ||
}{ | ||
{ | ||
name: "empty string", | ||
}, | ||
{ | ||
name: "alphanumeric", | ||
input: "ice-pwd:aBc123", | ||
expected: "ice-pwd:XXX", | ||
}, | ||
{ | ||
name: "special chars", | ||
input: "ice-pwd:/aBc+1/2", | ||
expected: "ice-pwd:XXX", | ||
}, | ||
{ | ||
name: "with ending", | ||
input: "ice-pwd:abc123\\rtest", | ||
expected: "ice-pwd:XXX\\rtest", | ||
}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
t.Run(tc.name, func(t *testing.T) { | ||
require.Equal(t, tc.expected, sanitizeConsoleLog(tc.input)) | ||
}) | ||
} | ||
} |