mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
vault: call is_encrypted directly in is_encrypted_file
Doing the conversion and checking for exceptions there is pointless since is_encrypted already does it.
This commit is contained in:
parent
385f1d82dc
commit
680d61c609
1 changed files with 2 additions and 11 deletions
|
@ -147,20 +147,11 @@ def is_encrypted_file(file_obj, start_pos=0, count=-1):
|
|||
current_position = file_obj.tell()
|
||||
try:
|
||||
file_obj.seek(start_pos)
|
||||
vaulttext = file_obj.read(count)
|
||||
try:
|
||||
b_vaulttext = to_bytes(to_text(vaulttext, encoding='ascii', errors='strict'), encoding='ascii', errors='strict')
|
||||
except (UnicodeError, TypeError):
|
||||
# At present, vault files contain only ascii characters. The encoding is utf-8
|
||||
# without BOM (for future expansion). If the header does not
|
||||
# decode as ascii then we know we do not have proper vault
|
||||
# encrypted data.
|
||||
return False
|
||||
return is_encrypted(file_obj.read(count))
|
||||
|
||||
finally:
|
||||
file_obj.seek(current_position)
|
||||
|
||||
return is_encrypted(b_vaulttext)
|
||||
|
||||
|
||||
class VaultLib:
|
||||
|
||||
|
|
Loading…
Reference in a new issue