Island: Add all imports from encryption to __init__

Now the imports are shorter by one directory.
Check the __init__ in encryption.
This commit is contained in:
Ilija Lazoroski 2021-09-23 18:42:40 +02:00
parent 071a4eb1a7
commit e0779347b2
18 changed files with 30 additions and 31 deletions

View File

@ -5,6 +5,7 @@ exclude = monkey/monkey_island/cc/ui,vulture_allowlist.py
show-source = True show-source = True
max-complexity = 10 max-complexity = 10
max-line-length = 100 max-line-length = 100
per-file-ignores = __init__.py:F401
### ignore "whitespace before ':'", "line break before binary operator" for ### ignore "whitespace before ':'", "line break before binary operator" for
### compatibility with black, and cyclomatic complexity (for now). ### compatibility with black, and cyclomatic complexity (for now).

View File

@ -1,7 +1,7 @@
from typing import List from typing import List
from monkey_island.cc.models.utils.field_encryptors.i_field_encryptor import IFieldEncryptor from monkey_island.cc.models.utils.field_encryptors.i_field_encryptor import IFieldEncryptor
from monkey_island.cc.server_utils.encryption.data_store_encryptor import get_encryptor from monkey_island.cc.server_utils.encryption import get_encryptor
class StringListEncryptor(IFieldEncryptor): class StringListEncryptor(IFieldEncryptor):

View File

@ -4,9 +4,7 @@ import flask_restful
from flask import request from flask import request
from monkey_island.cc.resources.auth.auth import jwt_required from monkey_island.cc.resources.auth.auth import jwt_required
from monkey_island.cc.server_utils.encryption.password_based_encryption import ( from monkey_island.cc.server_utils.encryption import PasswordBasedEncryptor
PasswordBasedEncryptor,
)
from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.config import ConfigService

View File

@ -8,7 +8,7 @@ from flask import request
from common.utils.exceptions import InvalidConfigurationError from common.utils.exceptions import InvalidConfigurationError
from monkey_island.cc.resources.auth.auth import jwt_required from monkey_island.cc.resources.auth.auth import jwt_required
from monkey_island.cc.server_utils.encryption.password_based_encryption import ( from monkey_island.cc.server_utils.encryption import (
InvalidCiphertextError, InvalidCiphertextError,
InvalidCredentialsError, InvalidCredentialsError,
PasswordBasedEncryptor, PasswordBasedEncryptor,

View File

@ -27,9 +27,7 @@ from monkey_island.cc.server_utils.consts import ( # noqa: E402
GEVENT_EXCEPTION_LOG, GEVENT_EXCEPTION_LOG,
MONGO_CONNECTION_TIMEOUT, MONGO_CONNECTION_TIMEOUT,
) )
from monkey_island.cc.server_utils.encryption.data_store_encryptor import ( # noqa: E402 from monkey_island.cc.server_utils.encryption import initialize_encryptor # noqa: E402
initialize_encryptor,
)
from monkey_island.cc.server_utils.island_logger import reset_logger, setup_logging # noqa: E402 from monkey_island.cc.server_utils.island_logger import reset_logger, setup_logging # noqa: E402
from monkey_island.cc.services.initialize import initialize_services # noqa: E402 from monkey_island.cc.services.initialize import initialize_services # noqa: E402
from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402 from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402

View File

@ -1 +1,13 @@
from monkey_island.cc.server_utils.encryption.i_encryptor import IEncryptor # noqa: F401 from monkey_island.cc.server_utils.encryption.i_encryptor import IEncryptor
from monkey_island.cc.server_utils.encryption.key_based_encryptor import KeyBasedEncryptor
from monkey_island.cc.server_utils.encryption.password_based_encryption import (
InvalidCiphertextError,
InvalidCredentialsError,
PasswordBasedEncryptor,
is_encrypted,
)
from monkey_island.cc.server_utils.encryption.data_store_encryptor import (
DataStoreEncryptor,
get_encryptor,
initialize_encryptor,
)

View File

@ -4,7 +4,7 @@ import os
# is maintained. # is maintained.
from Crypto import Random # noqa: DUO133 # nosec: B413 from Crypto import Random # noqa: DUO133 # nosec: B413
from monkey_island.cc.server_utils.encryption.key_based_encryptor import KeyBasedEncryptor from monkey_island.cc.server_utils.encryption import KeyBasedEncryptor
from monkey_island.cc.server_utils.file_utils import open_new_securely_permissioned_file from monkey_island.cc.server_utils.file_utils import open_new_securely_permissioned_file
_encryptor = None _encryptor = None

View File

@ -1,4 +1,4 @@
from monkey_island.cc.server_utils.encryption.data_store_encryptor import get_encryptor from monkey_island.cc.server_utils.encryption import get_encryptor
def parse_creds(attempt): def parse_creds(attempt):

View File

@ -19,7 +19,7 @@ from common.config_value_paths import (
USER_LIST_PATH, USER_LIST_PATH,
) )
from monkey_island.cc.database import mongo from monkey_island.cc.database import mongo
from monkey_island.cc.server_utils.encryption.data_store_encryptor import get_encryptor from monkey_island.cc.server_utils.encryption import get_encryptor
from monkey_island.cc.services.config_manipulator import update_config_per_mode from monkey_island.cc.services.config_manipulator import update_config_per_mode
from monkey_island.cc.services.config_schema.config_schema import SCHEMA from monkey_island.cc.services.config_schema.config_schema import SCHEMA
from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode

