Skip to content

Commit

Permalink
Check exceptions during filtering using plugins (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
msm-code authored Jan 20, 2023
1 parent e832f51 commit a849815
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def execute_yara(self, job: JobSchema, files: List[str]) -> None:
num_files = len(files)
self.db.job_start_work(job.id, num_files)

filemap_raw = {name: self.plugins.filter(name) for name in files}
filemap = {k: v for k, v in filemap_raw.items() if v}

for orig_name, path in filemap.items():
for orig_name in files:
try:
path = self.plugins.filter(orig_name)
if not path:
continue
matches = rule.match(path)
if matches:
self.update_metadata(
Expand All @@ -107,6 +107,9 @@ def execute_yara(self, job: JobSchema, files: List[str]) -> None:
except FileNotFoundError:
logging.error("Failed to open file %s", orig_name)
num_errors += 1
except Exception:
logging.exception("Unknown error (plugin?): %s", orig_name)
num_errors += 1

self.plugins.cleanup()
self.db.job_update_work(job.id, num_files, num_matches, num_errors)
Expand Down

0 comments on commit a849815

Please sign in to comment.