Add log sanitization for CodeQL log forging alerts

This commit is contained in:
admin 2025-12-18 20:17:42 -06:00
parent b1f50bae97
commit 1190d218af
3 changed files with 7 additions and 6 deletions

View file

@ -138,7 +138,7 @@ public bool FolderWritable(string path)
}
catch (Exception e)
{
Logger.Trace("Directory '{0}' isn't writable. {1}", path, e.Message);
Logger.Trace("Directory '{0}' isn't writable. {1}", path.SanitizeForLog(), e.Message);
return false;
}
}
@ -206,7 +206,7 @@ public long GetFileSize(string path)
}
catch (IOException ex)
{
Logger.Trace(ex, "Unable to resolve symlink target for {0}", path);
Logger.Trace(ex, "Unable to resolve symlink target for {0}", path.SanitizeForLog());
}
return fi.Length;
@ -534,7 +534,7 @@ public virtual IMount GetMount(string path)
}
catch (Exception ex)
{
Logger.Debug(ex, $"Failed to get mount for path {path}");
Logger.Debug(ex, "Failed to get mount for path {0}", path.SanitizeForLog());
return null;
}
}

View file

@ -1,5 +1,6 @@
using System;
using NLog;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.EnsureThat
{
@ -9,13 +10,13 @@ internal static class ExceptionFactory
internal static ArgumentException CreateForParamValidation(string paramName, string message)
{
Logger.Warn(message);
Logger.Warn(message.SanitizeForLog());
return new ArgumentException(message, paramName);
}
internal static ArgumentNullException CreateForParamNullValidation(string paramName, string message)
{
Logger.Warn(message);
Logger.Warn(message.SanitizeForLog());
return new ArgumentNullException(paramName, message);
}
}

View file

@ -274,7 +274,7 @@ public async Task DownloadFileAsync(string url, string fileName)
fileInfo.Directory.Create();
}
_logger.Debug("Downloading [{0}] to [{1}]", url, fileName);
_logger.Debug("Downloading [{0}] to [{1}]", url.SanitizeForLog(), fileName.SanitizeForLog());
var stopWatch = Stopwatch.StartNew();
await using (var fileStream = new FileStream(fileNamePart, FileMode.Create, FileAccess.ReadWrite))