Changed tests names

This commit is contained in:
Maximilien Rigaut 2022-06-27 03:00:57 +02:00
parent cd38817742
commit 2741329afc
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
2 changed files with 21 additions and 11 deletions

View File

@ -33,10 +33,11 @@ def parse(_args):
# Tests
parser.add_argument('--spidey', action='store_true', help='Runs the spidey test')
parser.add_argument('--adler', "--adler32", action='store_true', help='Runs the adler32 test')
parser.add_argument('--line-count', action='store_true', help='Test all known files for line count')
parser.add_argument('--file-count', action='store_true', help="Test the number of files in the discord folder")
parser.add_argument('--file-size', action='store_true', help="Test the size of the files in the discord folder")
parser.add_argument('--file-hash', action='store_true', help="Test the hash of the files in the discord folder")
parser.add_argument('--file-hash', '--sha', action='store_true', help="Test the hash of the files in the discord folder")
parser.add_argument('--file-path', action='store_true', help="Test the path of the files in the discord folder")
parser.add_argument('--file-name', action='store_true', help="Test the name of the files in the discord folder")
parser.add_argument('--file-extension', action='store_true', help="Test the extension of the files in the discord folder")
@ -47,7 +48,6 @@ def parse(_args):
parser.add_argument("--no-eval", action="store_true", help="Check for the eval function wich is a HUGE red flag")
parser.add_argument("--const-abuse", "--no-const", action="store_true",
help="Check for the abuse of the const: keyword, wich is massively used for obfucation")
parser.add_argument("--test-walk", action="store_true", help="Test walk function")
parser.add_argument("--max-errors", default=5, type=int, help="Maximum number of errors before the analysis is stopped")
return parser.parse_args(_args)

View File

@ -8,7 +8,6 @@ import time
from collections import deque
from modules.internal_io import global_status, thread_parameters
from modules import size_test, adler_test # noqa # Used to force import of modules by pyinstaller
"""
All modules that can be tested
@ -20,10 +19,11 @@ os.system('color')
# red, green, yellow, blue, magenta, cyan, white.
_TEST_MODULES = {
"spidey": ["spidey_test", "SpideyTest"],
# "test_walk": ["test_template", "TestWalkTemplate"],
"size_test": ["size_test", "SizeTest"],
"adler_test": ["adler_test", "AdlerTest"],
"spidey": ["test_spidey", "SpideyTest"],
"file_size": ["test_size", "SizeCheck"],
"adler": ["test_adler", "Adler32"],
"file_hash": ["test_sha", "Sha256"],
"line_count": ["test_line_count", "LineCount"],
}
PROGRAM_VERSION = "1.0.0"
@ -87,9 +87,10 @@ class TestRunner:
self.main_path = agnpath.main_path
self.version = agnpath.version
self.start_time = start_time
self.selected_tests = []
self.is_infected = 0 # Only set to 1 if the certainty is high enough
self.is_unknown = 0 # Unknown if the file is infected or not
self.is_unknown = 1 # Unknown if the file is infected or not
self.threat_level = 0 # The threat level of the infection, 0 is the lowest, can only be increased
self.errors = 0
self.bad_database = False # Set to true if the database is not valid
@ -149,7 +150,7 @@ class TestRunner:
self.base_data = {}
return self.base_data
def check_database(self):
def check_database(self): # TODO: All of this can be refactored with a function
"""
Check if the database is valid set self.bad_database to True if it is not
"""
@ -194,6 +195,11 @@ class TestRunner:
if "tests" not in self.base_data:
print(colored(" > The database is missing the test results", "red"))
self.bad_database = True
else:
for test_name in self.selected_tests:
if test_name not in self.base_data["tests"]:
print(colored(f" > The database is missing the test {test_name}", "red"))
self.bad_database = True
def update_module_list(self):
"""
@ -209,6 +215,7 @@ class TestRunner:
if self.args.all or self.args.__getattribute__(module_name):
modules[values[0]] = importlib.import_module(f"modules.{values[0]}")
classes[values[0]] = getattr(modules[values[0]], values[1])
self.selected_tests.append(values[1])
except AttributeError as e:
print(f"The module {module_name} was not loaded because it was not specified in the config.")
@ -361,7 +368,10 @@ class TestRunner:
for test_name, test in self.dict_of_processes.items():
progress += test.progress
progress = int(progress / nb_tests)
if nb_tests == 0:
progress = 100
else:
progress = int(progress / nb_tests)
nb_tests_ran = nb_tests_success + nb_tests_failure + nb_tests_skipped + nb_tests_error
nb_test_running = nb_tests - nb_tests_ran
@ -508,7 +518,7 @@ def print_final_status(testrunner, start_time, args):
Prints the final status
"""
status = testrunner.get_status()
if status.tests_failed == 0 and status.tests_error == 0:
if status.tests_failed == 0 and status.tests_error == 0 and status.tests_total != 0:
color = "green"
print(CLEAR_CODE)
elif status.tests_failed > 0: