extensions icon indicating copy to clipboard operation
extensions copied to clipboard

HttpRouteParser incorrectly handles catch-all routes

Open dariusclay opened this issue 1 year ago • 1 comments

Description

The HttpRouteParser.TryExtractParameters method in the Microsoft.Extensions.Telemetry library does not handle route parameters that are marked as catch-all. This can lead to either truncated export of the route parameter in structured logging, or misleading redacted data in the output.

Reproduction Steps

  1. Create a route with a catch-all parameter, for example: {*catchall}
  2. Use the HttpRouteParser to parse this route.
  3. Observe the parsing result.

Expected behavior

The HttpRouteParser should correctly handle and parse catch-all route parameters.

Actual behavior

The HttpRouteParser fails to correctly parse routes with catch-all parameters, leading to incorrect logs.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

When redaction is configured, redacted values may be unintuitive because only the first segment of the catch-all route is used.

For example, the following produces the same results since only the segment /1 is taken into account.

redaction: HmacRedactor

route template: path/with/{*catchAll}

requests:

  • path/with/1/2/3
  • path/with/1/2
  • path/with/1
  • path/with/1/some/data

dariusclay avatar Oct 03 '24 14:10 dariusclay