Merge pull request #1190 from guardicore/vulture-skip-unit-tests

Configure Vulture to skip tests/unit_tests/
This commit is contained in:
VakarisZ 2021-06-03 09:35:22 +03:00 committed by GitHub
commit e6bb48100e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 69 additions and 48 deletions

View File

@ -1,7 +1,7 @@
[flake8] [flake8]
## Warn about linter issues. ## Warn about linter issues.
exclude = monkey/monkey_island/cc/ui,whitelist.py 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

View File

@ -1,5 +0,0 @@
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester # noqa: F401
class SomeDummyPlugin:
pass

View File

@ -1,5 +0,0 @@
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
class PluginWorking(PluginTester):
pass

View File

@ -0,0 +1,7 @@
from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.PluginTestClass import ( # noqa: F401, E501
PluginTester,
)
class SomeDummyPlugin:
pass

View File

@ -1,4 +1,4 @@
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
class BadPluginInit(PluginTester): class BadPluginInit(PluginTester):

View File

@ -1,4 +1,4 @@
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
class BadInit(PluginTester): class BadInit(PluginTester):

View File

@ -1,4 +1,5 @@
import infection_monkey.utils.plugins.pluginTests import tests.unit_tests.infection_monkey.utils.plugins.pluginTests
from infection_monkey.utils.plugins.plugin import Plugin from infection_monkey.utils.plugins.plugin import Plugin
@ -15,8 +16,8 @@ class PluginTester(Plugin):
@staticmethod @staticmethod
def base_package_file(): def base_package_file():
return infection_monkey.utils.plugins.pluginTests.__file__ return tests.unit_tests.infection_monkey.utils.plugins.pluginTests.__file__
@staticmethod @staticmethod
def base_package_name(): def base_package_name():
return infection_monkey.utils.plugins.pluginTests.__package__ return tests.unit_tests.infection_monkey.utils.plugins.pluginTests.__package__

View File

@ -0,0 +1,5 @@
from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
class PluginWorking(PluginTester):
pass

View File

@ -1,10 +1,13 @@
from unittest import TestCase from unittest import TestCase
from infection_monkey.utils.plugins.pluginTests.BadImport import SomeDummyPlugin from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.BadImport import SomeDummyPlugin
from infection_monkey.utils.plugins.pluginTests.BadInit import BadPluginInit from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.BadInit import BadPluginInit
from infection_monkey.utils.plugins.pluginTests.ComboFile import BadInit, ProperClass from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.ComboFile import (
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester BadInit,
from infection_monkey.utils.plugins.pluginTests.PluginWorking import PluginWorking ProperClass,
)
from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
from tests.unit_tests.infection_monkey.utils.plugins.pluginTests.PluginWorking import PluginWorking
class TestPlugin(TestCase): class TestPlugin(TestCase):

View File

@ -1,12 +1,14 @@
import pytest import pytest
from mongoengine import ValidationError from mongoengine import ValidationError
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import ( # noqa: E501
RULES,
)
import common.common_consts.zero_trust_consts as zero_trust_consts import common.common_consts.zero_trust_consts as 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.monkey_finding_details import MonkeyFindingDetails from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails
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.models.zero_trust.scoutsuite_finding_details import ScoutSuiteFindingDetails from monkey_island.cc.models.zero_trust.scoutsuite_finding_details import ScoutSuiteFindingDetails
from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import RULES
MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails() MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails()
MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"] MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"]

View File

@ -1,12 +1,14 @@
from enum import Enum from enum import Enum
import pytest import pytest
from tests.unit_tests.monkey_island.cc.services.zero_trust.raw_scoutsute_data import (
RAW_SCOUTSUITE_DATA,
)
from common.utils.exceptions import RulePathCreatorNotFound from common.utils.exceptions import RulePathCreatorNotFound
from monkey_island.cc.services.zero_trust.scoutsuite.consts.rule_names.ec2_rules import EC2Rules from monkey_island.cc.services.zero_trust.scoutsuite.consts.rule_names.ec2_rules import EC2Rules
from monkey_island.cc.services.zero_trust.scoutsuite.consts.service_consts import SERVICES from monkey_island.cc.services.zero_trust.scoutsuite.consts.service_consts import SERVICES
from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_parser import RuleParser from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_parser import RuleParser
from monkey_island.cc.services.zero_trust.test_common.raw_scoutsute_data import RAW_SCOUTSUITE_DATA
class ExampleRules(Enum): class ExampleRules(Enum):

