From bce06962e678d42e4f02d72d97822dfbdd47e139 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 13 Mar 2024 06:24:22 +0000 Subject: [PATCH] style: Automatic code formatting --- analyzer/linux/analyzer.py | 2 +- analyzer/linux/lib/core/packages.py | 5 +++-- lib/cuckoo/core/database.py | 2 +- lib/cuckoo/core/scheduler.py | 7 ++++++- modules/processing/strace.py | 8 ++++---- .../versions/add_platform_column_for_guests.py | 12 ++++++------ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/analyzer/linux/analyzer.py b/analyzer/linux/analyzer.py index 0348c489f65..0ed1e077123 100644 --- a/analyzer/linux/analyzer.py +++ b/analyzer/linux/analyzer.py @@ -311,7 +311,7 @@ def run(self): for file in os.listdir(PATHS["logs"]): upload_to_host(os.path.join(PATHS["logs"], file), os.path.join("logs", file)) except Exception as e: - log.warning('The strace log failed to transfer:', e) + log.warning("The strace log failed to transfer:", e) # Terminate the Auxiliary modules. log.info("Stopping auxiliary modules") diff --git a/analyzer/linux/lib/core/packages.py b/analyzer/linux/lib/core/packages.py index 43551a02f4d..5b00003e9ef 100644 --- a/analyzer/linux/lib/core/packages.py +++ b/analyzer/linux/lib/core/packages.py @@ -151,8 +151,8 @@ def get_pids(self): def strace_analysis(self): kwargs = {"args": self.args, "timeout": self.timeout, "run_as_root": self.run_as_root} log.info(self.target) - - target_cmd = f'{self.target}' + + target_cmd = f"{self.target}" if "args" in kwargs: target_cmd += f' {" ".join(kwargs["args"])}' @@ -189,6 +189,7 @@ def _upload_file(local, remote): nf.sock.sendall(chunk) # dirty direct send, no reconnecting nf.close() + def _string_to_bool(raw): if not isinstance(raw, str): raise Exception("Unexpected input: not a string :/") diff --git a/lib/cuckoo/core/database.py b/lib/cuckoo/core/database.py index a959b7c604d..87585e5d437 100644 --- a/lib/cuckoo/core/database.py +++ b/lib/cuckoo/core/database.py @@ -289,7 +289,7 @@ class Guest(Base): status = Column(String(16), nullable=False) name = Column(String(255), nullable=False) label = Column(String(255), nullable=False) - platform = Column(String(255), nullable=False) + platform = Column(String(255), nullable=False) 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) diff --git a/lib/cuckoo/core/scheduler.py b/lib/cuckoo/core/scheduler.py index 28f4ffab26d..5e3a59a30a1 100644 --- a/lib/cuckoo/core/scheduler.py +++ b/lib/cuckoo/core/scheduler.py @@ -477,7 +477,12 @@ def launch_analysis(self): try: self.acquire_machine() guest_log = self.db.set_task_vm_and_guest_start( - self.task.id, self.machine.name, self.machine.label, self.task.platform , self.machine.id, machinery.__class__.__name__ + self.task.id, + self.machine.name, + self.machine.label, + self.task.platform, + self.machine.id, + machinery.__class__.__name__, ) # At this point we can tell the ResultServer about it. except CuckooOperationalError as e: diff --git a/modules/processing/strace.py b/modules/processing/strace.py index 7fec38726b0..7434761e4b4 100644 --- a/modules/processing/strace.py +++ b/modules/processing/strace.py @@ -1,7 +1,7 @@ -import logging -import re import json +import logging import os +import re from lib.cuckoo.common.abstracts import Processing from lib.cuckoo.common.path_utils import path_exists @@ -72,11 +72,11 @@ def __init__(self, log_path, syscalls_info, options): self.fetch_calls(syscalls_info) def __iter__(self): - return iter(super().__iter__()) + return iter(super().__iter__()) def __repr__(self): return f"" - + def begin_reporting(self): pass diff --git a/utils/db_migration/versions/add_platform_column_for_guests.py b/utils/db_migration/versions/add_platform_column_for_guests.py index 0e009562fa1..d7625014200 100644 --- a/utils/db_migration/versions/add_platform_column_for_guests.py +++ b/utils/db_migration/versions/add_platform_column_for_guests.py @@ -11,16 +11,16 @@ """ # revision identifiers, used by Alembic. -revision = '3a1c6c03844b' -down_revision = 'a8441ab0fd0f' +revision = "3a1c6c03844b" +down_revision = "a8441ab0fd0f" -from alembic import op import sqlalchemy as sa +from alembic import op def upgrade(): - # Add the platform column to the guests table with a default value of 'windows' - op.add_column('guests', sa.Column('platform', sa.String(length=50), nullable=True)) + # Add the platform column to the guests table with a default value of 'windows' + op.add_column("guests", sa.Column("platform", sa.String(length=50), nullable=True)) # Update existing rows with the default value op.execute("UPDATE guests SET platform = 'windows' WHERE platform IS NULL") @@ -28,4 +28,4 @@ def upgrade(): def downgrade(): # Remove the platform column from the guests table - op.drop_column('guests', 'platform') + op.drop_column("guests", "platform")