Merge pull request #1081 from guardicore/isort-everything

Isort everything
This commit is contained in:
Mike Salvatore 2021-04-07 07:30:06 -04:00 committed by GitHub
commit 1d7211e8dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 85 additions and 109 deletions

View File

@ -58,7 +58,7 @@ script:
- flake8 ./monkey
## Check import order
- python -m isort ./monkey --settings-file ./ci_scripts/isort.cfg
- python -m isort ./monkey --check-only
## Check that all python is properly formatted. Fail otherwise.
- python -m black --check .

View File

@ -17,3 +17,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Monkey agents are stored in the configurable data_dir when monkey is "run
from the island". #997
- Reformated all code using black. #1070
- Sort all imports usind isort. #1081

View File

@ -1,6 +0,0 @@
[isort]
# Possible options: https://pycqa.github.io/isort/docs/configuration/options/
known_first_party=common,infection_monkey,monkey_island
skip=monkey/common/cloud/scoutsuite,monkey/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/rule_path_building/rule_path_creators_list.py,monkey/monkey_island/cc/ui,monkey/common/cloud/scoutsuite

View File

@ -1,13 +1,13 @@
from typing import List
from pprint import pformat
from typing import List
import dpath.util
from common.config_value_paths import (
USER_LIST_PATH,
PASSWORD_LIST_PATH,
NTLM_HASH_LIST_PATH,
LM_HASH_LIST_PATH,
NTLM_HASH_LIST_PATH,
PASSWORD_LIST_PATH,
USER_LIST_PATH,
)
from envs.monkey_zoo.blackbox.analyzers.analyzer import Analyzer
from envs.monkey_zoo.blackbox.analyzers.analyzer_log import AnalyzerLog

View File

@ -3,8 +3,8 @@ import json
import dpath.util
from typing_extensions import Type
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
class IslandConfigParser:

View File

@ -7,8 +7,6 @@ from typing_extensions import Type
from envs.monkey_zoo.blackbox.analyzers.communication_analyzer import CommunicationAnalyzer
from envs.monkey_zoo.blackbox.analyzers.zerologon_analyzer import ZerologonAnalyzer
from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandConfigParser
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate
from envs.monkey_zoo.blackbox.config_templates.drupal import Drupal
from envs.monkey_zoo.blackbox.config_templates.elastic import Elastic
@ -25,6 +23,8 @@ from envs.monkey_zoo.blackbox.config_templates.weblogic import Weblogic
from envs.monkey_zoo.blackbox.config_templates.wmi_mimikatz import WmiMimikatz
from envs.monkey_zoo.blackbox.config_templates.wmi_pth import WmiPth
from envs.monkey_zoo.blackbox.config_templates.zerologon import Zerologon
from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandConfigParser
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
from envs.monkey_zoo.blackbox.log_handlers.test_logs_handler import TestLogsHandler
from envs.monkey_zoo.blackbox.tests.exploitation import ExploitationTest
from envs.monkey_zoo.blackbox.tests.performance.map_generation import MapGenerationTest

View File

@ -18,12 +18,8 @@ from envs.monkey_zoo.blackbox.config_templates.weblogic import Weblogic
from envs.monkey_zoo.blackbox.config_templates.wmi_mimikatz import WmiMimikatz
from envs.monkey_zoo.blackbox.config_templates.wmi_pth import WmiPth
from envs.monkey_zoo.blackbox.config_templates.zerologon import Zerologon
from envs.monkey_zoo.blackbox.island_client.island_config_parser import (
IslandConfigParser,
)
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import (
MonkeyIslandClient,
)
from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandConfigParser
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
DST_DIR_NAME = "generated_configs"
DST_DIR_PATH = pathlib.Path(pathlib.Path(__file__).parent.absolute(), DST_DIR_NAME)

View File

@ -1,6 +1,7 @@
import json
import logging
import re
import requests
from common.cloud.environment_names import Environment

View File

