Skip to content

Commit 4374ad5

Browse files
authored
Remove "attributes" from EncryptionContext str/repr (#128)
* add test to verify that EncryptionContext.attributes is not included in str/repr * remove EncryptionContext.attributes from str/repr * update changelog with #127 fix * add pylint ignores for no-member checks on generated code
1 parent 9d99241 commit 4374ad5

9 files changed

+39
-8
lines changed

Diff for: CHANGELOG.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
Changelog
33
*********
44

5-
1.1.2 -- 2019-09-??
5+
1.1.2 -- 2019-10-??
66
===================
77

88
Bugfixes
99
--------
1010
* Fix :class:`AwsKmsCryptographicMaterialsProvider` regional clients override bug
1111
`#124 <https://github.com/aws/aws-dynamodb-encryption-python/issues/124>`_
12+
* Remove ``attributes`` attribute from :class:`EncryptionContext` ``str`` and ``repr`` values.
13+
`#127 <https://github.com/aws/aws-dynamodb-encryption-python/issues/127>`_
1214

1315
1.1.1 -- 2019-08-29
1416
===================

Diff for: examples/src/aws_kms_encrypted_item.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def encrypt_item(table_name, aws_cmk_id):
4141
plaintext_item.update(index_key)
4242

4343
# Create a normal table resource.
44-
table = boto3.resource("dynamodb").Table(table_name)
44+
table = boto3.resource("dynamodb").Table(table_name) # generated code confuse pylint: disable=no-member
4545

4646
# Use the TableInfo helper to collect information about the indexes.
4747
table_info = TableInfo(name=table_name)

Diff for: examples/src/aws_kms_encrypted_resource.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def encrypt_batch_items(table_name, aws_cmk_id):
6464
)
6565

6666
# Get the encrypted item using the standard service resource.
67-
encrypted_items = resource.batch_get_item(RequestItems={table_name: {"Keys": index_keys}})["Responses"][table_name]
67+
encrypted_items = resource.batch_get_item( # generated code confuse pylint: disable=no-member
68+
RequestItems={table_name: {"Keys": index_keys}}
69+
)["Responses"][table_name]
6870

6971
# Get the item using the encrypted service resource, transparently decyrpting it.
7072
decrypted_items = encrypted_resource.batch_get_item(RequestItems={table_name: {"Keys": index_keys}})["Responses"][

Diff for: examples/src/aws_kms_encrypted_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def encrypt_item(table_name, aws_cmk_id):
3939
plaintext_item.update(index_key)
4040

4141
# Create a normal table resource.
42-
table = boto3.resource("dynamodb").Table(table_name)
42+
table = boto3.resource("dynamodb").Table(table_name) # generated code confuse pylint: disable=no-member
4343
# Create a crypto materials provider using the specified AWS KMS key.
4444
aws_kms_cmp = AwsKmsCryptographicMaterialsProvider(key_id=aws_cmk_id)
4545
# Create attribute actions that tells the encrypted table to encrypt all attributes except one.

Diff for: examples/src/most_recent_provider_encrypted_table.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def encrypt_item(table_name, aws_cmk_id, meta_table_name, material_name):
4141
plaintext_item.update(index_key)
4242

4343
# Create a normal table resource for the meta store.
44-
meta_table = boto3.resource("dynamodb").Table(meta_table_name)
44+
meta_table = boto3.resource("dynamodb").Table(meta_table_name) # generated code confuse pylint: disable=no-member
4545
# Create a crypto materials provider for the meta store using the specified AWS KMS key.
4646
aws_kms_cmp = AwsKmsCryptographicMaterialsProvider(key_id=aws_cmk_id)
4747
# Create a meta store using the AWS KMS crypto materials provider.
@@ -53,7 +53,7 @@ def encrypt_item(table_name, aws_cmk_id, meta_table_name, material_name):
5353
version_ttl=600.0, # Check for a new material version every five minutes.
5454
)
5555
# Create a normal table resource.
56-
table = boto3.resource("dynamodb").Table(table_name)
56+
table = boto3.resource("dynamodb").Table(table_name) # generated code confuse pylint: disable=no-member
5757
# Create attribute actions that tells the encrypted table to encrypt all attributes except one.
5858
actions = AttributeActions(
5959
default_action=CryptoAction.ENCRYPT_AND_SIGN, attribute_actions={"leave me": CryptoAction.DO_NOTHING}

Diff for: examples/src/wrapped_rsa_encrypted_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def encrypt_item(table_name, rsa_wrapping_private_key_bytes, rsa_signing_private
4040
plaintext_item.update(index_key)
4141

4242
# Create a normal table resource.
43-
table = boto3.resource("dynamodb").Table(table_name)
43+
table = boto3.resource("dynamodb").Table(table_name) # generated code confuse pylint: disable=no-member
4444
# Create a crypto materials provider using the provided wrapping and signing keys.
4545
# We show private keys used here, but public keys could be used as well, allowing
4646
# only wrapping or signature verification.

Diff for: examples/src/wrapped_symmetric_encrypted_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def encrypt_item(table_name, aes_wrapping_key_bytes, hmac_signing_key_bytes):
4040
plaintext_item.update(index_key)
4141

4242
# Create a normal table resource.
43-
table = boto3.resource("dynamodb").Table(table_name)
43+
table = boto3.resource("dynamodb").Table(table_name) # generated code confuse pylint: disable=no-member
4444
# Create a crypto materials provider using the provided wrapping and signing keys.
4545
wrapping_key = JceNameLocalDelegatedKey(
4646
key=aes_wrapping_key_bytes,

Diff for: src/dynamodb_encryption_sdk/structures.py

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class EncryptionContext(object):
6868
validator=attr.validators.optional(attr.validators.instance_of(six.string_types)), default=None
6969
)
7070
attributes = attr.ib(
71+
repr=False,
7172
validator=(dictionary_validator(six.string_types, dict), _validate_attribute_values_are_ddb_items),
7273
default=attr.Factory(dict),
7374
)

Diff for: test/unit/test_structures.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""Unit tests for ``dynamodb_encryption_sdk.structures``."""
14+
import pytest
15+
16+
from dynamodb_encryption_sdk.structures import EncryptionContext
17+
18+
19+
@pytest.mark.parametrize("operator", (repr, str))
20+
def test_encryption_context_repr(operator):
21+
value = EncryptionContext(attributes={"unique_name": {"S": "unique_value"}})
22+
23+
test = operator(value)
24+
25+
assert "unique_name" not in test
26+
assert "unique_value" not in test

0 commit comments

Comments
 (0)