2023-07-13 18:28:09 +00:00
|
|
|
import bwpass
|
|
|
|
|
2024-11-08 05:39:59 +00:00
|
|
|
|
2023-07-13 18:28:09 +00:00
|
|
|
def demagify(something, vault):
|
|
|
|
if isinstance(something, str):
|
|
|
|
if something.startswith('!bwpass:'):
|
|
|
|
return bwpass.password(something[8:])
|
|
|
|
elif something.startswith('!bwpass_attr:'):
|
|
|
|
identifier, attribute = something[13:].split(':', 1)
|
|
|
|
return bwpass.attr(identifier, attribute)
|
|
|
|
elif something.startswith('!decrypt:'):
|
|
|
|
return vault.decrypt(something[9:])
|
|
|
|
return something
|
|
|
|
elif isinstance(something, dict):
|
|
|
|
return {k:demagify(v, vault) for k,v in something.items()}
|
|
|
|
elif isinstance(something, list):
|
|
|
|
return [demagify(i, vault) for i in something]
|
|
|
|
elif isinstance(something, set):
|
|
|
|
return {demagify(i, vault) for i in something}
|
|
|
|
elif isinstance(something, tuple):
|
|
|
|
return tuple([demagify(i, vault) for i in something])
|
|
|
|
return something
|