From d60fe464cabde899c27b64486d7d675c519a5a4c Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:18:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Des6.8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98=20(#1206?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/common/plugins/es.py | 5 +++-- apps/terminal/api/session/command.py | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/common/plugins/es.py b/apps/common/plugins/es.py index 95f878263..297f2e32a 100644 --- a/apps/common/plugins/es.py +++ b/apps/common/plugins/es.py @@ -177,9 +177,10 @@ class ES(object): body = self.get_query_body(**query) data = self.es.search( - index=self.query_index, doc_type=self.doc_type, body=body, + index=self.query_index, body=body, from_=from_, size=size, sort=sort ) + source_data = [] for item in data['hits']['hits']: if item: @@ -191,7 +192,7 @@ class ES(object): def count(self, **query): try: body = self.get_query_body(**query) - data = self.es.count(index=self.query_index, doc_type=self.doc_type, body=body) + data = self.es.count(index=self.query_index, body=body) count = data["count"] except Exception as e: logger.error('ES count error: {}'.format(e)) diff --git a/apps/terminal/api/session/command.py b/apps/terminal/api/session/command.py index 4d20d345c..494d001c0 100644 --- a/apps/terminal/api/session/command.py +++ b/apps/terminal/api/session/command.py @@ -1,26 +1,25 @@ # -*- coding: utf-8 -*- # -from django.utils import translation from django.utils import timezone from rest_framework import generics from rest_framework.fields import DateTimeField from rest_framework.response import Response from acls.models import CommandFilterACL, CommandGroup -from terminal.models import CommandStorage, Session, Command -from terminal.filters import CommandFilter -from orgs.utils import current_org from common.api import JMSBulkModelViewSet from common.utils import get_logger -from terminal.serializers import ( - SessionCommandSerializer, InsecureCommandAlertSerializer -) -from terminal.exceptions import StorageInvalid +from orgs.utils import current_org from terminal.backends import ( get_command_storage, get_multi_command_storage ) -from terminal.notifications import CommandAlertMessage, CommandWarningMessage from terminal.const import RiskLevelChoices +from terminal.exceptions import StorageInvalid +from terminal.filters import CommandFilter +from terminal.models import CommandStorage, Session, Command +from terminal.notifications import CommandAlertMessage, CommandWarningMessage +from terminal.serializers import ( + SessionCommandSerializer, InsecureCommandAlertSerializer +) logger = get_logger(__name__) __all__ = ['CommandViewSet', 'InsecureCommandAlertAPI'] @@ -140,8 +139,8 @@ class CommandViewSet(JMSBulkModelViewSet): if session_id and not command_storage_id: # 会话里的命令列表肯定会提供 session_id,这里防止 merge 的时候取全量的数据 return self.merge_all_storage_list(request, *args, **kwargs) - - queryset = self.filter_queryset(self.get_queryset()) + queryset = self.get_queryset() + queryset = self.filter_queryset(queryset) page = self.paginate_queryset(queryset) if page is not None: