Fix issue #574 for a module without IOCs output (#620)

* Fix issue #574 for a module without IOCs output
This commit is contained in:
ping2A
2025-04-30 10:30:39 +02:00
committed by GitHub
parent e34e03d3a3
commit 3dedd169c4
2 changed files with 12 additions and 4 deletions

View File

@@ -65,6 +65,10 @@ class CmdCheckIOCS(Command):
m = iocs_module.from_json(
file_path, log=logging.getLogger(iocs_module.__module__)
)
if not m:
log.warning("No result from this module, skipping it")
continue
if self.iocs.total_ioc_count > 0:
m.indicators = self.iocs
m.indicators.log = m.log

View File

@@ -69,10 +69,14 @@ class MVTModule:
@classmethod
def from_json(cls, json_path: str, log: logging.Logger):
with open(json_path, "r", encoding="utf-8") as handle:
results = json.load(handle)
if log:
log.info('Loaded %d results from "%s"', len(results), json_path)
return cls(results=results, log=log)
try:
results = json.load(handle)
if log:
log.info('Loaded %d results from "%s"', len(results), json_path)
return cls(results=results, log=log)
except json.decoder.JSONDecodeError as err:
log.error('Error to decode the json "%s" file: "%s"', json_path, err)
return None
@classmethod
def get_slug(cls) -> str: