Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOJIRA] - If request protocol doesn't start with "HTTP" - http logging middleware responds with an error indicating the request protocol is invalid. #58781

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,33 @@
/// <returns></returns>HttpResponseLog.cs
public Task Invoke(HttpContext context)
{
if (!_logger.IsEnabled(LogLevel.Information))
if (context.Request.Protocol.StartsWith("HTTP"))

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)

Check failure on line 51 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L51

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(51,13): error CA1310: (NETCORE_ENGINEERING_TELEMETRY=Build) The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)' with a call to 'string.StartsWith(string, System.StringComparison)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310)
{
// Logger isn't enabled.
return _next(context);
}
if (!_logger.IsEnabled(LogLevel.Information))
{
// Logger isn't enabled.
return _next(context);
}

var options = _options.CurrentValue;
var loggingAttribute = context.GetEndpoint()?.Metadata.GetMetadata<HttpLoggingAttribute>();
var loggingFields = loggingAttribute?.LoggingFields ?? options.LoggingFields;
var options = _options.CurrentValue;
var loggingAttribute = context.GetEndpoint()?.Metadata.GetMetadata<HttpLoggingAttribute>();
var loggingFields = loggingAttribute?.LoggingFields ?? options.LoggingFields;

if (_interceptors.Length == 0 && loggingFields == HttpLoggingFields.None)
{
// Logging is disabled for this endpoint and there are no interceptors to turn it on.
return _next(context);
if (_interceptors.Length == 0 && loggingFields == HttpLoggingFields.None)
{
// Logging is disabled for this endpoint and there are no interceptors to turn it on.
return _next(context);
}

return InvokeInternal(context, options, loggingAttribute, loggingFields);
}
else
{
context.Response.StatusCode = StatusCodes.Status400BadRequest;
await context.Response.WriteAsync("Invalid request protocol.");

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

Check failure on line 74 in src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs#L74

src/Middleware/HttpLogging/src/HttpLoggingMiddleware.cs(74,13): error CS4032: (NETCORE_ENGINEERING_TELEMETRY=Build) The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

return InvokeInternal(context, options, loggingAttribute, loggingFields);
return Task.CompletedTask;
}
}

private async Task InvokeInternal(HttpContext context, HttpLoggingOptions options,
Expand Down
Loading