perf: 修改命令command input 长度问题 (#7996)

* perf: 修改命令command input max_length 1024

* perf: 修改命令command input 长度问题

* perf: 修改命令command input 长度问题

* perf: 修改命令command input 长度问题

* perf: 修改命令command input 长度问题

Co-authored-by: Jiangjie.Bai <bugatti_it@163.com>
This commit is contained in:
fit2bot
2022-03-30 19:07:49 +08:00
committed by GitHub
parent 54d1996507
commit e7af037513
13 changed files with 117 additions and 53 deletions

View File

@@ -1,5 +1,7 @@
from __future__ import unicode_literals
import time
from django.db import models
from django.db.models.signals import post_save
from django.utils.translation import ugettext_lazy as _
@@ -18,6 +20,33 @@ class CommandManager(models.Manager):
class Command(AbstractSessionCommand):
objects = CommandManager()
@classmethod
def generate_fake(cls, count=100, org=None):
import uuid
import datetime
from orgs.models import Organization
from common.utils import random_string
if not org:
org = Organization.default()
d = datetime.datetime.now() - datetime.timedelta(days=1)
commands = [
cls(**{
'user': random_string(6),
'asset': random_string(10),
'system_user': random_string(6),
'session': str(uuid.uuid4()),
'input': random_string(16),
'output': random_string(64),
'timestamp': int(d.timestamp()),
'org_id': str(org.id)
})
for i in range(count)
]
cls.objects.bulk_create(commands)
print(f'Create {len(commands)} commands of org ({org})')
class Meta:
db_table = "terminal_command"
ordering = ('-timestamp',)