|
|
@ -9,7 +9,7 @@ class SessionCommandSerializer(serializers.Serializer):
|
|
|
|
"""使用这个类作为基础Command Log Serializer类, 用来序列化"""
|
|
|
|
"""使用这个类作为基础Command Log Serializer类, 用来序列化"""
|
|
|
|
|
|
|
|
|
|
|
|
id = serializers.UUIDField(read_only=True)
|
|
|
|
id = serializers.UUIDField(read_only=True)
|
|
|
|
user = serializers.CharField(max_length=64, label=_("User"))
|
|
|
|
user = serializers.CharField(label=_("User")) # 限制 64 字符,见 validate_user
|
|
|
|
asset = serializers.CharField(max_length=128, label=_("Asset"))
|
|
|
|
asset = serializers.CharField(max_length=128, label=_("Asset"))
|
|
|
|
system_user = serializers.CharField(max_length=64, label=_("System user"))
|
|
|
|
system_user = serializers.CharField(max_length=64, label=_("System user"))
|
|
|
|
input = serializers.CharField(max_length=128, label=_("Command"))
|
|
|
|
input = serializers.CharField(max_length=128, label=_("Command"))
|
|
|
@ -25,6 +25,11 @@ class SessionCommandSerializer(serializers.Serializer):
|
|
|
|
risk_mapper = dict(AbstractSessionCommand.RISK_LEVEL_CHOICES)
|
|
|
|
risk_mapper = dict(AbstractSessionCommand.RISK_LEVEL_CHOICES)
|
|
|
|
return risk_mapper.get(obj.risk_level)
|
|
|
|
return risk_mapper.get(obj.risk_level)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_user(self, value):
|
|
|
|
|
|
|
|
if len(value) > 64:
|
|
|
|
|
|
|
|
value = value[:32] + value[-32:]
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsecureCommandAlertSerializer(serializers.Serializer):
|
|
|
|
class InsecureCommandAlertSerializer(serializers.Serializer):
|
|
|
|
input = serializers.CharField()
|
|
|
|
input = serializers.CharField()
|
|
|
|