Make `MVTModule.get_slug()` a classmethod (#418)

This commit is contained in:
Rory Flynn 2023-11-22 10:37:38 +01:00 committed by GitHub
parent 73104814ba
commit 1d075abde9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -53,7 +53,7 @@ class CmdCheckIOCS(Command):
if self.module_name and iocs_module.__name__ != self.module_name:
continue
if iocs_module().get_slug() != name_only:
if iocs_module.get_slug() != name_only:
continue
log.info(

View File

@ -74,12 +74,13 @@ class MVTModule:
log.info('Loaded %d results from "%s"', len(results), json_path)
return cls(results=results, log=log)
def get_slug(self) -> str:
@classmethod
def get_slug(cls) -> str:
"""Use the module's class name to retrieve a slug"""
if self.slug:
return self.slug
if cls.slug:
return cls.slug
sub = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", self.__class__.__name__)
sub = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", cls.__name__)
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", sub).lower()
def check_indicators(self) -> None: