From 7675bc2101db348b547655eb8c3158386d5cce4b Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Tue, 2 Nov 2021 18:01:29 -0500 Subject: [PATCH 01/17] ci(GitHub): update setup-python to v2 --- .github/workflows/ci_decrypt-oracle.yaml | 2 +- .github/workflows/ci_static-analysis.yaml | 2 +- .github/workflows/ci_test-vector-handler.yaml | 2 +- .github/workflows/ci_tests.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_decrypt-oracle.yaml b/.github/workflows/ci_decrypt-oracle.yaml index 7bced5ebf..e773bd98a 100644 --- a/.github/workflows/ci_decrypt-oracle.yaml +++ b/.github/workflows/ci_decrypt-oracle.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: # The oracle runs in a Python 3.6 Lamba python-version: 3.6 diff --git a/.github/workflows/ci_static-analysis.yaml b/.github/workflows/ci_static-analysis.yaml index 1b659fa5a..31705a5d3 100644 --- a/.github/workflows/ci_static-analysis.yaml +++ b/.github/workflows/ci_static-analysis.yaml @@ -28,7 +28,7 @@ jobs: - isort-check steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: python-version: 3.8 - run: | diff --git a/.github/workflows/ci_test-vector-handler.yaml b/.github/workflows/ci_test-vector-handler.yaml index 1b24390e4..75556dc13 100644 --- a/.github/workflows/ci_test-vector-handler.yaml +++ b/.github/workflows/ci_test-vector-handler.yaml @@ -47,7 +47,7 @@ jobs: aws-secret-access-key: ${{ secrets.INTEG_AWS_SECRET_ACCESS_KEY }} aws-region: us-west-2 - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.architecture }} diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 0926e60ad..aa4da3886 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -52,7 +52,7 @@ jobs: architecture: x86 steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.architecture }} From a02c5527dddb5ccc277a51805dcdaa2038ec0574 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Tue, 2 Nov 2021 18:07:22 -0500 Subject: [PATCH 02/17] ci(CodeBuild): update CodeBuild to the latest minor releases of python --- codebuild/py35/awses_local.yml | 4 ++-- codebuild/py35/examples.yml | 4 ++-- codebuild/py35/integ.yml | 4 ++-- codebuild/py36/awses_local.yml | 6 ++++-- codebuild/py36/examples.yml | 4 +++- codebuild/py36/integ.yml | 4 +++- codebuild/py37/awses_local.yml | 4 ++-- codebuild/py37/examples.yml | 4 ++-- codebuild/py37/integ.yml | 4 ++-- codebuild/py38/awses_local.yml | 4 ++-- codebuild/py38/examples.yml | 4 ++-- codebuild/py38/integ.yml | 4 ++-- codebuild/py39/awses_1.7.1.yml | 4 ++-- codebuild/py39/awses_2.0.0.yml | 4 ++-- codebuild/py39/awses_latest.yml | 4 ++-- codebuild/py39/examples.yml | 4 ++-- codebuild/py39/integ.yml | 4 ++-- 17 files changed, 38 insertions(+), 32 deletions(-) diff --git a/codebuild/py35/awses_local.yml b/codebuild/py35/awses_local.yml index 71583417a..77668996d 100644 --- a/codebuild/py35/awses_local.yml +++ b/codebuild/py35/awses_local.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.5.9 - - pyenv local 3.5.9 + - pyenv install 3.5.10 + - pyenv local 3.5.10 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py35/examples.yml b/codebuild/py35/examples.yml index 109f2764c..08939ca07 100644 --- a/codebuild/py35/examples.yml +++ b/codebuild/py35/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.5.9 - - pyenv local 3.5.9 + - pyenv install 3.5.10 + - pyenv local 3.5.10 - pip install tox tox-pyenv - tox diff --git a/codebuild/py35/integ.yml b/codebuild/py35/integ.yml index 0014378ba..bcec41b6c 100644 --- a/codebuild/py35/integ.yml +++ b/codebuild/py35/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.5.9 - - pyenv local 3.5.9 + - pyenv install 3.5.10 + - pyenv local 3.5.10 - pip install tox tox-pyenv - tox diff --git a/codebuild/py36/awses_local.yml b/codebuild/py36/awses_local.yml index dba6a28ba..cd3296ea5 100644 --- a/codebuild/py36/awses_local.yml +++ b/codebuild/py36/awses_local.yml @@ -20,6 +20,8 @@ phases: python: latest build: commands: - - pip install tox - - cd test_vector_handlers + - pyenv install 3.6.15 + - pyenv local 3.6.15 + - pip install tox tox-pyenv - tox +’ diff --git a/codebuild/py36/examples.yml b/codebuild/py36/examples.yml index 1bd091d11..46af14902 100644 --- a/codebuild/py36/examples.yml +++ b/codebuild/py36/examples.yml @@ -18,5 +18,7 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.6.15 + - pyenv local 3.6.15 + - pip install tox tox-pyenv - tox diff --git a/codebuild/py36/integ.yml b/codebuild/py36/integ.yml index 35124c835..d55581c43 100644 --- a/codebuild/py36/integ.yml +++ b/codebuild/py36/integ.yml @@ -18,5 +18,7 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.6.15 + - pyenv local 3.6.15 + - pip install tox tox-pyenv - tox diff --git a/codebuild/py37/awses_local.yml b/codebuild/py37/awses_local.yml index 958823841..9e77d43f7 100644 --- a/codebuild/py37/awses_local.yml +++ b/codebuild/py37/awses_local.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.7.9 - - pyenv local 3.7.9 + - pyenv install 3.7.12 + - pyenv local 3.7.12 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py37/examples.yml b/codebuild/py37/examples.yml index cbe251cf0..57d1626df 100644 --- a/codebuild/py37/examples.yml +++ b/codebuild/py37/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.7.9 - - pyenv local 3.7.9 + - pyenv install 3.7.12 + - pyenv local 3.7.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py37/integ.yml b/codebuild/py37/integ.yml index 27ce515d0..04d24c26d 100644 --- a/codebuild/py37/integ.yml +++ b/codebuild/py37/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.7.9 - - pyenv local 3.7.9 + - pyenv install 3.7.12 + - pyenv local 3.7.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py38/awses_local.yml b/codebuild/py38/awses_local.yml index b221abe72..4e20973d4 100644 --- a/codebuild/py38/awses_local.yml +++ b/codebuild/py38/awses_local.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.8.6 - - pyenv local 3.8.6 + - pyenv install 3.8.12 + - pyenv local 3.8.12 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py38/examples.yml b/codebuild/py38/examples.yml index c9a9f9a7a..1a8f4f826 100644 --- a/codebuild/py38/examples.yml +++ b/codebuild/py38/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.8.6 - - pyenv local 3.8.6 + - pyenv install 3.8.12 + - pyenv local 3.8.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py38/integ.yml b/codebuild/py38/integ.yml index 31cbb7d43..28eae25fc 100644 --- a/codebuild/py38/integ.yml +++ b/codebuild/py38/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.8.6 - - pyenv local 3.8.6 + - pyenv install 3.8.12 + - pyenv local 3.8.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py39/awses_1.7.1.yml b/codebuild/py39/awses_1.7.1.yml index 4da84dfa5..e261b5e4d 100644 --- a/codebuild/py39/awses_1.7.1.yml +++ b/codebuild/py39/awses_1.7.1.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py39/awses_2.0.0.yml b/codebuild/py39/awses_2.0.0.yml index cf8f90b36..b4a6654d5 100644 --- a/codebuild/py39/awses_2.0.0.yml +++ b/codebuild/py39/awses_2.0.0.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py39/awses_latest.yml b/codebuild/py39/awses_latest.yml index 9a2b12190..ac70cede8 100644 --- a/codebuild/py39/awses_latest.yml +++ b/codebuild/py39/awses_latest.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py39/examples.yml b/codebuild/py39/examples.yml index 38b1f01c7..9b1911024 100644 --- a/codebuild/py39/examples.yml +++ b/codebuild/py39/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - tox diff --git a/codebuild/py39/integ.yml b/codebuild/py39/integ.yml index 49e8f6d1c..c7452e37e 100644 --- a/codebuild/py39/integ.yml +++ b/codebuild/py39/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - tox From fb74b99ac40261cae1e98c59e48c7bd9411d09e7 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 09:19:27 -0500 Subject: [PATCH 03/17] ci(py310): test against python3.10.0 --- codebuild/py310/awses_local.yml | 27 +++++++++++++++++++++++++++ codebuild/py310/examples.yml | 24 ++++++++++++++++++++++++ codebuild/py310/integ.yml | 24 ++++++++++++++++++++++++ tox.ini | 4 ++-- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 codebuild/py310/awses_local.yml create mode 100644 codebuild/py310/examples.yml create mode 100644 codebuild/py310/integ.yml diff --git a/codebuild/py310/awses_local.yml b/codebuild/py310/awses_local.yml new file mode 100644 index 000000000..a60eba6d2 --- /dev/null +++ b/codebuild/py310/awses_local.yml @@ -0,0 +1,27 @@ +version: 0.2 + +env: + variables: + TOXENV: "py310-awses_local" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_API_DEPLOYMENT_ID: "xi1mwx3ttb" + AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_REGION: "us-west-2" + +phases: + install: + runtime-versions: + python: latest + build: + commands: + - pyenv install 3.10.0 + - pyenv local 3.10.0 + - pip install tox tox-pyenv + - cd test_vector_handlers + - tox diff --git a/codebuild/py310/examples.yml b/codebuild/py310/examples.yml new file mode 100644 index 000000000..59bb42499 --- /dev/null +++ b/codebuild/py310/examples.yml @@ -0,0 +1,24 @@ +version: 0.2 + +env: + variables: + TOXENV: "py310-examples" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: latest + build: + commands: + - pyenv install 3.10.0 + - pyenv local 3.10.0 + - pip install tox tox-pyenv + - tox diff --git a/codebuild/py310/integ.yml b/codebuild/py310/integ.yml new file mode 100644 index 000000000..3346a06a2 --- /dev/null +++ b/codebuild/py310/integ.yml @@ -0,0 +1,24 @@ +version: 0.2 + +env: + variables: + TOXENV: "py310-integ" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: latest + build: + commands: + - pyenv install 3.10.0 + - pyenv local 3.10.0 + - pip install tox tox-pyenv + - tox diff --git a/tox.ini b/tox.ini index 110ae7263..7006ae0e0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{35,36,37,38,39}-{local,integ,accept,examples}, nocmk, + py{35,36,37,38,39,310}-{local,integ,accept,examples}, nocmk, bandit, doc8, readme, docs, {flake8,pylint}{,-tests,-examples}, isort-check, black-check, @@ -318,7 +318,7 @@ commands = # Release tooling [testenv:park] -basepython = python3.6 +basepython = python3.7 skip_install = true deps = pypi-parker From df24e2be1a4bc29f46e78a9e479f0cf241dad394 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 09:44:06 -0500 Subject: [PATCH 04/17] style(lint): suppress fstring --- decrypt_oracle/src/pylintrc | 1 + decrypt_oracle/test/pylintrc | 1 + examples/src/pylintrc | 1 + examples/test/pylintrc | 1 + src/pylintrc | 1 + test/pylintrc | 1 + test_vector_handlers/src/pylintrc | 1 + test_vector_handlers/test/pylintrc | 1 + 8 files changed, 8 insertions(+) diff --git a/decrypt_oracle/src/pylintrc b/decrypt_oracle/src/pylintrc index 8dcba5d63..2e1e6336e 100644 --- a/decrypt_oracle/src/pylintrc +++ b/decrypt_oracle/src/pylintrc @@ -3,6 +3,7 @@ disable = bad-continuation, # we let black handle this ungrouped-imports, # we let isort handle this + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/decrypt_oracle/test/pylintrc b/decrypt_oracle/test/pylintrc index bb64faf87..3d4a895b2 100644 --- a/decrypt_oracle/test/pylintrc +++ b/decrypt_oracle/test/pylintrc @@ -5,6 +5,7 @@ disable = missing-docstring, # we don't write docstrings for tests bad-continuation, # we let black handle this ungrouped-imports, # we let isort handle this + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/examples/src/pylintrc b/examples/src/pylintrc index dcb72e849..858fa4d96 100644 --- a/examples/src/pylintrc +++ b/examples/src/pylintrc @@ -14,6 +14,7 @@ disable = attribute-defined-outside-init, # breaks with attrs_post_init abstract-method, # throws false positives on io.BaseIO grandchildren redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [BASIC] # Allow function names up to 50 characters diff --git a/examples/test/pylintrc b/examples/test/pylintrc index b30a3e202..67090eedf 100644 --- a/examples/test/pylintrc +++ b/examples/test/pylintrc @@ -7,6 +7,7 @@ disable = # unknown modules as non-standard-library. flake8 tests for this as well # and does treat them properly duplicate-code, # tests for similar things tend to be similar + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [VARIABLES] additional-builtins = raw_input diff --git a/src/pylintrc b/src/pylintrc index 1919d76e5..d187a5ea8 100644 --- a/src/pylintrc +++ b/src/pylintrc @@ -14,6 +14,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [BASIC] # Allow function names up to 50 characters diff --git a/test/pylintrc b/test/pylintrc index 599a9e182..21365a29e 100644 --- a/test/pylintrc +++ b/test/pylintrc @@ -22,6 +22,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [VARIABLES] additional-builtins = raw_input diff --git a/test_vector_handlers/src/pylintrc b/test_vector_handlers/src/pylintrc index ebd2eb02e..c78fe416a 100644 --- a/test_vector_handlers/src/pylintrc +++ b/test_vector_handlers/src/pylintrc @@ -8,6 +8,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/test_vector_handlers/test/pylintrc b/test_vector_handlers/test/pylintrc index 5aa03d3ae..bc118f899 100644 --- a/test_vector_handlers/test/pylintrc +++ b/test_vector_handlers/test/pylintrc @@ -11,6 +11,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 From 5102a97bb0e26aabeb124f2cf9a6437c36d91625 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:02:33 -0500 Subject: [PATCH 05/17] feat(identifiers): Check Python Runtime Issues a WARNING if the Python Version will become unsupported. Prints an ERROR to STDERR if Python Version is unsupported. Will start issuing WARNING for Python Version less than 3.6. Will start printing ERROR for Python Version less than 3.5 AFTER Jan 1st, 2022. --- src/aws_encryption_sdk/__init__.py | 5 ++- src/aws_encryption_sdk/identifiers.py | 44 ++++++++++++++++++ test/unit/test_check_python_version.py | 62 ++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 test/unit/test_check_python_version.py diff --git a/src/aws_encryption_sdk/__init__.py b/src/aws_encryption_sdk/__init__.py index 0525f332d..f6f0636b3 100644 --- a/src/aws_encryption_sdk/__init__.py +++ b/src/aws_encryption_sdk/__init__.py @@ -12,7 +12,6 @@ # language governing permissions and limitations under the License. """High level AWS Encryption SDK client functions.""" # Below are imported for ease of use by implementors - import warnings import attr @@ -20,7 +19,7 @@ from aws_encryption_sdk.caches.local import LocalCryptoMaterialsCache # noqa from aws_encryption_sdk.caches.null import NullCryptoMaterialsCache # noqa from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError # noqa -from aws_encryption_sdk.identifiers import Algorithm, CommitmentPolicy, __version__ # noqa +from aws_encryption_sdk.identifiers import Algorithm, CommitmentPolicy, __version__, check_python_version # noqa from aws_encryption_sdk.internal.utils.signature import SignaturePolicy # noqa from aws_encryption_sdk.key_providers.kms import ( # noqa DiscoveryAwsKmsMasterKeyProvider, @@ -36,6 +35,8 @@ StreamEncryptor, ) +check_python_version() + @attr.s(hash=True) class EncryptionSDKClientConfig(object): diff --git a/src/aws_encryption_sdk/identifiers.py b/src/aws_encryption_sdk/identifiers.py index 9d94e0378..907dd5d7e 100644 --- a/src/aws_encryption_sdk/identifiers.py +++ b/src/aws_encryption_sdk/identifiers.py @@ -11,7 +11,10 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """AWS Encryption SDK native data structures for defining implementation-specific characteristics.""" +import datetime import struct +import sys +import warnings from enum import Enum from cryptography.hazmat.primitives import hashes @@ -378,3 +381,44 @@ class CommitmentPolicy(Enum): FORBID_ENCRYPT_ALLOW_DECRYPT = 0 REQUIRE_ENCRYPT_ALLOW_DECRYPT = 1 REQUIRE_ENCRYPT_REQUIRE_DECRYPT = 2 + + +class PythonVersionSupport: + """Configures Python Version warnings/error messaging""" + + WARN_BELOW_MAJOR = 3 + WARN_BELOW_MINOR = 6 + ERROR_BELOW_MAJOR = 3 + ERROR_BELOW_MINOR = 5 + ERROR_DATE = datetime.datetime(year=2022, month=1, day=1) + + +def check_python_version( + warn_below_major=PythonVersionSupport.WARN_BELOW_MAJOR, + warn_below_minor=PythonVersionSupport.WARN_BELOW_MINOR, + error_below_major=PythonVersionSupport.ERROR_BELOW_MAJOR, + error_below_minor=PythonVersionSupport.ERROR_BELOW_MINOR, + error_date=PythonVersionSupport.ERROR_DATE, +): + """Checks that we are on a supported version of Python. + Prints an error message to stderr if the Python Version is unsupported and therefore untested. + Emits a warning if the Python version will be unsupported. + """ + if datetime.datetime.now() > error_date and ( + sys.version_info.major < error_below_major or sys.version_info.minor < error_below_minor + ): + sys.stderr.write( + "ERROR: Python {} is not supported by the aws-encryption-sdk! ".format( + ".".join(map(str, [sys.version_info.major, sys.version_info.minor])) + ) + + "Please upgrade to Python {} or higher.".format(".".join(map(str, [warn_below_major, warn_below_minor]))) + ) + return + if sys.version_info.major < warn_below_major or sys.version_info.minor < warn_below_minor: + warnings.warn( + "Python {} support will be removed in a future release. ".format( + ".".join(map(str, [sys.version_info.major, sys.version_info.minor])) + ) + + "Please upgrade to Python {} or higher.".format(".".join(map(str, [warn_below_major, warn_below_minor]))), + DeprecationWarning, + ) diff --git a/test/unit/test_check_python_version.py b/test/unit/test_check_python_version.py new file mode 100644 index 000000000..e965502a6 --- /dev/null +++ b/test/unit/test_check_python_version.py @@ -0,0 +1,62 @@ +# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Unit test suite for ensuring the Python Runtime is supported.""" +import datetime +import sys + +import mock +import pytest + +from aws_encryption_sdk import check_python_version +from aws_encryption_sdk.identifiers import PythonVersionSupport + +pytestmark = [pytest.mark.unit, pytest.mark.local] + + +class TestBeforeErrorDate: + def test_happy_version(self): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = PythonVersionSupport.WARN_BELOW_MAJOR + v_info.minor = PythonVersionSupport.WARN_BELOW_MINOR + with pytest.warns(None) as record: + check_python_version(error_date=datetime.datetime.now() + datetime.timedelta(days=1)) + assert len(record) == 0 + + def test_below_warn(self): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = PythonVersionSupport.WARN_BELOW_MAJOR - 1 + v_info.minor = PythonVersionSupport.WARN_BELOW_MINOR + with pytest.warns(DeprecationWarning): + check_python_version(error_date=datetime.datetime.now() + datetime.timedelta(days=1)) + + +class TestAfterErrorDate: + def test_happy_version(self, capsys): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = PythonVersionSupport.WARN_BELOW_MAJOR + v_info.minor = PythonVersionSupport.WARN_BELOW_MINOR + with pytest.warns(None) as record: + check_python_version(error_date=datetime.datetime.now() - datetime.timedelta(days=1)) + assert len(record) == 0 + captured = capsys.readouterr().err + assert "ERROR" not in captured + + def test_below_error(self, capsys): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = PythonVersionSupport.ERROR_BELOW_MAJOR + v_info.minor = PythonVersionSupport.ERROR_BELOW_MINOR - 1 + with pytest.warns(None) as record: + check_python_version(error_date=datetime.datetime.now() - datetime.timedelta(days=1)) + assert len(record) == 0 + captured = capsys.readouterr().err + assert "ERROR" in captured From 0f1d548c009e8988fe2bd67d4ad3bfa1eeaaabd3 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:22:28 -0500 Subject: [PATCH 06/17] ci(GitHub): test with Python 3.10 --- .github/workflows/ci_test-vector-handler.yaml | 2 ++ .github/workflows/ci_tests.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/ci_test-vector-handler.yaml b/.github/workflows/ci_test-vector-handler.yaml index 75556dc13..b906f374d 100644 --- a/.github/workflows/ci_test-vector-handler.yaml +++ b/.github/workflows/ci_test-vector-handler.yaml @@ -26,6 +26,8 @@ jobs: - 3.6 - 3.7 - 3.8 + - 3.9 + - 3.10 - 3.x architecture: - x64 diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index aa4da3886..d431f0978 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -33,6 +33,7 @@ jobs: - 3.7 - 3.8 - 3.9 + - 3.10 - 3.x architecture: - x64 From 762cc2aff8ce085f9199339c1e21feed03b7fc3a Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:28:57 -0500 Subject: [PATCH 07/17] revert: 0f1d548c009e8988fe2bd67d4ad3bfa1eeaaabd3 This reverts: "ci(GitHub): test with Python 3.10" --- .github/workflows/ci_test-vector-handler.yaml | 2 -- .github/workflows/ci_tests.yaml | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/ci_test-vector-handler.yaml b/.github/workflows/ci_test-vector-handler.yaml index b906f374d..75556dc13 100644 --- a/.github/workflows/ci_test-vector-handler.yaml +++ b/.github/workflows/ci_test-vector-handler.yaml @@ -26,8 +26,6 @@ jobs: - 3.6 - 3.7 - 3.8 - - 3.9 - - 3.10 - 3.x architecture: - x64 diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index d431f0978..aa4da3886 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -33,7 +33,6 @@ jobs: - 3.7 - 3.8 - 3.9 - - 3.10 - 3.x architecture: - x64 From bc56b83ad4f776dbf3d3da473340ab522856956e Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 17:15:33 -0500 Subject: [PATCH 08/17] fix(CodeBuild): Add Python 3.10 to buildspec --- buildspec.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index 461d4e0d2..689530343 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -37,6 +37,12 @@ batch: buildspec: codebuild/py39/examples.yml - identifier: py39_awses_latest + - identifier: py310_integ + buildspec: codebuild/py310/integ.yml + - identifier: py310_examples + buildspec: codebuild/py310/examples.yml + - identifier: py310_awses_latest + - identifier: code_coverage buildspec: codebuild/coverage/coverage.yml From fabd4430b846bb22b40d4dd11646ddeba0d7bae1 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Wed, 3 Nov 2021 17:17:02 -0500 Subject: [PATCH 09/17] fix(CodeBuild): Add Python 3.10 to buildspec --- buildspec.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index 689530343..474054d4b 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -42,6 +42,8 @@ batch: - identifier: py310_examples buildspec: codebuild/py310/examples.yml - identifier: py310_awses_latest + buildspec: codebuild/py310/awses_local.yml + - identifier: code_coverage buildspec: codebuild/coverage/coverage.yml From cfe27bd9bf1846612f425de3de5abc35e9020987 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Thu, 4 Nov 2021 13:25:17 -0500 Subject: [PATCH 10/17] ci(test_vector_handlers): add Python3.10 to tox --- test_vector_handlers/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_vector_handlers/tox.ini b/test_vector_handlers/tox.ini index 41920d76d..7418b2e98 100644 --- a/test_vector_handlers/tox.ini +++ b/test_vector_handlers/tox.ini @@ -2,7 +2,7 @@ envlist = # The test vectors depend on new features now, # so until release we can only effectively test the local version of the ESDK. - py{35,36,37,38,39}-awses_local, + py{35,36,37,38,39,310}-awses_local, # 1.2.0 and 1.2.max are being difficult because of attrs bandit, doc8, readme, docs, {flake8,pylint}{,-tests}, From 4db40c505d661e056b4510e183933d91f6e6b006 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Thu, 4 Nov 2021 14:48:18 -0500 Subject: [PATCH 11/17] fix(CodeBuild): typo in Python3.6 awses_local --- codebuild/py36/awses_local.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/codebuild/py36/awses_local.yml b/codebuild/py36/awses_local.yml index cd3296ea5..15b8a4ce0 100644 --- a/codebuild/py36/awses_local.yml +++ b/codebuild/py36/awses_local.yml @@ -24,4 +24,3 @@ phases: - pyenv local 3.6.15 - pip install tox tox-pyenv - tox -’ From 8ee95385e96e6365913a5bbdb95e31f875c448ae Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:07:49 -0500 Subject: [PATCH 12/17] fix(CodeBuild): forgot to cd in Python3.6 awses_local --- codebuild/py36/awses_local.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codebuild/py36/awses_local.yml b/codebuild/py36/awses_local.yml index 15b8a4ce0..b68a7e434 100644 --- a/codebuild/py36/awses_local.yml +++ b/codebuild/py36/awses_local.yml @@ -23,4 +23,5 @@ phases: - pyenv install 3.6.15 - pyenv local 3.6.15 - pip install tox tox-pyenv + - cd test_vector_handlers - tox From ce4955c2cbad634063d613db17f8a514e1bbad29 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:23:10 -0700 Subject: [PATCH 13/17] refactor(check_python_version): link directly to support policy Replaces check_python_version with _warn_deprecated_python. _warn_deprecated_python is copied from the AWS SDK for Python (boto3/compat.py) and refactored for the ESDK. No Error will ever be logged, only a warning for Pythons 2.7, 3.4, and 3.5. Testing is added that not only checks the logic of the function, but also parses the SUPPORT_POLICY.rst for dates and ensures that the dates saved in compatability.py are accurate. --- src/aws_encryption_sdk/__init__.py | 5 +- src/aws_encryption_sdk/compatability.py | 39 ++++++++ src/aws_encryption_sdk/identifiers.py | 44 --------- src/aws_encryption_sdk/streaming_client.py | 2 +- test/unit/test_check_python_version.py | 62 ------------ test/unit/test_compatability.py | 107 +++++++++++++++++++++ 6 files changed, 150 insertions(+), 109 deletions(-) create mode 100644 src/aws_encryption_sdk/compatability.py delete mode 100644 test/unit/test_check_python_version.py create mode 100644 test/unit/test_compatability.py diff --git a/src/aws_encryption_sdk/__init__.py b/src/aws_encryption_sdk/__init__.py index f6f0636b3..661d41ee6 100644 --- a/src/aws_encryption_sdk/__init__.py +++ b/src/aws_encryption_sdk/__init__.py @@ -18,8 +18,9 @@ from aws_encryption_sdk.caches.local import LocalCryptoMaterialsCache # noqa from aws_encryption_sdk.caches.null import NullCryptoMaterialsCache # noqa +from aws_encryption_sdk.compatability import _warn_deprecated_python from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError # noqa -from aws_encryption_sdk.identifiers import Algorithm, CommitmentPolicy, __version__, check_python_version # noqa +from aws_encryption_sdk.identifiers import Algorithm, CommitmentPolicy, __version__ # noqa from aws_encryption_sdk.internal.utils.signature import SignaturePolicy # noqa from aws_encryption_sdk.key_providers.kms import ( # noqa DiscoveryAwsKmsMasterKeyProvider, @@ -35,7 +36,7 @@ StreamEncryptor, ) -check_python_version() +_warn_deprecated_python() @attr.s(hash=True) diff --git a/src/aws_encryption_sdk/compatability.py b/src/aws_encryption_sdk/compatability.py new file mode 100644 index 000000000..4dbc022d0 --- /dev/null +++ b/src/aws_encryption_sdk/compatability.py @@ -0,0 +1,39 @@ +# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Contains logic for checking ESDK and Python Version""" +import sys +import warnings + +DEPRECATION_DATE_MAP = {"1.x": "2022-06-30", "2.x": "2022-07-01"} + + +def _warn_deprecated_python(): + """Template for deprecation of Python warning.""" + deprecated_versions = { + (2, 7): {"date": DEPRECATION_DATE_MAP["2.x"]}, + (3, 4): {"date": DEPRECATION_DATE_MAP["2.x"]}, + (3, 5): {"date": "2021-11-10"}, + } + py_version = (sys.version_info.major, sys.version_info.minor) + minimum_version = (3, 6) + + if py_version in deprecated_versions: + params = deprecated_versions[py_version] + warning = ( + "aws-encryption-sdk will no longer support Python {}.{} " + "starting {}. To continue receiving service updates, " + "bug fixes, and security updates please upgrade to Python {}.{} or " + "later. For more information, see SUPPORT_POLICY.rst: " + "https://github.com/aws/aws-encryption-sdk-python/blob/master/SUPPORT_POLICY.rst" + ).format(py_version[0], py_version[1], minimum_version[0], minimum_version[1], params["date"]) + warnings.warn(warning, DeprecationWarning) diff --git a/src/aws_encryption_sdk/identifiers.py b/src/aws_encryption_sdk/identifiers.py index 907dd5d7e..9d94e0378 100644 --- a/src/aws_encryption_sdk/identifiers.py +++ b/src/aws_encryption_sdk/identifiers.py @@ -11,10 +11,7 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """AWS Encryption SDK native data structures for defining implementation-specific characteristics.""" -import datetime import struct -import sys -import warnings from enum import Enum from cryptography.hazmat.primitives import hashes @@ -381,44 +378,3 @@ class CommitmentPolicy(Enum): FORBID_ENCRYPT_ALLOW_DECRYPT = 0 REQUIRE_ENCRYPT_ALLOW_DECRYPT = 1 REQUIRE_ENCRYPT_REQUIRE_DECRYPT = 2 - - -class PythonVersionSupport: - """Configures Python Version warnings/error messaging""" - - WARN_BELOW_MAJOR = 3 - WARN_BELOW_MINOR = 6 - ERROR_BELOW_MAJOR = 3 - ERROR_BELOW_MINOR = 5 - ERROR_DATE = datetime.datetime(year=2022, month=1, day=1) - - -def check_python_version( - warn_below_major=PythonVersionSupport.WARN_BELOW_MAJOR, - warn_below_minor=PythonVersionSupport.WARN_BELOW_MINOR, - error_below_major=PythonVersionSupport.ERROR_BELOW_MAJOR, - error_below_minor=PythonVersionSupport.ERROR_BELOW_MINOR, - error_date=PythonVersionSupport.ERROR_DATE, -): - """Checks that we are on a supported version of Python. - Prints an error message to stderr if the Python Version is unsupported and therefore untested. - Emits a warning if the Python version will be unsupported. - """ - if datetime.datetime.now() > error_date and ( - sys.version_info.major < error_below_major or sys.version_info.minor < error_below_minor - ): - sys.stderr.write( - "ERROR: Python {} is not supported by the aws-encryption-sdk! ".format( - ".".join(map(str, [sys.version_info.major, sys.version_info.minor])) - ) - + "Please upgrade to Python {} or higher.".format(".".join(map(str, [warn_below_major, warn_below_minor]))) - ) - return - if sys.version_info.major < warn_below_major or sys.version_info.minor < warn_below_minor: - warnings.warn( - "Python {} support will be removed in a future release. ".format( - ".".join(map(str, [sys.version_info.major, sys.version_info.minor])) - ) - + "Please upgrade to Python {} or higher.".format(".".join(map(str, [warn_below_major, warn_below_minor]))), - DeprecationWarning, - ) diff --git a/src/aws_encryption_sdk/streaming_client.py b/src/aws_encryption_sdk/streaming_client.py index ac215c259..54eb046d2 100644 --- a/src/aws_encryption_sdk/streaming_client.py +++ b/src/aws_encryption_sdk/streaming_client.py @@ -70,7 +70,7 @@ _LOGGER = logging.getLogger(__name__) -@attr.s(hash=True) +@attr.s(hash=True) # pylint: disable=too-many-instance-attributes @six.add_metaclass(abc.ABCMeta) class _ClientConfig(object): # pylint: disable=too-many-instance-attributes """Parent configuration object for StreamEncryptor and StreamDecryptor objects. diff --git a/test/unit/test_check_python_version.py b/test/unit/test_check_python_version.py deleted file mode 100644 index e965502a6..000000000 --- a/test/unit/test_check_python_version.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"). You -# may not use this file except in compliance with the License. A copy of -# the License is located at -# -# http://aws.amazon.com/apache2.0/ -# -# or in the "license" file accompanying this file. This file is -# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF -# ANY KIND, either express or implied. See the License for the specific -# language governing permissions and limitations under the License. -"""Unit test suite for ensuring the Python Runtime is supported.""" -import datetime -import sys - -import mock -import pytest - -from aws_encryption_sdk import check_python_version -from aws_encryption_sdk.identifiers import PythonVersionSupport - -pytestmark = [pytest.mark.unit, pytest.mark.local] - - -class TestBeforeErrorDate: - def test_happy_version(self): - with mock.patch.object(sys, "version_info") as v_info: - v_info.major = PythonVersionSupport.WARN_BELOW_MAJOR - v_info.minor = PythonVersionSupport.WARN_BELOW_MINOR - with pytest.warns(None) as record: - check_python_version(error_date=datetime.datetime.now() + datetime.timedelta(days=1)) - assert len(record) == 0 - - def test_below_warn(self): - with mock.patch.object(sys, "version_info") as v_info: - v_info.major = PythonVersionSupport.WARN_BELOW_MAJOR - 1 - v_info.minor = PythonVersionSupport.WARN_BELOW_MINOR - with pytest.warns(DeprecationWarning): - check_python_version(error_date=datetime.datetime.now() + datetime.timedelta(days=1)) - - -class TestAfterErrorDate: - def test_happy_version(self, capsys): - with mock.patch.object(sys, "version_info") as v_info: - v_info.major = PythonVersionSupport.WARN_BELOW_MAJOR - v_info.minor = PythonVersionSupport.WARN_BELOW_MINOR - with pytest.warns(None) as record: - check_python_version(error_date=datetime.datetime.now() - datetime.timedelta(days=1)) - assert len(record) == 0 - captured = capsys.readouterr().err - assert "ERROR" not in captured - - def test_below_error(self, capsys): - with mock.patch.object(sys, "version_info") as v_info: - v_info.major = PythonVersionSupport.ERROR_BELOW_MAJOR - v_info.minor = PythonVersionSupport.ERROR_BELOW_MINOR - 1 - with pytest.warns(None) as record: - check_python_version(error_date=datetime.datetime.now() - datetime.timedelta(days=1)) - assert len(record) == 0 - captured = capsys.readouterr().err - assert "ERROR" in captured diff --git a/test/unit/test_compatability.py b/test/unit/test_compatability.py new file mode 100644 index 000000000..3219a68c1 --- /dev/null +++ b/test/unit/test_compatability.py @@ -0,0 +1,107 @@ +# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Unit test suite for aws_encryption_sdk.compatability""" +import os +import re +import sys + +import mock +import pytest +from typing import Mapping, Optional + +from aws_encryption_sdk.compatability import DEPRECATION_DATE_MAP, _warn_deprecated_python + +pytestmark = [pytest.mark.unit, pytest.mark.local] + + +def _parse_support_policy() -> Mapping[str, str]: + """Parses SUPPORT_POLICY.rst for Major Version Dates + + The code here is strongly tied to the format of SUPPORT_POLICY.rst. + If the format changes, this logic will need to be refactored as well. + + :rtype Mapping[str, str] + :return Mapping of keys from DEPRECATION_DATE_MAP to parsed date + """ + here = os.path.abspath(os.path.dirname(__file__)) + mv_date_line_offset = 3 + + def read(*args): + """Reads complete file contents.""" + return open(os.path.join(here, *args), encoding="utf-8").read() # pylint: disable=consider-using-with + + def _major_version_re_frmt(mvstr: str) -> str: + mv_str_lst = mvstr.split(".") + mv_str_lst.insert(1, r"\.") + return "".join(mv_str_lst) + + reg_mv_base = r"[\s]*\* - " # In support table, major versions are entered as "\t * - \d.x" + reg_date = re.compile(r"[\d]{4}-[\d]{2}-[\d]{2}") + mv_regs = {mv: re.compile(reg_mv_base + _major_version_re_frmt(mv)) for mv in DEPRECATION_DATE_MAP} + + def _match_mv_reg(a_line: str, reg_exp, mvstr: str) -> Optional[str]: + """Match a Major Version string in a row of the support version table + :return None or Major Version String + """ + if reg_exp.match(a_line): + return mvstr + + def _match_mv_regs(a_line: str) -> Optional[str]: + """Check for any Major Version string in a row + :return None or Major Version String + """ + for mv in DEPRECATION_DATE_MAP: + return_str = _match_mv_reg(a_line, mv_regs[mv], mv) + if return_str: + return return_str + + map_mvstr_date = {} + support_policy = read("../../SUPPORT_POLICY.rst").splitlines() + for line_number, line in enumerate(support_policy): + a_mv = _match_mv_regs(line) + if a_mv: + map_mvstr_date[a_mv] = reg_date.search(support_policy[line_number + mv_date_line_offset]).group() + return map_mvstr_date + + +@pytest.fixture(scope="module") +def parsed_deprecation_date_map(): + try: + return _parse_support_policy() + except Exception as ex: + raise RuntimeError( + "The Format of SUPPORT_POLICY.rst has changed! " "The logic in test_compatability must be updated!" + ) + + +def test_deprecation_date_map_accurate(parsed_deprecation_date_map): + assert ( + parsed_deprecation_date_map == DEPRECATION_DATE_MAP + ), "The DEPRECATION_DATE_MAP in aws_encryption_sdk.compatability is not accurate!" + + +class TestWarnDeprecatedPython: + def test_happy_version(self): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = 3 + v_info.minor = 6 + with pytest.warns(None) as record: + _warn_deprecated_python() + assert len(record) == 0 + + def test_below_warn(self): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = 2 + v_info.minor = 7 + with pytest.warns(DeprecationWarning): + _warn_deprecated_python() From e231906ddf4f249d28027f82f13f3f71e927a33f Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:39:25 -0700 Subject: [PATCH 14/17] style(test_compatability): address flake8 and pylint issues with test --- test/unit/test_compatability.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/test_compatability.py b/test/unit/test_compatability.py index 3219a68c1..164494594 100644 --- a/test/unit/test_compatability.py +++ b/test/unit/test_compatability.py @@ -14,10 +14,10 @@ import os import re import sys +from typing import Mapping, Optional import mock import pytest -from typing import Mapping, Optional from aws_encryption_sdk.compatability import DEPRECATION_DATE_MAP, _warn_deprecated_python @@ -49,14 +49,14 @@ def _major_version_re_frmt(mvstr: str) -> str: reg_date = re.compile(r"[\d]{4}-[\d]{2}-[\d]{2}") mv_regs = {mv: re.compile(reg_mv_base + _major_version_re_frmt(mv)) for mv in DEPRECATION_DATE_MAP} - def _match_mv_reg(a_line: str, reg_exp, mvstr: str) -> Optional[str]: + def _match_mv_reg(a_line: str, reg_exp, mvstr: str) -> Optional[str]: # pylint: disable=inconsistent-return-statements """Match a Major Version string in a row of the support version table :return None or Major Version String """ if reg_exp.match(a_line): return mvstr - def _match_mv_regs(a_line: str) -> Optional[str]: + def _match_mv_regs(a_line: str) -> Optional[str]: # pylint: disable=inconsistent-return-statements """Check for any Major Version string in a row :return None or Major Version String """ @@ -78,7 +78,7 @@ def _match_mv_regs(a_line: str) -> Optional[str]: def parsed_deprecation_date_map(): try: return _parse_support_policy() - except Exception as ex: + except Exception: raise RuntimeError( "The Format of SUPPORT_POLICY.rst has changed! " "The logic in test_compatability must be updated!" ) From aaa521297d2597444b066a001957897698c176e9 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:56:27 -0700 Subject: [PATCH 15/17] style(test_compatability): address flake8 and pylint issues with test --- test/pylintrc | 2 ++ test/unit/test_compatability.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/pylintrc b/test/pylintrc index 21365a29e..ceff0ad13 100644 --- a/test/pylintrc +++ b/test/pylintrc @@ -5,6 +5,7 @@ disable = missing-docstring, # we don't write docstrings for tests bad-continuation, # we let black handle this ungrouped-imports, # we let isort handle this + wrong-import-order, # we let isort handle this abstract-class-instantiated, # we do this on purpose to test that they are enforced no-member, # raised on patched objects with mock checks no-self-use, # common pattern when using pytest classes: can be enabled once all tests are refactored to pytest functions @@ -24,6 +25,7 @@ disable = super-with-arguments, consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + [VARIABLES] additional-builtins = raw_input diff --git a/test/unit/test_compatability.py b/test/unit/test_compatability.py index 164494594..f5e068a5c 100644 --- a/test/unit/test_compatability.py +++ b/test/unit/test_compatability.py @@ -14,10 +14,10 @@ import os import re import sys -from typing import Mapping, Optional import mock import pytest +from typing import Mapping, Optional from aws_encryption_sdk.compatability import DEPRECATION_DATE_MAP, _warn_deprecated_python @@ -49,7 +49,9 @@ def _major_version_re_frmt(mvstr: str) -> str: reg_date = re.compile(r"[\d]{4}-[\d]{2}-[\d]{2}") mv_regs = {mv: re.compile(reg_mv_base + _major_version_re_frmt(mv)) for mv in DEPRECATION_DATE_MAP} - def _match_mv_reg(a_line: str, reg_exp, mvstr: str) -> Optional[str]: # pylint: disable=inconsistent-return-statements + def _match_mv_reg( # pylint: disable=inconsistent-return-statements + a_line: str, reg_exp, mvstr: str + ) -> Optional[str]: """Match a Major Version string in a row of the support version table :return None or Major Version String """ From 461027b402f9f22299223841454b8621f76620c7 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 8 Nov 2021 10:10:20 -0700 Subject: [PATCH 16/17] chore: deprecate python 3.5 --- .github/workflows/ci_test-vector-handler.yaml | 1 - .github/workflows/ci_tests.yaml | 1 - README.rst | 2 +- buildspec.yml | 7 ----- codebuild/py35/awses_local.yml | 27 ------------------- codebuild/py35/examples.yml | 24 ----------------- codebuild/py35/integ.yml | 24 ----------------- decrypt_oracle/tox.ini | 2 +- setup.py | 1 - tox.ini | 2 +- 10 files changed, 3 insertions(+), 88 deletions(-) delete mode 100644 codebuild/py35/awses_local.yml delete mode 100644 codebuild/py35/examples.yml delete mode 100644 codebuild/py35/integ.yml diff --git a/.github/workflows/ci_test-vector-handler.yaml b/.github/workflows/ci_test-vector-handler.yaml index 75556dc13..1c33fecdb 100644 --- a/.github/workflows/ci_test-vector-handler.yaml +++ b/.github/workflows/ci_test-vector-handler.yaml @@ -22,7 +22,6 @@ jobs: - macos-latest python: - 2.7 - - 3.5 - 3.6 - 3.7 - 3.8 diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index aa4da3886..c562e167f 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -28,7 +28,6 @@ jobs: - windows-latest - macos-latest python: - - 3.5 - 3.6 - 3.7 - 3.8 diff --git a/README.rst b/README.rst index b6feff4da..7f1b22824 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ Getting Started Required Prerequisites ====================== -* Python 3.5+ +* Python 3.6+ * cryptography >= 2.5.0 * boto3 >= 1.10.0 * attrs diff --git a/buildspec.yml b/buildspec.yml index 474054d4b..bb1e0cd97 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -3,13 +3,6 @@ version: 0.2 batch: fast-fail: false build-list: - - identifier: py35_integ - buildspec: codebuild/py35/integ.yml - - identifier: py35_examples - buildspec: codebuild/py35/examples.yml - - identifier: py35_awses_local - buildspec: codebuild/py35/awses_local.yml - - identifier: py36_integ buildspec: codebuild/py36/integ.yml - identifier: py36_examples diff --git a/codebuild/py35/awses_local.yml b/codebuild/py35/awses_local.yml deleted file mode 100644 index 77668996d..000000000 --- a/codebuild/py35/awses_local.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: 0.2 - -env: - variables: - TOXENV: "py35-awses_local" - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- - arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- - arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- - arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- - arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 - AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_API_DEPLOYMENT_ID: "xi1mwx3ttb" - AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_REGION: "us-west-2" - -phases: - install: - runtime-versions: - python: latest - build: - commands: - - pyenv install 3.5.10 - - pyenv local 3.5.10 - - pip install tox tox-pyenv - - cd test_vector_handlers - - tox diff --git a/codebuild/py35/examples.yml b/codebuild/py35/examples.yml deleted file mode 100644 index 08939ca07..000000000 --- a/codebuild/py35/examples.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: 0.2 - -env: - variables: - TOXENV: "py35-examples" - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- - arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- - arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- - arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- - arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 - -phases: - install: - runtime-versions: - python: latest - build: - commands: - - pyenv install 3.5.10 - - pyenv local 3.5.10 - - pip install tox tox-pyenv - - tox diff --git a/codebuild/py35/integ.yml b/codebuild/py35/integ.yml deleted file mode 100644 index bcec41b6c..000000000 --- a/codebuild/py35/integ.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: 0.2 - -env: - variables: - TOXENV: "py35-integ" - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- - arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- - arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- - arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 - AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- - arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 - -phases: - install: - runtime-versions: - python: latest - build: - commands: - - pyenv install 3.5.10 - - pyenv local 3.5.10 - - pip install tox tox-pyenv - - tox diff --git a/decrypt_oracle/tox.ini b/decrypt_oracle/tox.ini index ef39c65d2..b90d9f527 100644 --- a/decrypt_oracle/tox.ini +++ b/decrypt_oracle/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{35,36,37,38,39}-{local,integ}, + py{36,37,38,39}-{local,integ}, bandit, doc8, readme, docs, {flake8,pylint}{,-tests}, # prone to false positives diff --git a/setup.py b/setup.py index bfe48b091..2db856d89 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,6 @@ def get_requirements(): "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/tox.ini b/tox.ini index 7006ae0e0..f6a293f0c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{35,36,37,38,39,310}-{local,integ,accept,examples}, nocmk, + py{36,37,38,39,310}-{local,integ,accept,examples}, nocmk, bandit, doc8, readme, docs, {flake8,pylint}{,-tests,-examples}, isort-check, black-check, From 7550d520ab6d135ac0deab8be2618c001897a21e Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 8 Nov 2021 10:41:04 -0700 Subject: [PATCH 17/17] chore: Changelog for 3.1 release --- CHANGELOG.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 190259b3d..362b53f49 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,25 @@ Changelog ********* +3.1.0 -- 2021-11-10 +=================== + +Deprecation +----------- +The AWS Encryption SDK for Python no longer supports Python 3.5 +as of version 3.1; only Python 3.6+ is supported. Customers using +Python 3.5 can still use the 2.x line of the AWS Encryption SDK for Python, +which will continue to receive security updates, in accordance +with our `Support Policy `__. + +Feature +----------- +* Warn on Deprecated Python usage + `#368 `_ +* Add Python 3.10 to CI +* Remove Python 3.5 from testing + + 3.0.0 -- 2021-07-01 ===================