View File

@ -1,5 +1,9 @@
from copy import deepcopy from copy import deepcopy
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import ( # noqa: E501
RULES,
)
from monkey_island.cc.services.zero_trust.scoutsuite.consts.rule_consts import ( from monkey_island.cc.services.zero_trust.scoutsuite.consts.rule_consts import (
RULE_LEVEL_DANGER, RULE_LEVEL_DANGER,
RULE_LEVEL_WARNING, RULE_LEVEL_WARNING,
@ -7,7 +11,6 @@ from monkey_island.cc.services.zero_trust.scoutsuite.consts.rule_consts import (
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_rule_service import ( from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_rule_service import (
ScoutSuiteRuleService, ScoutSuiteRuleService,
) )
from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import RULES
example_scoutsuite_data = { example_scoutsuite_data = {
"checked_items": 179, "checked_items": 179,

View File

@ -1,14 +1,14 @@
import pytest import pytest
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import ( # noqa: E501
RULES,
SCOUTSUITE_FINDINGS,
)
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 ( from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_zt_finding_service import (
ScoutSuiteZTFindingService, ScoutSuiteZTFindingService,
) )
from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import (
RULES,
SCOUTSUITE_FINDINGS,
)
class TestScoutSuiteZTFindingService: class TestScoutSuiteZTFindingService:

View File

@ -1,9 +1,10 @@
from common.common_consts import zero_trust_consts from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.finding_data import (
from monkey_island.cc.services.zero_trust.test_common.finding_data import (
get_monkey_finding_dto, get_monkey_finding_dto,
get_scoutsuite_finding_dto, get_scoutsuite_finding_dto,
) )
from common.common_consts import zero_trust_consts
def save_example_findings(): def save_example_findings():
# devices passed = 1 # devices passed = 1

View File

@ -1,3 +1,10 @@
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.monkey_finding_data import (
get_monkey_details_dto,
)
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import ( # noqa: E501
get_scoutsuite_details_dto,
)
from common.common_consts.zero_trust_consts import ( from common.common_consts.zero_trust_consts import (
STATUS_FAILED, STATUS_FAILED,
STATUS_PASSED, STATUS_PASSED,
@ -7,12 +14,6 @@ from common.common_consts.zero_trust_consts import (
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.monkey_finding import MonkeyFinding from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding
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.test_common.monkey_finding_data import (
get_monkey_details_dto,
)
from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import (
get_scoutsuite_details_dto,
)
def get_scoutsuite_finding_dto() -> Finding: def get_scoutsuite_finding_dto() -> Finding:

View File

@ -1,6 +1,10 @@
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest import pytest
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.finding_data import (
get_monkey_finding_dto,
get_scoutsuite_finding_dto,
)
from common.common_consts.zero_trust_consts import ( from common.common_consts.zero_trust_consts import (
DEVICES, DEVICES,
@ -14,10 +18,6 @@ from common.common_consts.zero_trust_consts import (
from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_details_service import ( from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_details_service import (
MonkeyZTDetailsService, MonkeyZTDetailsService,
) )
from monkey_island.cc.services.zero_trust.test_common.finding_data import (
get_monkey_finding_dto,
get_scoutsuite_finding_dto,
)
from monkey_island.cc.services.zero_trust.zero_trust_report.finding_service import ( from monkey_island.cc.services.zero_trust.zero_trust_report.finding_service import (
EnrichedFinding, EnrichedFinding,
FindingService, FindingService,

View File

@ -1,6 +1,9 @@
from typing import List from typing import List
import pytest import pytest
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.example_finding_data import ( # noqa: E501
save_example_findings,
)
from common.common_consts import zero_trust_consts from common.common_consts import zero_trust_consts
from common.common_consts.zero_trust_consts import ( from common.common_consts.zero_trust_consts import (
@ -13,9 +16,6 @@ from common.common_consts.zero_trust_consts import (
WORKLOADS, 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.pillar_service import PillarService
from monkey_island.cc.services.zero_trust.zero_trust_report.test_common.example_finding_data import ( # noqa: E501
save_example_findings,
)
@pytest.mark.usefixtures("uses_database") @pytest.mark.usefixtures("uses_database")

View File

@ -1,10 +1,10 @@
import pytest import pytest
from tests.unit_tests.monkey_island.cc.services.zero_trust.test_common.finding_data import (
from common.common_consts import zero_trust_consts
from monkey_island.cc.services.zero_trust.test_common.finding_data import (
get_monkey_finding_dto, get_monkey_finding_dto,
get_scoutsuite_finding_dto, get_scoutsuite_finding_dto,
) )
from common.common_consts import zero_trust_consts
from monkey_island.cc.services.zero_trust.zero_trust_report.principle_service import ( from monkey_island.cc.services.zero_trust.zero_trust_report.principle_service import (
PrincipleService, PrincipleService,
) )

View File

@ -23,5 +23,5 @@ addopts = "-v --capture=sys tests"
norecursedirs = "node_modules dist" norecursedirs = "node_modules dist"
[tool.vulture] [tool.vulture]
exclude = ["monkey/monkey_island/cc/ui"] exclude = ["monkey/monkey_island/cc/ui/", "monkey/tests/"]
paths = ["."] paths = ["."]

View File

@ -167,6 +167,8 @@ DigitalOcean # unused variable (monkey/common/cloud/environment_names.py:12)
_.aws_info # unused attribute (monkey/monkey_island/cc/environment/aws.py:13) _.aws_info # unused attribute (monkey/monkey_island/cc/environment/aws.py:13)
build_from_config_file_contents # unused method 'build_from_config_file_contents' (\monkey_island\setup\island_config_options.py:18) build_from_config_file_contents # unused method 'build_from_config_file_contents' (\monkey_island\setup\island_config_options.py:18)
mock_port_in_env_singleton # monkey\tests\unit_tests\monkey_island\cc\services\test_config.py:26: mock_port_in_env_singleton # monkey\tests\unit_tests\monkey_island\cc\services\test_config.py:26:
ISLAND # unused variable (monkey/monkey_island/cc/services/utils/node_states.py:14)
MONKEY_LINUX_RUNNING # unused variable (monkey/monkey_island/cc/services/utils/node_states.py:26)
# these are not needed for it to work, but may be useful extra information to understand what's going on # these are not needed for it to work, but may be useful extra information to understand what's going on
WINDOWS_PBA_TYPE # unused variable (monkey/monkey_island/cc/resources/pba_file_upload.py:23) WINDOWS_PBA_TYPE # unused variable (monkey/monkey_island/cc/resources/pba_file_upload.py:23)
@ -182,7 +184,11 @@ thread_id # unused variable (monkey/infection_monkey/network/mysqlfinger.py:61)
_.get_wmi_info # unused method (monkey/infection_monkey/system_info/windows_info_collector.py:63) _.get_wmi_info # unused method (monkey/infection_monkey/system_info/windows_info_collector.py:63)
# not 100% sure about these? are these being/will be used somewhere else? # potentially unused (there may also be unit tests referencing these)
LOG_DIR_NAME # unused variable (envs/monkey_zoo/blackbox/log_handlers/test_logs_handler.py:8) LOG_DIR_NAME # unused variable (envs/monkey_zoo/blackbox/log_handlers/test_logs_handler.py:8)
delete_logs # unused function (envs/monkey_zoo/blackbox/test_blackbox.py:85) delete_logs # unused function (envs/monkey_zoo/blackbox/test_blackbox.py:85)
MongoQueryJSONEncoder # unused class (envs/monkey_zoo/blackbox/utils/json_encoder.py:6) MongoQueryJSONEncoder # unused class (envs/monkey_zoo/blackbox/utils/json_encoder.py:6)
environment # unused variable (monkey/monkey_island/cc/models/monkey.py:59)
_.environment # unused attribute (monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/environment.py:10)
_.instance_name # unused attribute (monkey/common/cloud/azure/azure_instance.py:35)
_.instance_name # unused attribute (monkey/common/cloud/azure/azure_instance.py:64)