View File

@ -3,7 +3,7 @@ import copy
import dateutil import dateutil
from monkey_island.cc.models import Monkey from monkey_island.cc.models import Monkey
from monkey_island.cc.server_utils.encryption.data_store_encryptor import get_encryptor from monkey_island.cc.server_utils.encryption import get_encryptor
from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.edge.displayed_edge import EdgeService from monkey_island.cc.services.edge.displayed_edge import EdgeService
from monkey_island.cc.services.node import NodeService from monkey_island.cc.services.node import NodeService

View File

@ -1,6 +1,6 @@
import logging import logging
from monkey_island.cc.server_utils.encryption.data_store_encryptor import get_encryptor from monkey_island.cc.server_utils.encryption import get_encryptor
from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.node import NodeService from monkey_island.cc.services.node import NodeService
from monkey_island.cc.services.telemetry.processing.system_info_collectors.system_info_telemetry_dispatcher import ( # noqa: E501 from monkey_island.cc.services.telemetry.processing.system_info_collectors.system_info_telemetry_dispatcher import ( # noqa: E501

View File

@ -5,7 +5,7 @@ from ScoutSuite.providers.base.authentication_strategy import AuthenticationExce
from common.cloud.scoutsuite_consts import CloudProviders from common.cloud.scoutsuite_consts import CloudProviders
from common.config_value_paths import AWS_KEYS_PATH from common.config_value_paths import AWS_KEYS_PATH
from common.utils.exceptions import InvalidAWSKeys from common.utils.exceptions import InvalidAWSKeys
from monkey_island.cc.server_utils.encryption.data_store_encryptor import get_encryptor from monkey_island.cc.server_utils.encryption import get_encryptor
from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.config import ConfigService

View File

@ -1,7 +1,7 @@
import pytest import pytest
from monkey_island.cc.models.utils.field_encryptors.string_list_encryptor import StringListEncryptor from monkey_island.cc.models.utils.field_encryptors.string_list_encryptor import StringListEncryptor
from monkey_island.cc.server_utils.encryption.data_store_encryptor import initialize_encryptor from monkey_island.cc.server_utils.encryption import initialize_encryptor
MOCK_STRING_LIST = ["test_1", "test_2"] MOCK_STRING_LIST = ["test_1", "test_2"]
EMPTY_LIST = [] EMPTY_LIST = []

View File

@ -8,9 +8,7 @@ from tests.unit_tests.monkey_island.cc.services.utils.ciphertexts_for_encryption
from common.utils.exceptions import InvalidConfigurationError from common.utils.exceptions import InvalidConfigurationError
from monkey_island.cc.resources.configuration_import import ConfigurationImport from monkey_island.cc.resources.configuration_import import ConfigurationImport
from monkey_island.cc.server_utils.encryption.password_based_encryption import ( from monkey_island.cc.server_utils.encryption import PasswordBasedEncryptor
PasswordBasedEncryptor,
)
def test_is_config_encrypted__json(monkey_config_json): def test_is_config_encrypted__json(monkey_config_json):

View File

@ -1,9 +1,6 @@
import os import os
from monkey_island.cc.server_utils.encryption.data_store_encryptor import ( from monkey_island.cc.server_utils.encryption import get_encryptor, initialize_encryptor
get_encryptor,
initialize_encryptor,
)
PASSWORD_FILENAME = "mongo_key.bin" PASSWORD_FILENAME = "mongo_key.bin"

View File

@ -4,10 +4,7 @@ from tests.unit_tests.monkey_island.cc.services.utils.ciphertexts_for_encryption
VALID_CIPHER_TEXT, VALID_CIPHER_TEXT,
) )
from monkey_island.cc.server_utils.encryption.password_based_encryption import ( from monkey_island.cc.server_utils.encryption import InvalidCredentialsError, PasswordBasedEncryptor
InvalidCredentialsError,
PasswordBasedEncryptor,
)
MONKEY_CONFIGS_DIR_PATH = "monkey_configs" MONKEY_CONFIGS_DIR_PATH = "monkey_configs"
STANDARD_PLAINTEXT_MONKEY_CONFIG_FILENAME = "monkey_config_standard.json" STANDARD_PLAINTEXT_MONKEY_CONFIG_FILENAME = "monkey_config_standard.json"

View File

@ -5,10 +5,7 @@ import pytest
from common.config_value_paths import AWS_KEYS_PATH from common.config_value_paths import AWS_KEYS_PATH
from monkey_island.cc.database import mongo from monkey_island.cc.database import mongo
from monkey_island.cc.server_utils.encryption.data_store_encryptor import ( from monkey_island.cc.server_utils.encryption import get_encryptor, initialize_encryptor
get_encryptor,
initialize_encryptor,
)
from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_auth_service import ( from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_auth_service import (
is_aws_keys_setup, is_aws_keys_setup,

View File

@ -12,6 +12,7 @@ include_trailing_comma = true
force_grid_wrap = 0 force_grid_wrap = 0
use_parentheses = true use_parentheses = true
ensure_newline_before_comments = true ensure_newline_before_comments = true
skip_glob="**/__init__.py"
[tool.pytest.ini_options] [tool.pytest.ini_options]
minversion = "6.0" minversion = "6.0"