forked from p15670423/monkey
Cleaned up imports and added no inspection comments to pass flake
This commit is contained in:
parent
414dbf0665
commit
a977ec4397
|
@ -1 +1,3 @@
|
||||||
from monkey_island.cc.test_common.fixtures import *
|
# Without these imports pytests can't use fixtures,
|
||||||
|
# because they are not found
|
||||||
|
from monkey_island.cc.test_common.fixtures import * # noqa: F401,F403
|
||||||
|
|
|
@ -8,9 +8,6 @@ from __future__ import annotations
|
||||||
from mongoengine import Document, StringField
|
from mongoengine import Document, StringField
|
||||||
|
|
||||||
import common.common_consts.zero_trust_consts as zero_trust_consts
|
import common.common_consts.zero_trust_consts as zero_trust_consts
|
||||||
# Dummy import for mongoengine.
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails
|
|
||||||
|
|
||||||
|
|
||||||
class Finding(Document):
|
class Finding(Document):
|
||||||
|
|
|
@ -46,7 +46,8 @@ class Authenticate(flask_restful.Resource):
|
||||||
secret = credentials["password"]
|
secret = credentials["password"]
|
||||||
# If the user and password have been previously registered
|
# If the user and password have been previously registered
|
||||||
if self._authenticate(username, secret):
|
if self._authenticate(username, secret):
|
||||||
access_token = flask_jwt_extended.create_access_token(identity=user_store.UserStore.username_table[username].id)
|
access_token = flask_jwt_extended.create_access_token(
|
||||||
|
identity=user_store.UserStore.username_table[username].id)
|
||||||
logger.debug(f"Created access token for user {username} that begins with {access_token[:4]}")
|
logger.debug(f"Created access token for user {username} that begins with {access_token[:4]}")
|
||||||
return make_response({"access_token": access_token, "error": ""}, 200)
|
return make_response({"access_token": access_token, "error": ""}, 200)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -12,9 +12,9 @@ def check_new_user_communication(current_monkey, success, message):
|
||||||
MonkeyZTFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_COMMUNICATE_AS_NEW_USER,
|
MonkeyZTFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_COMMUNICATE_AS_NEW_USER,
|
||||||
status=status,
|
status=status,
|
||||||
events=[
|
events=[
|
||||||
get_attempt_event(current_monkey),
|
get_attempt_event(current_monkey),
|
||||||
get_result_event(current_monkey, message, success)
|
get_result_event(current_monkey, message, success)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
def get_attempt_event(current_monkey):
|
def get_attempt_event(current_monkey):
|
||||||
|
|
|
@ -11,6 +11,7 @@ from monkey_island.cc.services.zero_trust.test_common.raw_scoutsute_data import
|
||||||
class ExampleRules(Enum):
|
class ExampleRules(Enum):
|
||||||
NON_EXSISTENT_RULE = 'bogus_rule'
|
NON_EXSISTENT_RULE = 'bogus_rule'
|
||||||
|
|
||||||
|
|
||||||
ALL_PORTS_OPEN = EC2Rules.SECURITY_GROUP_ALL_PORTS_TO_ALL
|
ALL_PORTS_OPEN = EC2Rules.SECURITY_GROUP_ALL_PORTS_TO_ALL
|
||||||
|
|
||||||
EXPECTED_RESULT = {'description': 'Security Group Opens All Ports to All',
|
EXPECTED_RESULT = {'description': 'Security Group Opens All Ports to All',
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from common.common_consts import zero_trust_consts
|
|
||||||
from monkey_island.cc.models.zero_trust.finding import Finding
|
from monkey_island.cc.models.zero_trust.finding import Finding
|
||||||
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
|
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
|
||||||
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_zt_finding_service import ScoutSuiteZTFindingService
|
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_zt_finding_service import ScoutSuiteZTFindingService
|
||||||
|
|
|
@ -73,5 +73,3 @@ def get_scoutsuite_details_dto() -> ScoutSuiteFindingDetails:
|
||||||
scoutsuite_details.scoutsuite_rules.append(RULES[0])
|
scoutsuite_details.scoutsuite_rules.append(RULES[0])
|
||||||
scoutsuite_details.scoutsuite_rules.append(RULES[1])
|
scoutsuite_details.scoutsuite_rules.append(RULES[1])
|
||||||
return scoutsuite_details
|
return scoutsuite_details
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,3 @@ def test_get_all_findings():
|
||||||
|
|
||||||
assert findings[0] == expected_finding0
|
assert findings[0] == expected_finding0
|
||||||
assert findings[1] == expected_finding1
|
assert findings[1] == expected_finding1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
from .fixture_enum import FixtureEnum
|
# Without these imports pytests can't use fixtures,
|
||||||
from .mongomock_fixtures import *
|
# because they are not found
|
||||||
|
from .fixture_enum import FixtureEnum # noqa: F401
|
||||||
|
from .mongomock_fixtures import * # noqa: F401,F403
|
||||||
|
|
|
@ -1,4 +1,2 @@
|
||||||
|
|
||||||
|
|
||||||
class FixtureEnum:
|
class FixtureEnum:
|
||||||
USES_DATABASE = 'uses_database'
|
USES_DATABASE = 'uses_database'
|
||||||
|
|
Loading…
Reference in New Issue