Repository navigation
Conversation
_KMSKeyRedactingFormatter deep-copied every record before checking whether it held KMS plaintext. Records whose arguments cannot be deep-copied made format() raise instead of logging. Copy only the records that are redacted and pass all others through unchanged. Fixes aws#145 Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
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.
Having an issue that names the log handler's record handling so plainly made it easy to find where to look, so this is my fix there; the title is all I had, so please check it.
Issue #, if available: #145
Description of changes:
_KMSKeyRedactingFormatter.formatdeep-copied every log record before checking whether it was a KMS Encrypt request or a KMS response containingPlaintext. If a record's arguments could not be deep-copied,formatraised, as in the traceback in the issue (TypeErrorfromcopy.deepcopyon a urllib3 connection-pool record), and the log line was lost.__redact_recordnow makes the copy only for the two record kinds that are redacted, and returns every other record unchanged. Redaction of those two kinds is not changed. The record that reaches the formatter is still never modified in place, because the deep copy is kept for the redacted cases. The copy for the redacted cases can still fail for the same reason in principle, but those are botocore records with plain dict and bytes arguments.Tests: two cases in
test/unit/internal/test_logging_utils.py. One formats an unrelated record whose argument raises in__deepcopy__; it fails withTypeError: cannot deep copywhen the source change is reverted and passes with it. The other checks that a KMS response body still hasPlaintextredacted and the original record is untouched.pytest test/unit/internal/test_logging_utils.pyin a fresh Python 3.14 venv: 13 passed.I could not reproduce the original Python 2.7 failure with the real urllib3 object, so the test uses a stand-in object. In the rest of
test/unit(excludingtest_arg_parsing.py), 4 tests fail both with and without this change (3 intest_aws_encryption_sdk_cli.py, 1 intest_compatability.py).test_arg_parsing.pyfails at collection on this Python version withValueError: mutually exclusive groups cannot be nested, also without the change. I did not run the integration tests.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Fixes #145