Skip to content

Commit

Permalink
convert to use yaml.safe_load (#122)
Browse files Browse the repository at this point in the history
Convert tests to use yaml.safe_load instead of insecure yaml.load

yaml/pyyaml#243
  • Loading branch information
flatnine committed Jan 7, 2019
1 parent 91b3a7d commit 072abe3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/test_cli.py
Expand Up @@ -54,7 +54,7 @@ def test_encrypt(tmpdir, kms_stub):

main(['encrypt-file', six.text_type(tmpfile)])

data = yaml.load(tmpfile.read())
data = yaml.safe_load(tmpfile.read())
assert data['MY_ENCRYPTED_VAR'] == {'encrypted': base64.b64encode(b'quux').decode('utf-8')}
assert data['MY_UNENCRYPTED_VAR'] == 'bar'
assert data['TREEHUGGER_APP'] == 'baz'
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_encrypt_different_key(tmpdir, kms_stub):

main(['-k', key_arn, 'encrypt-file', six.text_type(tmpfile)])

data = yaml.load(tmpfile.read())
data = yaml.safe_load(tmpfile.read())
assert data['MY_ENCRYPTED_VAR'] == {'encrypted': base64.b64encode(b'quux').decode('utf-8')}
assert data['MY_UNENCRYPTED_VAR'] == 'bar'
assert data['TREEHUGGER_APP'] == 'baz'
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_encrypt_different_key_env_var(tmpdir, kms_stub):
with mock.patch.dict(os.environ, {'TREEHUGGER_KEY': key_id}):
main(['encrypt-file', six.text_type(tmpfile)])

data = yaml.load(tmpfile.read())
data = yaml.safe_load(tmpfile.read())
assert data['MY_ENCRYPTED_VAR'] == {'encrypted': base64.b64encode(b'quux').decode('utf-8')}
assert data['MY_UNENCRYPTED_VAR'] == 'bar'
assert data['TREEHUGGER_APP'] == 'baz'
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_decrypt(tmpdir, kms_stub):

main(['decrypt-file', six.text_type(tmpfile)])

data = yaml.load(tmpfile.read())
data = yaml.safe_load(tmpfile.read())
assert data['MY_ENCRYPTED_VAR'] == {'to_encrypt': 'quux'}
assert data['MY_UNENCRYPTED_VAR'] == 'bar'
assert data['TREEHUGGER_APP'] == 'baz'
Expand Down

0 comments on commit 072abe3

Please sign in to comment.