Azure / Azure/azure-functions-host

Improve sanitizer approach

Open
#10,646 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

#### What problem would the feature you're requesting solve? Please describe.

We need to simplify the class Sanitizer.cs to improve performance. Currently it is using both regex approach and string comparison. We can optimize it to use either of these approaches. Note that the method `Sanitize()` gets executed a lot as it examines the logs and sanitizes any secret related strings. Also, using regex comparison is very expensive. For that we can use .Net feature GeneratedRegex for performance - [link](https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators?pivots=dotnet-8-0#source-generation)


Documentation here - [Link](https://microsoft.sharepoint.com/:w:/t/AzureFunctionsCoreTeam/EV09nmZ5_SZJv4tFfxDwpxIB_eamOrLsp2vi8uQujYIGxQ?e=0qmnxz)

Contributor guide

Open the contributing guide

Research direction

Start by reading Sanitizer.cs and the Sanitize() entry point, then review the linked .NET GeneratedRegex documentation and the internal sanitizer design document. Compare the existing regex and string-comparison paths, and consider how the hot path can use one approach while continuing to sanitize secret-related log strings correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, performance, security
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.