Island: Use MONGO_OBJECT_ID_KEY in MongoCredentialsRepository

This commit is contained in:
Mike Salvatore 2022-08-29 19:32:40 -04:00
parent bf6125dd55
commit 10d8d8e756
1 changed files with 3 additions and 1 deletions

View File

@ -7,6 +7,8 @@ from monkey_island.cc.repository import RemovalError, RetrievalError, StorageErr
from monkey_island.cc.repository.i_credentials_repository import ICredentialsRepository
from monkey_island.cc.server_utils.encryption import ILockableEncryptor
from .consts import MONGO_OBJECT_ID_KEY
class MongoCredentialsRepository(ICredentialsRepository):
"""
@ -51,7 +53,7 @@ class MongoCredentialsRepository(ICredentialsRepository):
collection_result = []
list_collection_result = list(collection.find({}))
for encrypted_credentials in list_collection_result:
del encrypted_credentials["_id"]
del encrypted_credentials[MONGO_OBJECT_ID_KEY]
plaintext_credentials = self._decrypt_credentials_mapping(encrypted_credentials)
collection_result.append(Credentials.from_mapping(plaintext_credentials))