Skip to content

Commit

Permalink
fix: Use FORBID_ENCRYPT_ALLOW_DECRYPT policy for decrypt oracle (#538)
Browse files Browse the repository at this point in the history
* fix: Use FORBID_ENCRYPT_ALLOW_DECRYPT policy for decrypt oracle

* fix: pin tox version < 4.0

* Update decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/app.py

Co-authored-by: seebees <ryanemer@amazon.com>

* fix: change forward-slashes to pound for comment

* fix: linting issue - ran autoformatter

Co-authored-by: Shubham Chaturvedi <scchatur@amazon.com>
Co-authored-by: seebees <ryanemer@amazon.com>
  • Loading branch information
3 people committed Dec 22, 2022
1 parent 2822364 commit e91838f
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion codebuild/coverage/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ phases:
python: latest
build:
commands:
- pip install tox
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py310/awses_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ phases:
commands:
- pyenv install 3.10.0
- pyenv local 3.10.0
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- cd test_vector_handlers
- tox
2 changes: 1 addition & 1 deletion codebuild/py310/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.10.0
- pyenv local 3.10.0
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py310/integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.10.0
- pyenv local 3.10.0
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py37/awses_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ phases:
commands:
- pyenv install 3.7.12
- pyenv local 3.7.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- cd test_vector_handlers
- tox
2 changes: 1 addition & 1 deletion codebuild/py37/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.7.12
- pyenv local 3.7.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py37/integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.7.12
- pyenv local 3.7.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py38/awses_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ phases:
commands:
- pyenv install 3.8.12
- pyenv local 3.8.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- cd test_vector_handlers
- tox
2 changes: 1 addition & 1 deletion codebuild/py38/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.8.12
- pyenv local 3.8.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py38/integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.8.12
- pyenv local 3.8.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py39/awses_1.7.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ phases:
commands:
- pyenv install 3.9.7
- pyenv local 3.9.7
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- cd test_vector_handlers
- tox
2 changes: 1 addition & 1 deletion codebuild/py39/awses_2.0.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ phases:
commands:
- pyenv install 3.9.7
- pyenv local 3.9.7
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- cd test_vector_handlers
- tox
2 changes: 1 addition & 1 deletion codebuild/py39/awses_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ phases:
commands:
- pyenv install 3.9.7
- pyenv local 3.9.7
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- cd test_vector_handlers
- tox
2 changes: 1 addition & 1 deletion codebuild/py39/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.9.7
- pyenv local 3.9.7
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/py39/integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ phases:
commands:
- pyenv install 3.9.7
- pyenv local 3.9.7
- pip install tox tox-pyenv
- pip install "tox < 4.0"
- tox
2 changes: 1 addition & 1 deletion codebuild/release/prod-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
phases:
install:
commands:
- pip install tox
- pip install "tox < 4.0"
- pip install --upgrade pip
runtime-versions:
python: latest
Expand Down
2 changes: 1 addition & 1 deletion codebuild/release/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
phases:
install:
commands:
- pip install tox
- pip install "tox < 4.0"
- pip install --upgrade pip
runtime-versions:
python: latest
Expand Down
4 changes: 2 additions & 2 deletions codebuild/release/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 0.2
phases:
install:
commands:
- pip install tox
- pip install "tox < 4.0"
runtime-versions:
python: latest
pre_build:
Expand All @@ -13,7 +13,7 @@ phases:
- sed -i "s/aws_encryption_sdk/aws_encryption_sdk==$VERSION/" requirements-dev.txt
- pyenv install 3.8.12
- pyenv local 3.8.12
- pip install tox tox-pyenv
- pip install "tox < 4.0"
build:
commands:
- NUM_RETRIES=3
Expand Down
5 changes: 4 additions & 1 deletion decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os

import aws_encryption_sdk
from aws_encryption_sdk.identifiers import CommitmentPolicy
from aws_encryption_sdk.key_providers.kms import DiscoveryAwsKmsMasterKeyProvider
from chalice import Chalice, Response

Expand Down Expand Up @@ -59,7 +60,9 @@ def basic_decrypt() -> Response:
APP.log.debug(APP.current_request.raw_body)

try:
client = aws_encryption_sdk.EncryptionSDKClient()
# The decrypt oracle needs to be able to decrypt any message
# it does not encrypt messages for anyone.
client = aws_encryption_sdk.EncryptionSDKClient(commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT)
ciphertext = APP.current_request.raw_body
plaintext, _header = client.decrypt(source=ciphertext, key_provider=_master_key_provider())
APP.log.debug("Plaintext:")
Expand Down

0 comments on commit e91838f

Please sign in to comment.