Started the module loading

This commit is contained in:
Maximilien Rigaut 2022-06-21 20:27:09 +02:00
parent cdff66dc39
commit e799252122
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
3 changed files with 35 additions and 3 deletions

View File

@ -2,6 +2,10 @@ import os
import re
import sys
_TEST_MODULES = { # argparse argument : [module_name, class_name]
"spidey": ["spidey_test", "spidey"],
}
class SpideyDetector:
def __init__(self, args, agnpath):
@ -18,13 +22,24 @@ class SpideyDetector:
self.main_path = agnpath.main_path
self.latest_version = agnpath.latest_version
# self.is_windows = self.check_os()
self.is_infected = False
self.is_infected = 0
self.detections = 0
self.test_run = {}
# self.paths = self.check_paths(*self.get_path())
# self.spidey_check()
self.loaded_modules = self.get_module_list()
self.spidey_check()
def get_module_list(self):
"""
Gets the list of modules to be loaded (in accordance to the config)
:return: List of modules
:rtype: list
"""
modules = []
for module in _TEST_MODULES:
if module[0] in self.loaded_modules:
modules.append(module[1])
def check_os(self): # noqa
if not sys.platform.startswith('win'):
raise OSError("This script can only check for Spideys on Windows.")

16
modules/spidey_test.py Normal file
View File

@ -0,0 +1,16 @@
class SpideyTest:
def __init__(self, args, agnpath, test_data):
"""
Simple test runner, for testing the detection of Spidey viruses.
:param args: List of arguments
:type args: argparse.Namespace
:param agnpath: The path to the discord folder
:type agnpath: agnostic_path.AgnosticPath
:param test_data: The data to be tested
:type test_data: str
"""
self.ptb = args.ptb
self.agnostic_path = agnpath
self.os_name = agnpath.os
self.main_path = agnpath.main_path
self.test_data = test_data

View File

@ -16,6 +16,7 @@ def parse(_args):
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0')
parser.add_argument('-d', '--debug', action='store_true', help='Debug mode')
parser.add_argument('-s', '--silent', action='store_true', help='Silent mode')
parser.add_argument('--spidey', action='store_true', help='Runs the spidey 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")