feat: 资产详情页面添加历史执行命令列表页面

pull/12043/head^2
wangruidong 1 year ago committed by Bryan
parent cf18300360
commit 2cad97065f

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
#
import uuid
from django.utils import timezone
from rest_framework import generics
from rest_framework.fields import DateTimeField
@ -166,6 +167,7 @@ class CommandViewSet(JMSBulkModelViewSet):
def get_queryset(self):
command_storage_id = self.request.query_params.get('command_storage_id')
asset_id = self.request.query_params.get('asset_id')
if not command_storage_id:
return Command.objects.none()
@ -174,6 +176,9 @@ class CommandViewSet(JMSBulkModelViewSet):
raise StorageInvalid
else:
qs = storage.get_command_queryset()
if asset_id:
session_ids = Session.objects.filter(asset_id=asset_id).values_list('id', flat=True)
qs = qs.filter(session__in=list(session_ids))
return qs
def create(self, request, *args, **kwargs):

@ -62,7 +62,7 @@ class SessionFilterSet(BaseFilterSet):
class Meta:
model = Session
fields = [
"user", "user_id", "asset", "account", "remote_addr",
"user", "user_id", "asset", "asset_id", "account", "remote_addr",
"protocol", "is_finished", 'login_from', 'terminal'
]

@ -13,11 +13,12 @@ class CommandFilter(filters.FilterSet):
user = filters.CharFilter(lookup_expr='startswith')
input = filters.CharFilter(lookup_expr='icontains')
asset = filters.CharFilter(field_name='asset', lookup_expr='icontains')
asset_id = filters.UUIDFilter(method='do_nothing')
class Meta:
model = Command
fields = [
'asset', 'account', 'user', 'session', 'risk_level', 'input',
'asset', 'asset_id', 'account', 'user', 'session', 'risk_level', 'input',
'date_from', 'date_to', 'session_id', 'risk_level', 'command_storage_id',
]

Loading…
Cancel
Save