-
Notifications
You must be signed in to change notification settings - Fork 17
add SanitizeURL hook for safe request masking before logging #89
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
Conversation
Hello, thank you for your PR. Line 407 in 852c9ca
M.b. It's better to move it to Line 145 in 059c650
|
Also, could you please add builder for it to Line 187 in 059c650
|
Hi! Thanks a lot for your suggestion regarding moving the The problem is that
As a result, applying the |
Hello, thank you again for your PR. I moved and modified your PR to https://github.com/ozontech/cute/pull/90/files. Could you please check it? |
Summary
Adds a
SanitizeURL
hook to theTest
struct, allowing users to modify the request (e.g., mask API keys) before logging or reporting.Motivation
While using
cute
for integration tests, we found that sensitive query params like?key=...
were exposed in Allure reports.We tried several approaches without library changes, but none masked the URLs in cute's built-in logs.
Approaches we tried
Example 1: Logging masked URL via Middleware
Worked: Added an Allure attachment.
Problem: Did not affect cute's internal request logging.
Example 2: Temporarily replacing
req.URL.RawQuery
Worked: Controlled masked URL.
Problem: Too late — cute had already logged the request.
What’s added
SanitizeHook
type with doc.Sanitizer
field onTest
.createRequest()
.TestSanitizeURLHook
.sanitizeKeyParam()
.Example usage
Notes
Thanks for reviewing!