Skip to content

Commit ce47e59

Browse files
Potential fix for code scanning alert no. 38: Log entries created from user input
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 01cd487 commit ce47e59

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/api/Elastic.Documentation.Api.Core/LogSanitizer.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,7 @@ public static string Sanitize(string? input)
3131

3232
var span = input.AsSpan();
3333

34-
// Fast path: check if any dangerous characters exist (common case has none) - zero allocations
35-
var hasDangerousChars = false;
36-
foreach (var c in span)
37-
{
38-
if (IsDangerousChar(c))
39-
{
40-
hasDangerousChars = true;
41-
break;
42-
}
43-
}
44-
45-
if (!hasDangerousChars)
46-
return input;
47-
48-
// Slow path: count chars to keep, then create string with exact size
34+
// Always sanitize: remove all dangerous/control/log-forging characters
4935
var keepCount = 0;
5036
foreach (var c in span)
5137
{

0 commit comments

Comments
 (0)