Repository navigation
Redact credentials from toString() of authorization, encryption and webhook structures - #224
Open
ffumero2003 wants to merge 4 commits into
Open
ffumero2003 wants to merge 4 commits into
ffumero2003 wants to merge 4 commits into
Conversation
Remove the vacuous upload-request toString test.
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Several structures that hold credentials print them in
toString():B2AccountAuthorization(authorization token),B2FileSseForRequest(SSE-C customer key),B2WebhookConfiguration(HMAC signing secret),B2WebhookCustomHeader(header values) andB2HeadersImpl(AuthorizationandX-Bz-Server-Side-Encryption-Customer-Key). Applications that log these objects, or exceptions and debug output that include them, write those values in clear text.Changes
toString()replaces the sensitive values with[redacted](anullvalue still prints asnull). Non-secret fields, including the SSE-C key MD5, are unchanged.B2HeadersImplmatches header names case-insensitively.B2EventNotificationRule.COMPARATORpreviously ordered rules by the target configuration'stoString(). With the redaction, two rules that differ only in a secret would compare equal and one would be dropped from aTreeSet. Webhook targets are now compared field by field (url, custom headers, signing secret,maxEventsPerBatch). Any other target type falls back totoString()ordering, as before, and never throws.CHANGELOG.md: an[Unreleased]entry for both behavior changes.No public API or serialized form changes; JSON output is unaffected.
Verification
toString()omits its secret and keeps non-secret fieldsB2AccountAuthorizationTest,B2FileSseForRequestTest,B2WebhookConfigurationTest,B2CustomWebhookHeaderTest,B2HeadersImplTestB2HeadersImplTestTreeSet;compareTois consistent withequalsB2EventNotificationRuleTestB2EventNotificationRuleTest.testCompareToOrdersUnknownTargetConfigurationsWithoutThrowingEach fix was checked against a deliberate break: restoring the comparator's
toString()ordering fails three tests; removing the header redaction failsB2HeadersImplTest; restoring an exception for unknown targets fails 1 of 702 core tests.