Browse Source

perf: 命令上传 取消input长度限制

pull/12699/head
feng 9 months ago committed by Bryan
parent
commit
cea16fc41f
  1. 7
      apps/terminal/backends/command/db.py
  2. 2
      apps/terminal/serializers/command.py

7
apps/terminal/backends/command/db.py

@ -2,10 +2,10 @@
import datetime
from django.db import transaction
from django.utils import timezone
from django.db.utils import OperationalError
from common.utils.common import pretty_string
from django.utils import timezone
from common.utils.common import pretty_string
from .base import CommandBase
@ -19,9 +19,10 @@ class CommandStore(CommandBase):
"""
保存命令到数据库
"""
cmd_input = pretty_string(command['input'])
self.model.objects.create(
user=command["user"], asset=command["asset"],
account=command["account"], input=command["input"],
account=command["account"], input=cmd_input,
output=command["output"], session=command["session"],
risk_level=command.get("risk_level", 0), org_id=command["org_id"],
timestamp=command["timestamp"]

2
apps/terminal/serializers/command.py

@ -15,7 +15,7 @@ class SimpleSessionCommandSerializer(serializers.ModelSerializer):
""" 简单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"))
input = serializers.CharField(label=_("Command"))
session = serializers.CharField(max_length=36, label=_("Session ID"))
risk_level = LabeledChoiceField(
choices=RiskLevelChoices.choices,

Loading…
Cancel
Save