Skip to content

Commit c022c2f

Browse files
bmcoelhocfpipeline
andauthored
Added Python version validation before update kms decrypt output (#765)
Co-authored-by: cfpipeline <cfpipeline@bt.com>
1 parent eda3a52 commit c022c2f

File tree

1 file changed

+9
-1
lines changed
  • stacker/lookups/handlers

1 file changed

+9
-1
lines changed

stacker/lookups/handlers/kms.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import division
33
from __future__ import absolute_import
44
import codecs
5+
import sys
56
from stacker.session_cache import get_session
67

78
from . import LookupHandler
@@ -63,5 +64,12 @@ def handle(cls, value, **kwargs):
6364
# get raw but still encrypted value from base64 version.
6465
decoded = codecs.decode(value, 'base64')
6566

67+
# check python version in your system
68+
python3_or_later = sys.version_info[0] >= 3
69+
6670
# decrypt and return the plain text raw value.
67-
return kms.decrypt(CiphertextBlob=decoded)["Plaintext"]
71+
if python3_or_later:
72+
return kms.decrypt(CiphertextBlob=decoded)["Plaintext"]\
73+
.decode('utf-8')
74+
else:
75+
return kms.decrypt(CiphertextBlob=decoded)["Plaintext"]

0 commit comments

Comments
 (0)