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

[Test Proxy] Centrally sanitize sensitive patterns for all tests #35196

Merged
merged 5 commits into from
Apr 16, 2024

Conversation

mccoyp
Copy link
Member

@mccoyp mccoyp commented Apr 13, 2024

Description

This adds a Sanitizer enum and batch sanitizer registration method -- add_batch_sanitizers -- that make it possible to easily set a number of sanitizers in a single request.

Sanitizer registration has been centralized to take place just after the test proxy is started up and before recordings are loaded up, meaning that they will apply to the entire session.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@mccoyp mccoyp added the test-proxy Anything relating to test-proxy requests or issues. label Apr 13, 2024
@mccoyp mccoyp force-pushed the proxy-sanitize-patterns branch 2 times, most recently from 16d2955 to 8594052 Compare April 13, 2024 06:23
@mccoyp mccoyp requested a review from scbedd April 13, 2024 06:30
@mccoyp
Copy link
Member Author

mccoyp commented Apr 15, 2024

Core failures are unrelated and preexisting.

@mccoyp mccoyp force-pushed the proxy-sanitize-patterns branch 2 times, most recently from 2923b54 to 8101a07 Compare April 15, 2024 01:47
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@mccoyp mccoyp requested a review from pvaneck April 15, 2024 23:32
@mccoyp mccoyp marked this pull request as ready for review April 16, 2024 04:06
@xiangyan99
Copy link
Member

/azp run python - storage - ci

Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@xiangyan99
Copy link
Member

/azp run python - core - ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@xiangyan99 xiangyan99 merged commit 07c08c9 into Azure:main Apr 16, 2024
32 checks passed
HarshaNalluru added a commit to Azure/azure-sdk-for-js that referenced this pull request Apr 16, 2024
### Packages impacted by this PR
`@azure-tools/test-recorder` - Adding the central sanitizers

### Issues associated with this PR
**References:**
- Azure/azure-sdk-for-java#39700
- Azure/azure-sdk-for-python#35196
- And the patterns found

### Describe the problem that is addressed by this PR
- Introducing fallback sanitizers into the test recorder to handle
potential secret leaks.
- The new sanitizers are designed to work in conjunction with the
existing `handleEnvSetup` mechanism and the fake secrets.
  - The sanitizers include:
- `BodyKeySanitizers` that redact sensitive information in the JSON body
of the requests.
- `FindReplaceSanitizers` that redact sensitive information based on
provided regular expressions.
- `HeaderSanitizers` that redact sensitive information in the headers of
the requests.

## Tests
I've ran the tests for the following and they work fine
- [x] recorder
- [x] template
- [x] notification-hubs (needed to make a few fixes for browser tests in
notification hubs which do feel like unrelated to this PR, but fixing
them here anyway.)

___Currently only these three packages depend on recorder v4.___

## Future work (future PRs)
- Once this PR is merged, cherrypick the commit and release a hotfix 3.x
version
- Add more tests at some point
@mccoyp mccoyp deleted the proxy-sanitize-patterns branch April 25, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test-proxy Anything relating to test-proxy requests or issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants