From 1ce24aae9ceadef5f15938ae0c26b34877235abd Mon Sep 17 00:00:00 2001 From: Matteo Lodi <30625432+mlodic@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:01:02 +0200 Subject: [PATCH] fix deepsource --- api_app/admin.py | 9 ++++++--- .../0021_ingestor_fix_malwarebazaar_threatfox.py | 1 + api_app/interfaces.py | 2 +- api_app/pivots_manager/admin.py | 6 ++++-- api_app/serializers/__init__.py | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/api_app/admin.py b/api_app/admin.py index 53b9f2c7c9..c4aab5f423 100644 --- a/api_app/admin.py +++ b/api_app/admin.py @@ -70,10 +70,12 @@ class JobAdminView(CustomAdminView): ) list_filter = ("status", "user", "tags") - def has_add_permission(self, request: HttpRequest) -> bool: + @staticmethod + def has_add_permission(request: HttpRequest) -> bool: return False - def has_change_permission(self, request: HttpRequest, obj=None) -> bool: + @staticmethod + def has_change_permission(request: HttpRequest, obj=None) -> bool: return False @admin.display(description="Tags") @@ -152,7 +154,8 @@ class AbstractReportAdminView(CustomAdminView): def has_add_permission(request): return False - def has_change_permission(self, request: HttpRequest, obj=None) -> bool: + @staticmethod + def has_change_permission(request: HttpRequest, obj=None) -> bool: return False diff --git a/api_app/ingestors_manager/migrations/0021_ingestor_fix_malwarebazaar_threatfox.py b/api_app/ingestors_manager/migrations/0021_ingestor_fix_malwarebazaar_threatfox.py index 89866faf56..c7ca8c4ea1 100644 --- a/api_app/ingestors_manager/migrations/0021_ingestor_fix_malwarebazaar_threatfox.py +++ b/api_app/ingestors_manager/migrations/0021_ingestor_fix_malwarebazaar_threatfox.py @@ -34,6 +34,7 @@ def migrate(apps, schema_editor): def reverse_migrate(apps, schema_editor): IngestorConfig = apps.get_model("ingestors_manager", "IngestorConfig") + PeriodicTask = apps.get_model("django_celery_beat", "PeriodicTask") ic_threatfox = IngestorConfig.objects.get(name="ThreatFox") ic_malwarebazaar = IngestorConfig.objects.get(name="MalwareBazaar") diff --git a/api_app/interfaces.py b/api_app/interfaces.py index 7392343e08..852ed4ced7 100644 --- a/api_app/interfaces.py +++ b/api_app/interfaces.py @@ -64,8 +64,8 @@ def _get_serializer( values, tlp, user, playbook_to_execute=playbook_to_execute, delay=delay ) + @staticmethod def _get_observable_serializer( - self, values: Iterable[Any], tlp: str, user: User, diff --git a/api_app/pivots_manager/admin.py b/api_app/pivots_manager/admin.py index 010b94a780..d9043a4ebb 100644 --- a/api_app/pivots_manager/admin.py +++ b/api_app/pivots_manager/admin.py @@ -35,8 +35,10 @@ def get_related_configs(self, instance: PivotConfig): class PivotMapAdminView(admin.ModelAdmin): list_display = ["pk", "starting_job", "pivot_config", "ending_job", "owner"] - def has_add_permission(self, request: HttpRequest) -> bool: + @staticmethod + def has_add_permission(request: HttpRequest) -> bool: return False - def has_change_permission(self, request: HttpRequest, obj=None) -> bool: + @staticmethod + def has_change_permission(request: HttpRequest, obj=None) -> bool: return False diff --git a/api_app/serializers/__init__.py b/api_app/serializers/__init__.py index cacc91ab25..03f56602e9 100644 --- a/api_app/serializers/__init__.py +++ b/api_app/serializers/__init__.py @@ -30,7 +30,8 @@ class Meta: "end_time", ] - def get_class_instance(self, instance): + @staticmethod + def get_class_instance(instance): return instance.__class__.__name__.lower() @staticmethod