perf: command log risk choice (#9419)

Co-authored-by: feng <1304903146@qq.com>
pull/9420/head
fit2bot 2 years ago committed by GitHub
parent 93932f1904
commit 003feb1aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,9 +26,8 @@ from common.signals import django_ready
from common.utils import get_request_ip, get_logger, get_syslogger
from common.utils.encode import data_to_json
from jumpserver.utils import current_request
from terminal.backends.command.serializers import SessionCommandSerializer
from terminal.models import Session, Command
from terminal.serializers import SessionSerializer
from terminal.serializers import SessionSerializer, SessionCommandSerializer
from users.models import User
from users.signals import post_user_change_password
from . import models, serializers

@ -11,11 +11,12 @@ from terminal.filters import CommandFilter
from orgs.utils import current_org
from common.api import JMSBulkModelViewSet
from common.utils import get_logger
from terminal.backends.command.serializers import InsecureCommandAlertSerializer
from terminal.serializers import (
SessionCommandSerializer, InsecureCommandAlertSerializer
)
from terminal.exceptions import StorageInvalid
from terminal.backends import (
get_command_storage, get_multi_command_storage,
SessionCommandSerializer,
get_command_storage, get_multi_command_storage
)
from terminal.notifications import CommandAlertMessage

@ -3,8 +3,6 @@ from django.conf import settings
from django.utils.functional import LazyObject
from common.utils import get_logger
from .command.serializers import SessionCommandSerializer
logger = get_logger(__file__)

@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
#
from .terminal import *
from .applet import *
from .command import *
from .session import *
from .storage import *
from .sharing import *
from .terminal import *
from .endpoint import *
from .applet import *
from .applet_host import *

@ -3,18 +3,20 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from common.utils import pretty_string
from .models import AbstractSessionCommand
from common.serializers.fields import LabeledChoiceField
from terminal.backends.command.models import AbstractSessionCommand
__all__ = ['SessionCommandSerializer', 'InsecureCommandAlertSerializer']
class SimpleSessionCommandSerializer(serializers.Serializer):
""" 简单Session命令序列类, 用来提取公共字段 """
user = serializers.CharField(label=_("User")) # 限制 64 字符,见 validate_user
asset = serializers.CharField(max_length=128, label=_("Asset"))
input = serializers.CharField(max_length=2048, label=_("Command"))
session = serializers.CharField(max_length=36, label=_("Session ID"))
risk_level = serializers.ChoiceField(
risk_level = LabeledChoiceField(
required=False, label=_("Risk level"), choices=AbstractSessionCommand.RISK_LEVEL_CHOICES
)
org_id = serializers.CharField(
Loading…
Cancel
Save