Skip to content

Commit e156cd8

Browse files
committed
redact usernames from path
1 parent 8c02485 commit e156cd8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

GPUPrefSwitcher/AppLogger.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Text;
5+
using System.Text.RegularExpressions;
56
using System.Threading;
67
using System.Threading.Tasks;
78

@@ -263,11 +264,13 @@ private async Task WriteAsyncInternal_Standard(string str)
263264
{
264265
await semaphoreSlim_Standard.WaitAsync();
265266

267+
string sanitized = Regex.Replace(str, @"\\Users\\[^\\]+\\", "<redacted>");
268+
266269
try
267270
{
268-
await outputFile_Standard.WriteLineAsync(str);
271+
await outputFile_Standard.WriteLineAsync(sanitized);
269272
await outputFile_Standard.FlushAsync();
270-
System.Diagnostics.Debug.WriteLine(str);
273+
System.Diagnostics.Debug.WriteLine(sanitized);
271274
}
272275
finally
273276
{
@@ -286,11 +289,13 @@ private async Task WriteAsyncInternal_Error(string str)
286289

287290
await semaphoreSlim_Error.WaitAsync();
288291

292+
string sanitized = Regex.Replace(str, @"\\Users\\[^\\]+\\", "<redacted>");
293+
289294
try
290295
{
291-
await outputFile_Error.WriteLineAsync(str);
296+
await outputFile_Error.WriteLineAsync(sanitized);
292297
await outputFile_Error.FlushAsync();
293-
System.Diagnostics.Debug.WriteLine(str);
298+
System.Diagnostics.Debug.WriteLine(sanitized);
294299
}
295300
finally
296301
{

0 commit comments

Comments
 (0)