-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Unified recorder] String sanitizer support + sanitizer refactor (#19954
) - Fixes #19809 - Part of work towards #18223 The main motivation of this PR was to add support for the new string sanitizers introduced in Azure/azure-sdk-tools#2530. As part of this, I've also tackled some refactoring that will be required for session-level sanitizer support (#18223) where we will be wanting to enable adding sanitizers without access to an instance of the `Recorder` class. While implementing the new sanitizer logic, I refactored the `addSanitizers` method into smaller chunks to make adding additional sanitizers easier. To summarize the changes: * Removed the `Sanitizer` class, instead making the `addSanitizers` function in `sanitizer.ts` take in a `HttpClient` and recording ID as parameter. * Refactored the `addSanitizers` function to call smaller functions for each sanitizer (some of which are a bit FP-style) instead of using if statements + special cases. Hopefully this will make things a bit easier to maintain. * Some other minor refactors (e.g. extracting duplicated `createRecordingRequest` function into a utility). * Add support for the string sanitizers in what I think is the most logical way, but there is a **breaking change**: * When calling `addSanitizers`, instead of specifying `generalRegexSanitizers: [...]` etc., you now specify `generalSanitizers: [...]`. Both regex sanitizers and string sanitizers can be used in this way, for example: ```ts recorder.addSanitizers({ generalSanitizers: [ { regex: true, // Regex matching is enabled by setting the 'regex' option to true. target: ".*regex", value: "sanitized", }, { // Note that `regex` defaults to false and doesn't need to be specified when working with bare strings. // In my experience, this is the most common scenario anyway. target: "Not a regex", value: "sanitized", } ], }); ```
- Loading branch information
Showing
13 changed files
with
539 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.