From 2f4193500b418d54f0faa8816095dc45c2774020 Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Fri, 13 Nov 2026 13:19:19 -0800 Subject: [PATCH 1/7] chore(test): add integ test for null or empty KMS key ID --- test/integration/test_i_s3_encryption.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/integration/test_i_s3_encryption.py b/test/integration/test_i_s3_encryption.py index 4074c6ed..3697cb53 100644 --- a/test/integration/test_i_s3_encryption.py +++ b/test/integration/test_i_s3_encryption.py @@ -314,6 +314,22 @@ 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. +# Spec typo: in the quote below, "is not null or empty" should read "is 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, match="Kms Key ID cannot be empty or null"): + 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 From 904cba4c5eca00e7b2be81c66b2f235fcb6e09c5 Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Fri, 13 Nov 2026 13:19:33 -0800 Subject: [PATCH 2/7] fix: validate KmsKeyring key ID is not null or empty --- compliance_exceptions/kms_keyring_exceptions.md | 16 ---------------- src/s3_encryption/materials/kms_keyring.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/compliance_exceptions/kms_keyring_exceptions.md b/compliance_exceptions/kms_keyring_exceptions.md index 0da55fb3..3ceee721 100644 --- a/compliance_exceptions/kms_keyring_exceptions.md +++ b/compliance_exceptions/kms_keyring_exceptions.md @@ -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). diff --git a/src/s3_encryption/materials/kms_keyring.py b/src/s3_encryption/materials/kms_keyring.py index d829d886..f5e1aeca 100644 --- a/src/s3_encryption/materials/kms_keyring.py +++ b/src/s3_encryption/materials/kms_keyring.py @@ -52,6 +52,18 @@ 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. + # Spec typo: in the quote below, "is not null or empty" should read "is 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 From b01d999a81f6e76b64d865c550887560b30c7f9d Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Sun, 15 Nov 2026 20:43:48 -0800 Subject: [PATCH 3/7] chore(test): check only the exception type for null or empty KMS key ID --- test/integration/test_i_s3_encryption.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/test_i_s3_encryption.py b/test/integration/test_i_s3_encryption.py index 3697cb53..802b15d3 100644 --- a/test/integration/test_i_s3_encryption.py +++ b/test/integration/test_i_s3_encryption.py @@ -326,7 +326,7 @@ 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, match="Kms Key ID cannot be empty or null"): + with pytest.raises(S3EncryptionClientError): KmsKeyring(kms_client, invalid_kms_key_id) From 8d442b08c06c608eac65f0692270894539d8eb84 Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Sun, 15 Nov 2026 21:08:19 -0800 Subject: [PATCH 4/7] Revert "fix: validate KmsKeyring key ID is not null or empty" This reverts commit 904cba4c5eca00e7b2be81c66b2f235fcb6e09c5. --- compliance_exceptions/kms_keyring_exceptions.md | 16 ++++++++++++++++ src/s3_encryption/materials/kms_keyring.py | 12 ------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/compliance_exceptions/kms_keyring_exceptions.md b/compliance_exceptions/kms_keyring_exceptions.md index 3ceee721..0da55fb3 100644 --- a/compliance_exceptions/kms_keyring_exceptions.md +++ b/compliance_exceptions/kms_keyring_exceptions.md @@ -20,6 +20,22 @@ 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). diff --git a/src/s3_encryption/materials/kms_keyring.py b/src/s3_encryption/materials/kms_keyring.py index f5e1aeca..d829d886 100644 --- a/src/s3_encryption/materials/kms_keyring.py +++ b/src/s3_encryption/materials/kms_keyring.py @@ -52,18 +52,6 @@ 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. - # Spec typo: in the quote below, "is not null or empty" should read "is 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 From 519b8f367fd306d7f64c409b072245ba94d20935 Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Mon, 16 Nov 2026 09:53:44 -0800 Subject: [PATCH 5/7] fix: validate KmsKeyring key ID is not null or empty --- compliance_exceptions/kms_keyring_exceptions.md | 16 ---------------- src/s3_encryption/materials/kms_keyring.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/compliance_exceptions/kms_keyring_exceptions.md b/compliance_exceptions/kms_keyring_exceptions.md index 0da55fb3..3ceee721 100644 --- a/compliance_exceptions/kms_keyring_exceptions.md +++ b/compliance_exceptions/kms_keyring_exceptions.md @@ -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). diff --git a/src/s3_encryption/materials/kms_keyring.py b/src/s3_encryption/materials/kms_keyring.py index d829d886..f5e1aeca 100644 --- a/src/s3_encryption/materials/kms_keyring.py +++ b/src/s3_encryption/materials/kms_keyring.py @@ -52,6 +52,18 @@ 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. + # Spec typo: in the quote below, "is not null or empty" should read "is 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 From 5d2409ba5c29ed11f23e7da310879784ed517296 Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Mon, 16 Nov 2026 09:54:49 -0800 Subject: [PATCH 6/7] chore: remove spec typo comments --- src/s3_encryption/materials/kms_keyring.py | 1 - test/integration/test_i_s3_encryption.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/s3_encryption/materials/kms_keyring.py b/src/s3_encryption/materials/kms_keyring.py index f5e1aeca..91955d26 100644 --- a/src/s3_encryption/materials/kms_keyring.py +++ b/src/s3_encryption/materials/kms_keyring.py @@ -55,7 +55,6 @@ class KmsKeyring(S3Keyring): ##= 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. - # Spec typo: in the quote below, "is not null or empty" should read "is 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. diff --git a/test/integration/test_i_s3_encryption.py b/test/integration/test_i_s3_encryption.py index 802b15d3..5dcd4927 100644 --- a/test/integration/test_i_s3_encryption.py +++ b/test/integration/test_i_s3_encryption.py @@ -317,7 +317,6 @@ def test_inaccessible_kms_key_raises_access_denied(): ##= 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. -# Spec typo: in the quote below, "is not null or empty" should read "is 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. From abbd08dadb53831bf8a3f31ddf0914f791f897a2 Mon Sep 17 00:00:00 2001 From: joshuavemana9 Date: Mon, 16 Nov 2026 10:18:32 -0800 Subject: [PATCH 7/7] chore(ci): run test-server on macos-15-xlarge GitHub retired the macOS 14 runner images on November 2, 2026, so the test-server job can no longer run on macos-14-xlarge. --- .github/workflows/test-server.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-server.yml b/.github/workflows/test-server.yml index a774015d..506df018 100644 --- a/.github/workflows/test-server.yml +++ b/.github/workflows/test-server.yml @@ -12,7 +12,7 @@ on: jobs: test-server: - runs-on: macos-14-xlarge + runs-on: macos-15-xlarge permissions: id-token: write contents: read