Fixed python linting warnings

This commit is contained in:
VakarisZ 2020-10-05 15:16:35 +03:00
parent d5f224f9f9
commit b88cb8bf3c
9 changed files with 37 additions and 39 deletions

View File

@ -11,7 +11,7 @@ class TestNetworkUtils(TestCase):
assert get_host_from_network_location("127.0.0.1") == "127.0.0.1" assert get_host_from_network_location("127.0.0.1") == "127.0.0.1"
assert get_host_from_network_location("www.google.com:8080") == "www.google.com" assert get_host_from_network_location("www.google.com:8080") == "www.google.com"
assert get_host_from_network_location("user:password@host:8080") == "host" assert get_host_from_network_location("user:password@host:8080") == "host"
def test_remove_port_from_url(self): def test_remove_port_from_url(self):
assert remove_port('https://google.com:80') == 'https://google.com' assert remove_port('https://google.com:80') == 'https://google.com'
assert remove_port('https://8.8.8.8:65336') == 'https://8.8.8.8' assert remove_port('https://8.8.8.8:65336') == 'https://8.8.8.8'

View File

@ -1,5 +1,4 @@
import hashlib import hashlib
import json
import os import os
import sys import sys
import uuid import uuid

View File

@ -191,8 +191,8 @@ class InfectionMonkey(object):
if self._default_server: if self._default_server:
if self._network.on_island(self._default_server): if self._network.on_island(self._default_server):
machine.set_default_server(get_interface_to_target(machine.ip_addr) + machine.set_default_server(get_interface_to_target(machine.ip_addr) +
( (':' + self._default_server_port
':' + self._default_server_port if self._default_server_port else '')) if self._default_server_port else ''))
else: else:
machine.set_default_server(self._default_server) machine.set_default_server(self._default_server)
LOG.debug("Default server for machine: %r set to %s" % (machine, machine.default_server)) LOG.debug("Default server for machine: %r set to %s" % (machine, machine.default_server))

View File

@ -5,7 +5,7 @@ import logging
from infection_monkey.control import ControlClient from infection_monkey.control import ControlClient
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
LOGGED_DATA_LENGTH = 300 # How many characters of telemetry data will be logged LOGGED_DATA_LENGTH = 300 # How many characters of telemetry data will be logged
__author__ = 'itay.mizeretz' __author__ = 'itay.mizeretz'

View File

@ -46,7 +46,7 @@ def run_local_monkey():
args = ['"%s" m0nk3y -s %s:%s' % (target_path, local_ip_addresses()[0], env_singleton.env.get_island_port())] args = ['"%s" m0nk3y -s %s:%s' % (target_path, local_ip_addresses()[0], env_singleton.env.get_island_port())]
if sys.platform == "win32": if sys.platform == "win32":
args = "".join(args) args = "".join(args)
pid = subprocess.Popen(args, shell=True).pid subprocess.Popen(args, shell=True).pid
except Exception as exc: except Exception as exc:
logger.error('popen failed', exc_info=True) logger.error('popen failed', exc_info=True)
return False, "popen failed: %s" % exc return False, "popen failed: %s" % exc

View File

@ -1,6 +1,5 @@
from monkey_island.cc.database import mongo from monkey_island.cc.database import mongo
from monkey_island.cc.models import Monkey from monkey_island.cc.models import Monkey
from monkey_island.cc.services.edge.edge import EdgeService
from monkey_island.cc.services.node import NodeService from monkey_island.cc.services.node import NodeService
from monkey_island.cc.services.telemetry.processing.utils import \ from monkey_island.cc.services.telemetry.processing.utils import \
get_edge_by_scan_or_exploit_telemetry get_edge_by_scan_or_exploit_telemetry

View File

@ -1,4 +1,5 @@
from monkey_island.cc.services.zero_trust.scoutsuite.consts.findings import * from monkey_island.cc.services.zero_trust.scoutsuite.consts.findings import PERMISSIVE_FIREWALL_RULES, \
UNENCRYPTED_DATA, DATA_LOSS_PREVENTION, SECURE_AUTHENTICATION, RESTRICTIVE_POLICIES, LOGGING, SERVICE_SECURITY
SCOUTSUITE_FINDINGS = [PERMISSIVE_FIREWALL_RULES, UNENCRYPTED_DATA, DATA_LOSS_PREVENTION, SECURE_AUTHENTICATION, SCOUTSUITE_FINDINGS = [PERMISSIVE_FIREWALL_RULES, UNENCRYPTED_DATA, DATA_LOSS_PREVENTION, SECURE_AUTHENTICATION,
RESTRICTIVE_POLICIES, LOGGING, SERVICE_SECURITY] RESTRICTIVE_POLICIES, LOGGING, SERVICE_SECURITY]

View File

@ -30,4 +30,3 @@ class SERVICE_TYPES(Enum):
SQS = 'sqs' SQS = 'sqs'
VPC = 'vpc' VPC = 'vpc'
SECRETSMANAGER = 'secretsmanager' SECRETSMANAGER = 'secretsmanager'

View File

@ -1,33 +1,33 @@
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.cloudformation_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building. \
CloudformationRulePathCreator rule_path_creators.cloudformation_rule_path_creator import CloudformationRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.cloudtrail_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
CloudTrailRulePathCreator rule_path_creators.cloudtrail_rule_path_creator import CloudTrailRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.cloudwatch_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
CloudWatchRulePathCreator rule_path_creators.cloudwatch_rule_path_creator import CloudWatchRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.config_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
ConfigRulePathCreator rule_path_creators.config_rule_path_creator import ConfigRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.ec2_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
EC2RulePathCreator rule_path_creators.ec2_rule_path_creator import EC2RulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.elb_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
ELBRulePathCreator rule_path_creators.elb_rule_path_creator import ELBRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.elbv2_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
ELBv2RulePathCreator rule_path_creators.elbv2_rule_path_creator import ELBv2RulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.iam_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
IAMRulePathCreator rule_path_creators.iam_rule_path_creator import IAMRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.rds_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
RDSRulePathCreator rule_path_creators.rds_rule_path_creator import RDSRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.redshift_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
RedshiftRulePathCreator rule_path_creators.redshift_rule_path_creator import RedshiftRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.s3_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
S3RulePathCreator rule_path_creators.s3_rule_path_creator import S3RulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.ses_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
SESRulePathCreator rule_path_creators.ses_rule_path_creator import SESRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.sns_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
SNSRulePathCreator rule_path_creators.sns_rule_path_creator import SNSRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.sqs_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
SQSRulePathCreator rule_path_creators.sqs_rule_path_creator import SQSRulePathCreator
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators.vpc_rule_path_creator import \ from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.\
VPCRulePathCreator rule_path_creators.vpc_rule_path_creator import VPCRulePathCreator
RULE_PATH_CREATORS_LIST = [EC2RulePathCreator, ELBv2RulePathCreator, RDSRulePathCreator, RedshiftRulePathCreator, RULE_PATH_CREATORS_LIST = [EC2RulePathCreator, ELBv2RulePathCreator, RDSRulePathCreator, RedshiftRulePathCreator,
S3RulePathCreator, IAMRulePathCreator, CloudTrailRulePathCreator, ELBRulePathCreator, S3RulePathCreator, IAMRulePathCreator, CloudTrailRulePathCreator, ELBRulePathCreator,