Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
test-server:
runs-on: macos-14-xlarge
runs-on: macos-15-xlarge
permissions:
id-token: write
contents: read
Expand Down
16 changes: 0 additions & 16 deletions compliance_exceptions/kms_keyring_exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ The Python S3 Encryption Client implementation takes a pragmatic approach that:

## Initialization Validation

##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=exception
##% The KmsKeyring MAY validate that the AWS KMS key identifier is not null or empty.

Justification: This validation is not implemented. The Python implementation relies on attrs field validation and KMS SDK to catch invalid key identifiers.

---

##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=exception
##% If the KmsKeyring validates that the AWS KMS key identifier is not null or empty, then it MUST throw an exception.

Justification: Not applicable since the MAY validation above is not implemented. If we don't validate, we don't need to throw an exception for validation failure.

---

##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=exception
##% The KmsKeyring MAY validate that the AWS KMS key identifier is [a valid AWS KMS Key identifier](../../framework/aws-kms/aws-kms-key-arn.md#a-valid-aws-kms-identifier).
Expand Down
11 changes: 11 additions & 0 deletions src/s3_encryption/materials/kms_keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ class KmsKeyring(S3Keyring):
##% The KmsV1 mode MUST be only enabled when legacy wrapping algorithms are enabled.
enable_legacy_wrapping_algorithms: bool = field(default=False)

##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=implementation
##% The KmsKeyring MAY validate that the AWS KMS key identifier is not null or empty.
##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=implementation
##% If the KmsKeyring validates that the AWS KMS key identifier is not null or empty, then it MUST throw an exception.
@kms_key_id.validator
def _validate_kms_key_id(self, attribute, value):
if value is None or value == "":
raise S3EncryptionClientError("Kms Key ID cannot be empty or null")

def __attrs_post_init__(self): # noqa: D105
from .._utils import _USER_AGENT_SUFFIX, append_user_agent

Expand Down
15 changes: 15 additions & 0 deletions test/integration/test_i_s3_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,21 @@ def test_inaccessible_kms_key_raises_access_denied():
assert cause.response["Error"]["Code"] == "AccessDeniedException"


##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=test
##% The KmsKeyring MAY validate that the AWS KMS key identifier is not null or empty.
##= specification/s3-encryption/materials/s3-kms-keyring.md#initialization
##= type=test
##% If the KmsKeyring validates that the AWS KMS key identifier is not null or empty, then it MUST throw an exception.
@pytest.mark.parametrize("invalid_kms_key_id", [None, ""], ids=["null", "empty"])
def test_null_or_empty_kms_key_id_raises_at_keyring_creation(invalid_kms_key_id):
"""A null or empty KMS key ID MUST be rejected when the KmsKeyring is created."""
kms_client = boto3.client("kms", region_name=region)

with pytest.raises(S3EncryptionClientError):
KmsKeyring(kms_client, invalid_kms_key_id)


def test_get_nonexistent_object_raises_no_such_key():
"""get_object for a key that doesn't exist MUST surface NoSuchKey."""
from botocore.exceptions import ClientError
Expand Down
Loading