From 619c145dcee6fc8ca482bcb4d95a4a373f0e62b9 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 4 Nov 2024 07:03:59 +0000 Subject: [PATCH] style: Automatic code formatting --- lib/cuckoo/common/cape_utils.py | 6 ++++-- lib/cuckoo/core/database.py | 11 +++++------ lib/cuckoo/core/scheduler.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/cuckoo/common/cape_utils.py b/lib/cuckoo/common/cape_utils.py index f9f85438a9a..31f1974645e 100644 --- a/lib/cuckoo/common/cape_utils.py +++ b/lib/cuckoo/common/cape_utils.py @@ -2,8 +2,8 @@ import logging import tempfile from collections.abc import Iterable, Mapping -from pathlib import Path from contextlib import suppress +from pathlib import Path from lib.cuckoo.common.config import Config from lib.cuckoo.common.constants import CUCKOO_ROOT @@ -22,7 +22,8 @@ HAS_MALWARECONFIGS = False HAVE_CAPE_EXTRACTORS = False with suppress(ImportError): - from cape_parsers import load_cape_parsers, load_mwcp_parsers, load_malwareconfig_parsers # load_malduck_parsers + from cape_parsers import load_cape_parsers, load_malwareconfig_parsers, load_mwcp_parsers # load_malduck_parsers + HAS_MWCP = True HAS_MALWARECONFIGS = True HAVE_CAPE_EXTRACTORS = True @@ -85,6 +86,7 @@ if process_cfg.CAPE_extractors.enabled: from lib.cuckoo.common.load_extra_modules import cape_load_custom_decoders + cape_malware_parsers = {} if HAVE_CAPE_EXTRACTORS: cape_malware_parsers = load_cape_parsers() diff --git a/lib/cuckoo/core/database.py b/lib/cuckoo/core/database.py index 7f88487641f..a38322da31d 100644 --- a/lib/cuckoo/core/database.py +++ b/lib/cuckoo/core/database.py @@ -170,8 +170,8 @@ tasks_tags = Table( "tasks_tags", Base.metadata, - Column("task_id", Integer, ForeignKey("tasks.id", ondelete='cascade')), - Column("tag_id", Integer, ForeignKey("tags.id", ondelete='cascade')), + Column("task_id", Integer, ForeignKey("tasks.id", ondelete="cascade")), + Column("tag_id", Integer, ForeignKey("tags.id", ondelete="cascade")), ) @@ -269,7 +269,7 @@ class Guest(Base): manager = Column(String(255), nullable=False) started_on = Column(DateTime(timezone=False), default=datetime.now, nullable=False) shutdown_on = Column(DateTime(timezone=False), nullable=True) - task_id = Column(Integer, ForeignKey("tasks.id", ondelete='cascade'), nullable=False, unique=True) + task_id = Column(Integer, ForeignKey("tasks.id", ondelete="cascade"), nullable=False, unique=True) def __repr__(self): return f"" @@ -2093,8 +2093,7 @@ def list_tasks( return tasks def check_tasks_timeout(self, timeout): - """Find tasks which were added_on more than timeout ago and clean - """ + """Find tasks which were added_on more than timeout ago and clean""" tasks: List[Task] = [] ids_to_delete = [] if timeout == 0: @@ -2102,7 +2101,7 @@ def check_tasks_timeout(self, timeout): search = self.session.query(Task).filter(Task.status == TASK_PENDING).order_by(Task.added_on.desc()) tasks = search.all() for task in tasks: - if task.added_on + timedelta(seconds = timeout) < datetime.now(): + if task.added_on + timedelta(seconds=timeout) < datetime.now(): ids_to_delete.append(task.id) if len(ids_to_delete) > 0: self.session.query(Task).filter(Task.id.in_(ids_to_delete)).delete(synchronize_session=False) diff --git a/lib/cuckoo/core/scheduler.py b/lib/cuckoo/core/scheduler.py index 3831c4a55b3..45d6b8dc506 100644 --- a/lib/cuckoo/core/scheduler.py +++ b/lib/cuckoo/core/scheduler.py @@ -102,7 +102,7 @@ def do_main_loop_work(self, error_queue: queue.Queue) -> SchedulerCycleDelay: if self.cfg.cuckoo.get("task_timeout", False): if self.next_timeout_time < time.time(): - self.next_timeout_time = time.time() + self.cfg.cuckoo.get("task_timeout_scan_interval", 30) + self.next_timeout_time = time.time() + self.cfg.cuckoo.get("task_timeout_scan_interval", 30) with self.db.session.begin(): self.db.check_tasks_timeout(self.cfg.cuckoo.get("task_pending_timeout", 0))