-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Sanitize Azure HTTP responses in BSL status messages #9321
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
Sanitize Azure HTTP responses in BSL status messages #9321
Conversation
Signed-off-by: Shubham Pampattiwar <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9321 +/- ##
==========================================
- Coverage 60.14% 60.14% -0.01%
==========================================
Files 385 385
Lines 35583 35635 +52
==========================================
+ Hits 21403 21433 +30
- Misses 12611 12632 +21
- Partials 1569 1570 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| unavailableErrors = append(unavailableErrors, err.Error()) | ||
| location.Status.Phase = velerov1api.BackupStorageLocationPhaseUnavailable | ||
| location.Status.Message = err.Error() | ||
| location.Status.Message = sanitizeStorageError(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we implement the logic on Azure plugin side? It is Azure specific logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ywk253100 I am unsure about that. The sanitization is about cleaning user-facing messages, not Azure-specific business logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this, but I think the controller is the right place for a few reasons:
- This is really about cleaning up the status message we show users, not about Azure-specific business logic. The controller owns the status field.
- The function already checks if it looks like an Azure error and passes everything else through unchanged. So it won't break other providers.
- If we put it in the plugin, we'd need to change the velero-plugin-for-microsoft-azure repo separately. And if GCP or AWS have similar issues later, we'd have to fix each plugin individually.
- This also sets us up for the secret scrubbing enhancement that @anshulahuja98 suggested - easier to do in one place.
Does that make sense, What do you think, open to hear suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the thought is that each storage plugin should individually self-contain function/status message cleanups, since that's why we have plugin system in the first place.
But if code is heavily reusable with secret scrubbing then that's a good compromise.
This return plain error object, which is used in Reconciler anonymous function.
I have noticed during logging in logReconciledPhase: will these get masked as well? |
This commit addresses three review comments on PR vmware-tanzu#9321: 1. Keep sanitization in controller (response to @ywk253100) - Maintaining centralized error handling for easier extension - Azure-specific patterns detected and others passed through unchanged 2. Sanitize unavailableErrors array (@priyansh17) - Now using sanitizeStorageError() for both unavailableErrors array and location.Status.Message for consistency 3. Add SAS token scrubbing (@anshulahuja98) - Scrubs Azure SAS token parameters to prevent credential leakage - Redacts: sig, se, st, sp, spr, sv, sr, sip, srt, ss - Example: ?sig=secret becomes ?sig=***REDACTED*** Added comprehensive test coverage for SAS token scrubbing with 4 new test cases covering various scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit addresses three review comments on PR vmware-tanzu#9321: 1. Keep sanitization in controller (response to @ywk253100) - Maintaining centralized error handling for easier extension - Azure-specific patterns detected and others passed through unchanged 2. Sanitize unavailableErrors array (@priyansh17) - Now using sanitizeStorageError() for both unavailableErrors array and location.Status.Message for consistency 3. Add SAS token scrubbing (@anshulahuja98) - Scrubs Azure SAS token parameters to prevent credential leakage - Redacts: sig, se, st, sp, spr, sv, sr, sip, srt, ss - Example: ?sig=secret becomes ?sig=***REDACTED*** Added comprehensive test coverage for SAS token scrubbing with 4 new test cases covering various scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Shubham Pampattiwar <[email protected]>
50a445a to
df6cf07
Compare
Signed-off-by: Shubham Pampattiwar <[email protected]>
This commit addresses three review comments on PR vmware-tanzu#9321: 1. Keep sanitization in controller (response to @ywk253100) - Maintaining centralized error handling for easier extension - Azure-specific patterns detected and others passed through unchanged 2. Sanitize unavailableErrors array (@priyansh17) - Now using sanitizeStorageError() for both unavailableErrors array and location.Status.Message for consistency 3. Add SAS token scrubbing (@anshulahuja98) - Scrubs Azure SAS token parameters to prevent credential leakage - Redacts: sig, se, st, sp, spr, sv, sr, sip, srt, ss - Example: ?sig=secret becomes ?sig=***REDACTED*** Added comprehensive test coverage for SAS token scrubbing with 4 new test cases covering various scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Shubham Pampattiwar <[email protected]>
Azure storage errors include verbose HTTP response details and XML in error messages, making the BSL status.message field cluttered and hard to read. This change adds sanitization to extract only the error code and meaningful message. Before: BackupStorageLocation "test" is unavailable: rpc error: code = Unknown desc = GET https://... RESPONSE 404: 404 The specified container does not exist. ERROR CODE: ContainerNotFound <?xml version="1.0"...> After: BackupStorageLocation "test" is unavailable: rpc error: code = Unknown desc = ContainerNotFound: The specified container does not exist. AWS and GCP error messages are preserved as-is since they don't contain verbose HTTP responses. Fixes vmware-tanzu#8368 Signed-off-by: Shubham Pampattiwar <[email protected]>
Signed-off-by: Shubham Pampattiwar <[email protected]>
This commit addresses three review comments on PR vmware-tanzu#9321: 1. Keep sanitization in controller (response to @ywk253100) - Maintaining centralized error handling for easier extension - Azure-specific patterns detected and others passed through unchanged 2. Sanitize unavailableErrors array (@priyansh17) - Now using sanitizeStorageError() for both unavailableErrors array and location.Status.Message for consistency 3. Add SAS token scrubbing (@anshulahuja98) - Scrubs Azure SAS token parameters to prevent credential leakage - Redacts: sig, se, st, sp, spr, sv, sr, sip, srt, ss - Example: ?sig=secret becomes ?sig=***REDACTED*** Added comprehensive test coverage for SAS token scrubbing with 4 new test cases covering various scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Shubham Pampattiwar <[email protected]>
df6cf07 to
20af2c2
Compare
|
Review request reminder: @ywk253100 @priyansh17 @kaovilai |
priyansh17
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks
14b34f0
into
vmware-tanzu:main
What this PR does / why we need it
Fixes the issue where Azure BackupStorageLocation status messages contain verbose HTTP response details and XML, making them difficult to read. This PR adds error sanitization to extract only the error code and meaningful message.
Which issue(s) this PR fixes
Fixes #8368
Before this change
When a BSL with a non-existent Azure bucket is created, the status message shows the full HTTP response:
After this change
The status message is clean and concise:
Implementation details
sanitizeStorageError()function that detects Azure-style HTTP response errors (containing "RESPONSE" and "ERROR CODE:" patterns)Testing
Checklist
/kind changelog-not-requiredon this PR.site/content/docs/main(if applicable).