fix(diagnostics): scrub whole passwords; unique bundle names; no temporary files left behind
- A secret value runs to the next ';' or the end of the line unless quoted (backslash and doubled-quote escapes), so passwords with spaces, commas or quotes never leak in part; URL passwords run to the last '@' before the path. - Desktop bundles get " (2)", " (3)"… instead of overwriting one made in the same minute, and a bundle that fails half-way deletes its .tmp file. - The server builds its bundle in a temporary file that no crash leaves behind (DeleteOnClose on Windows, unlinked at once elsewhere). - Tests: passwords with spaces, commas, quotes and '@'; a DbConnectionString in the server bundle; bundle name collisions and failure cleanup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+95
-27
No files matched your search
@@ -116,8 +116,8 @@ public static partial class SecretScrubber
|
||||
[GeneratedRegex(@"(?<scheme>\b(?:bearer|basic))\s+[A-Za-z0-9._~+/=-]{6,}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
private static partial Regex AuthScheme();
|
||||
|
||||
/// <summary>"https://user:secret@host" keeps the user name.</summary>
|
||||
[GeneratedRegex(@"(?<prefix>\b[a-z][a-z0-9+.-]*://[^/\s:@]+:)[^/\s@]+@", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
/// <summary>"https://user:secret@host" keeps the user name; the password runs to the last '@' before the path ("p@ss@db").</summary>
|
||||
[GeneratedRegex(@"(?<prefix>\b[a-z][a-z0-9+.-]*://[^/\s:@]+:)[^/\s]+@", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
private static partial Regex UrlCredentials();
|
||||
|
||||
/// <summary>"?token=…", "&access_token=…", "&sig=…".</summary>
|
||||
@@ -125,10 +125,12 @@ public static partial class SecretScrubber
|
||||
private static partial Regex QueryParameter();
|
||||
|
||||
/// <summary>
|
||||
/// "Password=…", "DbPassword: …", "\"token\": \"…\"", "client_secret=…" (connection strings, settings dumps, JSON in
|
||||
/// log messages): the value up to the next separator goes (a value an earlier rule already removed is left alone).
|
||||
/// "Password=…", "DbPassword: …", "\"token\": \"…\"", "client_secret=…" (connection strings, environment and settings
|
||||
/// dumps, JSON in log messages). A quoted value goes up to its closing quote (a backslash or a doubled quote escapes
|
||||
/// one); any other value up to the next ';' (the connection-string separator) or the end of the line, because
|
||||
/// passwords may hold spaces, commas or quotes. A value an earlier rule already removed is left alone.
|
||||
/// </summary>
|
||||
[GeneratedRegex(@"(?<name>[A-Za-z0-9_-]*(?:password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)[A-Za-z0-9_-]*[""']?\s*[=:]\s*)(?!\[removed\])(?:""[^""]*""|'[^']*'|[^\s;,&""']+)",
|
||||
[GeneratedRegex(@"(?<name>[A-Za-z0-9_-]*(?:password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)[A-Za-z0-9_-]*[""']?\s*[=:]\s*)(?!\[removed\])(?:""(?:[^""\\]|\\.|"""")*""|'(?:[^']|'')*'|[^;\r\n]+)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
private static partial Regex NamedValue();
|
||||
|
||||
|
||||
Reference in new issue
Block a user