|
13 | 13 | import time |
14 | 14 | import traceback |
15 | 15 | from collections import defaultdict |
16 | | -from datetime import datetime |
17 | 16 | from typing import DefaultDict, List, Optional, Tuple |
18 | 17 |
|
19 | 18 | from lib.cuckoo.common.cleaners_utils import free_space_monitor |
|
22 | 21 | from lib.cuckoo.common.exceptions import CuckooUnserviceableTaskError |
23 | 22 | from lib.cuckoo.common.utils import CATEGORIES_NEEDING_VM, load_categories |
24 | 23 | from lib.cuckoo.core.analysis_manager import AnalysisManager |
25 | | -from lib.cuckoo.core.database import TASK_FAILED_ANALYSIS, TASK_PENDING, Database, Machine, Task, _Database |
| 24 | +from lib.cuckoo.core.database import TASK_FAILED_ANALYSIS, TASK_PENDING, Database, Machine, Task, _Database, _utcnow_naive |
26 | 25 | from lib.cuckoo.core.machinery_manager import MachineryManager |
27 | 26 |
|
28 | 27 | log = logging.getLogger(__name__) |
@@ -95,7 +94,7 @@ def do_main_loop_work(self, error_queue: queue.Queue) -> SchedulerCycleDelay: |
95 | 94 | vm_state = self.cfg.timeouts.get("vm_state", 100) |
96 | 95 | timeout = analysis.task.timeout or self.cfg.timeouts.default |
97 | 96 | max_runtime = timeout + self.cfg.timeouts.critical + stuck_seconds + vm_state |
98 | | - duration = (datetime.now() - analysis.task.started_on).total_seconds() |
| 97 | + duration = (_utcnow_naive - analysis.task.started_on).total_seconds() |
99 | 98 | if duration > max_runtime: |
100 | 99 | log.warning( |
101 | 100 | "Task #%s has been running for %s seconds, which is longer than the configured timeout + critical timeout + 100s. Killing VM.", |
|
0 commit comments