forked from p15670423/monkey
Island: Fix string/bytes bug in StringListEncryptor
For some reason, bytes objects do not come out of mongo the same way they go in. This class will be removed when reporting is reworked, so rather than spend the time on figuring out exactly what's going on, just use strings.
This commit is contained in:
parent
e1c5972ccc
commit
e349a78334
|
@ -29,7 +29,8 @@ def save_report(report_dict: dict):
|
|||
|
||||
def get_report() -> dict:
|
||||
report_dict = Report.objects.first().to_mongo()
|
||||
return _decode_dot_char_before_mongo_insert(decrypt_dict(sensitive_fields, report_dict))
|
||||
decrypted = decrypt_dict(sensitive_fields, report_dict)
|
||||
return _decode_dot_char_before_mongo_insert(decrypted)
|
||||
|
||||
|
||||
# TODO remove this unnecessary encoding. I think these are legacy methods from back in the day
|
||||
|
|
|
@ -6,9 +6,9 @@ from . import IFieldEncryptor
|
|||
|
||||
class StringListEncryptor(IFieldEncryptor):
|
||||
@staticmethod
|
||||
def encrypt(value: List[str]):
|
||||
return [get_datastore_encryptor().encrypt(string.encode()) for string in value]
|
||||
def encrypt(value: List[str]) -> List[str]:
|
||||
return [get_datastore_encryptor().encrypt(string.encode()).decode() for string in value]
|
||||
|
||||
@staticmethod
|
||||
def decrypt(value: List[bytes]):
|
||||
return [get_datastore_encryptor().decrypt(bytes_).decode() for bytes_ in value]
|
||||
def decrypt(value: List[str]) -> List[str]:
|
||||
return [get_datastore_encryptor().decrypt(string.encode()).decode() for string in value]
|
||||
|
|
Loading…
Reference in New Issue