@ -5,7 +5,6 @@ import requests_mock
from common.cloud.aws.aws_instance import AWS_LATEST_METADATA_URI_PREFIX, AwsInstance
from common.cloud.environment_names import Environment
INSTANCE_ID_RESPONSE = "i-1234567890abcdef0"
AVAILABILITY_ZONE_RESPONSE = "us-west-2b"

View File

@ -6,7 +6,6 @@ import simplejson
from common.cloud.azure.azure_instance import AZURE_METADATA_SERVICE_URL, AzureInstance
from common.cloud.environment_names import Environment
GOOD_DATA = {
"compute": {
"azEnvironment": "AZUREPUBLICCLOUD",

View File

@ -9,12 +9,12 @@ from requests.exceptions import ConnectionError
import infection_monkey.monkeyfs as monkeyfs
import infection_monkey.tunnel as tunnel
from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH
from common.common_consts.timeouts import (
LONG_REQUEST_TIMEOUT,
MEDIUM_REQUEST_TIMEOUT,
SHORT_REQUEST_TIMEOUT,
)
from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH
from infection_monkey.config import GUID, WormConfiguration
from infection_monkey.network.info import check_internet_access, local_ips
from infection_monkey.transport.http import HTTPConnectProxy

View File

@ -11,8 +11,8 @@ import string
import requests
from infection_monkey.exploit.tools.helpers import build_monkey_commandline, get_monkey_depth
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
from infection_monkey.exploit.tools.helpers import build_monkey_commandline, get_monkey_depth
from infection_monkey.exploit.tools.http_tools import HTTPTools
from infection_monkey.exploit.web_rce import WebRCE
from infection_monkey.model import (

View File

@ -3,7 +3,6 @@ import pytest
from infection_monkey.exploit.zerologon import ZerologonExploiter
from infection_monkey.model.host import VictimHost
DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"
NETBIOS_NAME = "NetBIOS Name"

View File

@ -5,7 +5,6 @@ from common.utils.exceptions import DomainControllerNameFetchError
from infection_monkey.exploit.zerologon_utils.vuln_assessment import get_dc_details
from infection_monkey.model.host import VictimHost
DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"

View File

@ -21,7 +21,6 @@ from infection_monkey.exploit.zerologon_utils.vuln_assessment import get_dc_deta
from infection_monkey.exploit.zerologon_utils.wmiexec import Wmiexec
from infection_monkey.utils.capture_output import StdoutCapture
LOG = logging.getLogger(__name__)

View File

@ -7,7 +7,6 @@ import time
from threading import Thread
import infection_monkey.tunnel as tunnel
from infection_monkey.network.tools import is_running_on_island
from common.utils.attack_utils import ScanStatus, UsageEnum
from common.utils.exceptions import ExploitingVulnerableMachineError, FailedExploitationError
from common.version import get_version
@ -18,7 +17,7 @@ from infection_monkey.model import DELAY_DELETE_CMD
from infection_monkey.network.firewall import app as firewall
from infection_monkey.network.HostFinger import HostFinger
from infection_monkey.network.network_scanner import NetworkScanner
from infection_monkey.network.tools import get_interface_to_target
from infection_monkey.network.tools import get_interface_to_target, is_running_on_island
from infection_monkey.post_breach.post_breach_handler import PostBreach
from infection_monkey.system_info import SystemInfoCollector
from infection_monkey.system_singleton import SystemSingleton

View File

@ -1,5 +1,6 @@
from ScoutSuite.output.result_encoder import ScoutJsonEncoder
from ScoutSuite.providers.base.provider import BaseProvider
from common.common_consts.telem_categories import TelemCategoryEnum
from infection_monkey.telemetry.base_telem import BaseTelem

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.attack_telem import AttackTelem
STATUS = ScanStatus.USED
TECHNIQUE = "T9999"

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1005_telem import T1005Telem
GATHERED_DATA_TYPE = "[Type of data collected]"
INFO = "[Additional info]"
STATUS = ScanStatus.USED

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus, UsageEnum
from infection_monkey.telemetry.attack.t1035_telem import T1035Telem
STATUS = ScanStatus.USED
USAGE = UsageEnum.SMB

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1064_telem import T1064Telem
STATUS = ScanStatus.USED
USAGE_STR = "[Usage info]"

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1105_telem import T1105Telem
DST_IP = "0.0.0.1"
FILENAME = "virus.exe"
SRC_IP = "0.0.0.0"

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus, UsageEnum
from infection_monkey.telemetry.attack.t1106_telem import T1106Telem
STATUS = ScanStatus.USED
USAGE = UsageEnum.SMB

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1107_telem import T1107Telem
PATH = "path/to/file.txt"
STATUS = ScanStatus.USED

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus, UsageEnum
from infection_monkey.telemetry.attack.t1129_telem import T1129Telem
STATUS = ScanStatus.USED
USAGE = UsageEnum.SMB

View File

@ -6,7 +6,6 @@ from common.utils.attack_utils import ScanStatus
from infection_monkey.model import VictimHost
from infection_monkey.telemetry.attack.t1197_telem import T1197Telem
DOMAIN_NAME = "domain-name"
IP = "127.0.0.1"
MACHINE = VictimHost(IP, DOMAIN_NAME)

View File

@ -6,7 +6,6 @@ from common.utils.attack_utils import ScanStatus
from infection_monkey.model import VictimHost
from infection_monkey.telemetry.attack.t1222_telem import T1222Telem
COMMAND = "echo hi"
DOMAIN_NAME = "domain-name"
IP = "127.0.0.1"

View File

@ -5,7 +5,6 @@ import pytest
from common.utils.attack_utils import ScanStatus, UsageEnum
from infection_monkey.telemetry.attack.usage_telem import UsageTelem
STATUS = ScanStatus.USED
TECHNIQUE = "T9999"
USAGE = UsageEnum.SMB

View File

@ -6,7 +6,6 @@ from common.utils.attack_utils import ScanStatus
from infection_monkey.model import VictimHost
from infection_monkey.telemetry.attack.victim_host_telem import VictimHostTelem
DOMAIN_NAME = "domain-name"
IP = "127.0.0.1"
MACHINE = VictimHost(IP, DOMAIN_NAME)

View File

@ -6,7 +6,6 @@ from infection_monkey.exploit.wmiexec import WmiExploiter
from infection_monkey.model.host import VictimHost
from infection_monkey.telemetry.exploit_telem import ExploitTelem
DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"
HOST = VictimHost(IP, DOMAIN_NAME)

View File

@ -4,7 +4,6 @@ import pytest
from infection_monkey.telemetry.post_breach_telem import PostBreachTelem
HOSTNAME = "hostname"
IP = "0.0.0.0"
PBA_COMMAND = "run some pba"

View File

@ -2,9 +2,8 @@ import json
import pytest
from infection_monkey.telemetry.scan_telem import ScanTelem
from infection_monkey.model.host import VictimHost
from infection_monkey.telemetry.scan_telem import ScanTelem
DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"

View File

@ -4,7 +4,6 @@ import pytest
from infection_monkey.telemetry.state_telem import StateTelem
IS_DONE = True
VERSION = "version"

View File

@ -4,7 +4,6 @@ import pytest
from infection_monkey.telemetry.system_info_telem import SystemInfoTelem
SYSTEM_INFO = {}

View File

@ -4,7 +4,6 @@ import pytest
from infection_monkey.telemetry.trace_telem import TraceTelem
MSG = "message"

View File

@ -8,7 +8,6 @@ import json # noqa: E402
from monkey_island.cc.server_utils.island_logger import json_setup_logging # noqa: E402
if "__main__" == __name__:
island_args = parse_cli_args()

View File

@ -7,10 +7,6 @@ from werkzeug.exceptions import NotFound
import monkey_island.cc.environment.environment_singleton as env_singleton
from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH
from monkey_island.cc.resources.test.telemetry_test import TelemetryTest
from monkey_island.cc.resources.zero_trust.zero_trust_report import ZeroTrustReport
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.server_utils.custom_json_encoder import CustomJSONEncoder
from monkey_island.cc.database import database, mongo
from monkey_island.cc.resources.attack.attack_config import AttackConfiguration
from monkey_island.cc.resources.attack.attack_report import AttackReport
@ -35,18 +31,22 @@ from monkey_island.cc.resources.node_states import NodeStates
from monkey_island.cc.resources.pba_file_download import PBAFileDownload
from monkey_island.cc.resources.pba_file_upload import FileUpload
from monkey_island.cc.resources.remote_run import RemoteRun
from monkey_island.cc.resources.security_report import SecurityReport
from monkey_island.cc.resources.root import Root
from monkey_island.cc.resources.security_report import SecurityReport
from monkey_island.cc.resources.T1216_pba_file_download import T1216PBAFileDownload
from monkey_island.cc.resources.telemetry import Telemetry
from monkey_island.cc.resources.telemetry_feed import TelemetryFeed
from monkey_island.cc.resources.test.clear_caches import ClearCaches
from monkey_island.cc.resources.test.log_test import LogTest
from monkey_island.cc.resources.test.monkey_test import MonkeyTest
from monkey_island.cc.resources.test.telemetry_test import TelemetryTest
from monkey_island.cc.resources.version_update import VersionUpdate
from monkey_island.cc.resources.zero_trust.finding_event import ZeroTrustFindingEvent
from monkey_island.cc.resources.zero_trust.scoutsuite_auth.aws_keys import AWSKeys
from monkey_island.cc.resources.zero_trust.scoutsuite_auth.scoutsuite_auth import ScoutSuiteAuth
from monkey_island.cc.resources.zero_trust.zero_trust_report import ZeroTrustReport
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.server_utils.custom_json_encoder import CustomJSONEncoder
from monkey_island.cc.services.database import Database
from monkey_island.cc.services.remote_run_aws import RemoteRunAwsService
from monkey_island.cc.services.representations import output_json

View File

@ -1,8 +1,8 @@
from dataclasses import dataclass
from monkey_island.cc.server_utils.consts import (
DEFAULT_SERVER_CONFIG_PATH,
DEFAULT_LOGGER_CONFIG_PATH,
DEFAULT_SERVER_CONFIG_PATH,
)

View File

@ -6,10 +6,10 @@ from pathlib import Path
from typing import Dict, List
import monkey_island.cc.environment.server_config_generator as server_config_generator
from monkey_island.cc.server_utils.consts import DEFAULT_DATA_DIR
from monkey_island.cc.environment.user_creds import UserCreds
from monkey_island.cc.resources.auth.auth_user import User
from monkey_island.cc.resources.auth.user_store import UserStore
from monkey_island.cc.server_utils.consts import DEFAULT_DATA_DIR
class EnvironmentConfig:

View File

@ -4,7 +4,6 @@ from typing import Dict
from unittest import TestCase
from unittest.mock import MagicMock, patch
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
from common.utils.exceptions import (
AlreadyRegisteredError,
CredentialsNotRequiredError,
@ -12,6 +11,7 @@ from common.utils.exceptions import (
RegistrationNotNeededError,
)
from monkey_island.cc.environment import Environment, EnvironmentConfig, UserCreds
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
TEST_RESOURCES_DIR = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "testing", "environment")

View File

@ -4,10 +4,9 @@ import shutil
import pytest
from monkey_island.cc.server_utils.consts import DEFAULT_DATA_DIR, MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.environment.environment_config import EnvironmentConfig
from monkey_island.cc.environment.user_creds import UserCreds
from monkey_island.cc.server_utils.consts import DEFAULT_DATA_DIR, MONKEY_ISLAND_ABS_PATH
TEST_RESOURCES_DIR = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "testing", "environment")

View File

@ -17,16 +17,16 @@ from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH # noqa:
logger = logging.getLogger(__name__)
import monkey_island.cc.environment.environment_singleton as env_singleton # noqa: E402
from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH # noqa: E402
from common.version import get_version # noqa: E402
from monkey_island.cc.app import init_app # noqa: E402
from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402
from monkey_island.cc.database import get_db_version # noqa: E402
from monkey_island.cc.database import is_db_server_up # noqa: E402
from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402
from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402
from monkey_island.cc.resources.monkey_download import MonkeyDownload # noqa: E402
from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402
from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH # noqa: E402
from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402
from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402
from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402
from monkey_island.cc.setup import setup # noqa: E402
MINIMUM_MONGO_DB_VERSION_REQUIRED = "4.2.0"

View File

@ -15,9 +15,9 @@ from mongoengine import (
)
from common.cloud import environment_names
from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS
from monkey_island.cc.models.command_control_channel import CommandControlChannel
from monkey_island.cc.models.monkey_ttl import MonkeyTtl, create_monkey_ttl_document
from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
MAX_MONKEYS_AMOUNT_TO_CACHE = 100

View File

@ -6,8 +6,8 @@ import pytest
from monkey_island.cc.models.monkey import Monkey, MonkeyNotFoundError
from .monkey_ttl import MonkeyTtl
from ..test_common.fixtures import FixtureEnum
from .monkey_ttl import MonkeyTtl
logger = logging.getLogger(__name__)

View File

@ -8,12 +8,12 @@ import flask_restful
from flask import jsonify, make_response, request
import monkey_island.cc.environment.environment_singleton as env_singleton
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.models import Monkey
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
from monkey_island.cc.resources.auth.auth import jwt_required
from monkey_island.cc.resources.monkey_download import get_monkey_executable
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.services.node import NodeService
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
__author__ = "Barak"

View File

@ -5,10 +5,10 @@ import dateutil.parser
import flask_restful
from flask import request
from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS
from monkey_island.cc.database import mongo
from monkey_island.cc.models.monkey_ttl import create_monkey_ttl_document
from monkey_island.cc.resources.test.utils.telem_store import TestTelemStore
from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS
from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.edge.edge import EdgeService
from monkey_island.cc.services.node import NodeService

View File

@ -5,10 +5,10 @@ import flask_restful
from flask import jsonify, make_response, request
from monkey_island.cc.database import mongo
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
from monkey_island.cc.resources.auth.auth import jwt_required
from monkey_island.cc.services.database import Database
from monkey_island.cc.services.infection_lifecycle import InfectionLifecycle
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
__author__ = "Barak"

View File

@ -9,8 +9,8 @@ import monkey_island.cc.environment.environment_singleton as env_singleton
import monkey_island.cc.services.post_breach_files
from monkey_island.cc.database import mongo
from monkey_island.cc.server_utils.encryptor import get_encryptor
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
from monkey_island.cc.services.config_schema.config_schema import SCHEMA
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
__author__ = "itay.mizeretz"

View File

@ -1,5 +1,5 @@
from monkey_island.cc.services.config import ConfigService
from common.config_value_paths import INACCESSIBLE_SUBNETS_PATH
from monkey_island.cc.services.config import ConfigService
def get_config_network_segments_as_subnet_groups():

View File

@ -8,9 +8,9 @@ import monkey_island.cc.services.log
from monkey_island.cc import models
from monkey_island.cc.database import mongo
from monkey_island.cc.models import Monkey
from monkey_island.cc.services.utils.network_utils import is_local_ips, local_ip_addresses
from monkey_island.cc.services.edge.displayed_edge import DisplayedEdgeService
from monkey_island.cc.services.edge.edge import EdgeService
from monkey_island.cc.services.utils.network_utils import is_local_ips, local_ip_addresses
from monkey_island.cc.services.utils.node_states import NodeStates
__author__ = "itay.mizeretz"

View File

@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Type, Dict
from typing import Type
from monkey_island.cc.services.reporting.issue_processing.exploit_processing.processors.cred_exploit import (
CredExploitProcessor,

View File

@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Union, List
from typing import List, Union
class CredentialType(Enum):

View File

@ -1,6 +1,6 @@
from monkey_island.cc.services.reporting.issue_processing.exploit_processing.exploiter_report_info import (
ExploiterReportInfo,
CredentialType,
ExploiterReportInfo,
)
from monkey_island.cc.services.reporting.issue_processing.exploit_processing.processors.exploit import (
ExploitProcessor,

View File

@ -1,6 +1,6 @@
from monkey_island.cc.services.reporting.issue_processing.exploit_processing.processors.exploit import (
ExploitProcessor,
ExploiterReportInfo,
ExploitProcessor,
)

View File

@ -6,12 +6,6 @@ from typing import List
from bson import json_util
from common.network.network_range import NetworkRange
from common.network.segmentation_utils import get_ip_in_src_and_not_in_dst
from monkey_island.cc.database import mongo
from monkey_island.cc.models import Monkey
from monkey_island.cc.services.utils.network_utils import get_subnets, local_ip_addresses
from monkey_island.cc.services.config import ConfigService
from common.config_value_paths import (
EXPLOITER_CLASSES_PATH,
LOCAL_NETWORK_SCAN_PATH,
@ -19,6 +13,11 @@ from common.config_value_paths import (
SUBNET_SCAN_LIST_PATH,
USER_LIST_PATH,
)
from common.network.network_range import NetworkRange
from common.network.segmentation_utils import get_ip_in_src_and_not_in_dst
from monkey_island.cc.database import mongo
from monkey_island.cc.models import Monkey
from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.configuration.utils import (
get_config_network_segments_as_subnet_groups,
)
@ -37,6 +36,7 @@ from monkey_island.cc.services.reporting.report_exporter_manager import ReportEx
from monkey_island.cc.services.reporting.report_generation_synchronisation import (
safe_generate_regular_report,
)
from monkey_island.cc.services.utils.network_utils import get_subnets, local_ip_addresses
__author__ = "itay.mizeretz"

View File

@ -2,8 +2,8 @@ import copy
import dateutil
from monkey_island.cc.server_utils.encryptor import get_encryptor
from monkey_island.cc.models import Monkey
from monkey_island.cc.server_utils.encryptor import get_encryptor
from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.edge.displayed_edge import EdgeService
from monkey_island.cc.services.node import NodeService

View File

@ -5,7 +5,6 @@ from bson import ObjectId
from common.utils.exceptions import FindingWithoutDetailsError
from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails
# How many events of a single finding to return to UI.
# 100 will return 50 latest and 50 oldest events from a finding
MAX_EVENT_FETCH_CNT = 100

View File

@ -1,11 +1,11 @@
from monkey_island.cc.services.zero_trust.scoutsuite.consts.scoutsuite_finding_maps import (
DataLossPrevention,
Logging,
PermissiveFirewallRules,
RestrictivePolicies,
SecureAuthentication,
DataLossPrevention,
UnencryptedData,
PermissiveFirewallRules,
ServiceSecurity,
Logging,
UnencryptedData,
)
SCOUTSUITE_FINDINGS = [

View File

@ -3,10 +3,10 @@ from typing import Tuple
from ScoutSuite.providers.base.authentication_strategy import AuthenticationException
from common.cloud.scoutsuite_consts import CloudProviders
from common.config_value_paths import AWS_KEYS_PATH
from common.utils.exceptions import InvalidAWSKeys
from monkey_island.cc.server_utils.encryptor import get_encryptor
from monkey_island.cc.services.config import ConfigService
from common.config_value_paths import AWS_KEYS_PATH
def is_cloud_authentication_setup(provider: CloudProviders) -> Tuple[bool, str]:

View File

@ -1,12 +1,12 @@
from unittest.mock import MagicMock
import pytest
import dpath.util
import pytest
from monkey_island.cc.database import mongo
from monkey_island.cc.server_utils.encryptor import initialize_encryptor, get_encryptor
from monkey_island.cc.services.config import ConfigService
from common.config_value_paths import AWS_KEYS_PATH
from monkey_island.cc.database import mongo
from monkey_island.cc.server_utils.encryptor import get_encryptor, initialize_encryptor
from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_auth_service import (
is_aws_keys_setup,
)

View File

@ -1,8 +1,8 @@
from copy import deepcopy
from monkey_island.cc.services.zero_trust.scoutsuite.consts.rule_consts import (
RULE_LEVEL_WARNING,
RULE_LEVEL_DANGER,
RULE_LEVEL_WARNING,
)
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_rule_service import (
ScoutSuiteRuleService,

View File

@ -1,8 +1,8 @@
from common.common_consts.zero_trust_consts import (
TEST_SCOUTSUITE_SERVICE_SECURITY,
STATUS_FAILED,
TEST_ENDPOINT_SECURITY_EXISTS,
STATUS_PASSED,
TEST_ENDPOINT_SECURITY_EXISTS,
TEST_SCOUTSUITE_SERVICE_SECURITY,
)
from monkey_island.cc.models.zero_trust.finding import Finding
from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding

View File

@ -3,24 +3,24 @@ from unittest.mock import MagicMock
import pytest
from common.common_consts.zero_trust_consts import (
TESTS_MAP,
TEST_SCOUTSUITE_SERVICE_SECURITY,
STATUS_FAILED,
DEVICES,
NETWORKS,
STATUS_FAILED,
STATUS_PASSED,
TEST_ENDPOINT_SECURITY_EXISTS,
TEST_SCOUTSUITE_SERVICE_SECURITY,
TESTS_MAP,
)
from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_details_service import (
MonkeyZTDetailsService,
)
from monkey_island.cc.services.zero_trust.test_common.finding_data import (
get_scoutsuite_finding_dto,
get_monkey_finding_dto,
get_scoutsuite_finding_dto,
)
from monkey_island.cc.services.zero_trust.zero_trust_report.finding_service import (
FindingService,
EnrichedFinding,
FindingService,
)
from monkey_island.cc.test_common.fixtures.fixture_enum import FixtureEnum

View File

@ -4,13 +4,13 @@ import pytest
from common.common_consts import zero_trust_consts
from common.common_consts.zero_trust_consts import (
DATA,
PEOPLE,
NETWORKS,
WORKLOADS,
VISIBILITY_ANALYTICS,
AUTOMATION_ORCHESTRATION,
DATA,
DEVICES,
NETWORKS,
PEOPLE,
VISIBILITY_ANALYTICS,
WORKLOADS,
)
from monkey_island.cc.services.zero_trust.zero_trust_report.pillar_service import PillarService
from monkey_island.cc.services.zero_trust.zero_trust_report.test_common.example_finding_data import (

View File

@ -10,7 +10,6 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.principle_service im
)
from monkey_island.cc.test_common.fixtures import FixtureEnum
EXPECTED_DICT = {
"test_pillar1": [
{

View File

@ -1,4 +1,5 @@
import platform
import monkey_island.cc.server_utils.consts as consts

View File

@ -1,8 +1,7 @@
import os
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.server_utils.encryptor import initialize_encryptor, get_encryptor
from monkey_island.cc.server_utils.encryptor import get_encryptor, initialize_encryptor
TEST_DATA_DIR = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "testing")
PASSWORD_FILENAME = "mongo_key.bin"

View File

@ -1,3 +1,14 @@
[tool.black]
line-length = 100
target-version = ['py37']
[tool.isort]
skip = "monkey/monkey_island/cc/ui"
known_first_party = "common,infection_monkey,monkey_island"
line_length = 100
### for compatibility with black
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true