Datasets:

Modalities:
Text
Formats:
json
Languages:
code
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
cve-single-line-fixes / data /python /pythoncvefixed4.txt
Asankhaya Sharma
i
2e1f3f3
raw
history blame
983 Bytes
import yamltry: from ansible.utils.vault import VaultLibexcept ImportError: # Ansible 2.0 has changed the vault location from ansible.parsing.vault import VaultLibclass Vault(object): '''R/W an ansible-vault yaml file''' def __init__(self, password): self.password = password self.vault = VaultLib(password) def load(self, stream): '''read vault steam and return python object''' # BUG: CWE-94 Improper Control of Generation of Code ('Code Injection') # return yaml.load(self.vault.decrypt(stream)) # FIXED: return yaml.safe_load(self.vault.decrypt(stream)) def dump(self, data, stream=None): '''encrypt data and print stdout or write to stream''' yaml_text = yaml.dump( data, default_flow_style=False, allow_unicode=True) encrypted = self.vault.encrypt(yaml_text) if stream: stream.write(encrypted) else: return encrypted