From 10d8d8e7561e1ac02696ce8a3660484c45040fe7 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 29 Aug 2022 19:32:40 -0400 Subject: [PATCH] Island: Use MONGO_OBJECT_ID_KEY in MongoCredentialsRepository --- .../cc/repository/mongo_credentials_repository.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/repository/mongo_credentials_repository.py b/monkey/monkey_island/cc/repository/mongo_credentials_repository.py index ee8beb13c..25789f937 100644 --- a/monkey/monkey_island/cc/repository/mongo_credentials_repository.py +++ b/monkey/monkey_island/cc/repository/mongo_credentials_repository.py @@ -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))