Skip to content

Commit 7980654

Browse files
committed
chore: address CodeQL alert for log injection
Add suppression comments trusting Serilog's @ destructuring to automatically escape control characters, avoiding redundant sanitization.
1 parent 7801075 commit 7980654

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Dotnet.Samples.AspNetCore.WebApi/Controllers/PlayerController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ [FromBody] PlayerRequestModel player
189189
return TypedResults.NotFound();
190190
}
191191
await playerService.UpdateAsync(player);
192+
// codeql[cs/log-forging] Serilog structured logging with @ destructuring automatically escapes control characters
192193
logger.LogInformation("PUT /players/{SquadNumber} updated: {@Player}", squadNumber, player);
193194
return TypedResults.NoContent();
194195
}

src/Dotnet.Samples.AspNetCore.WebApi/Middlewares/ExceptionMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception
4949
// Add trace ID for request correlation
5050
problemDetails.Extensions["traceId"] = context.TraceIdentifier;
5151

52-
// Log the exception with structured logging
52+
// codeql[cs/log-forging] Serilog structured logging automatically escapes control characters
5353
logger.LogError(
5454
exception,
5555
"Unhandled exception occurred. TraceId: {TraceId}, Path: {Path}, StatusCode: {StatusCode}",

0 commit comments

Comments
 (0)