mirror of https://github.com/jumpserver/jumpserver
144 lines
4.8 KiB
Python
144 lines
4.8 KiB
Python
# Generated by Django 4.1.13 on 2024-11-14 11:00
|
|
|
|
import uuid
|
|
|
|
import django.db.models.deletion
|
|
from django.db import migrations, models
|
|
|
|
|
|
def init_account_check_engine(apps, schema_editor):
|
|
data = [
|
|
{
|
|
'id': '00000000-0000-0000-0000-000000000001',
|
|
'slug': 'check_gathered_account',
|
|
'name': '检查发现的账号',
|
|
'comment': '基于自动发现的账号结果进行检查分析,检查 用户组、公钥、sudoers 等信息'
|
|
},
|
|
{
|
|
'id': '00000000-0000-0000-0000-000000000002',
|
|
'slug': 'check_account_secret',
|
|
'name': '检查账号密码强弱',
|
|
'comment': '基于账号密码的安全性进行检查分析, 检查密码强度、泄露等信息'
|
|
}
|
|
]
|
|
model_cls = apps.get_model('accounts', 'CheckAccountEngine')
|
|
for item in data:
|
|
model_cls.objects.create(**item)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("assets", "0007_baseautomation_date_last_run_and_more"),
|
|
(
|
|
"accounts",
|
|
"0011_rename_date_change_password_gatheredaccount_date_password_change",
|
|
),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="CheckAccountAutomation",
|
|
fields=[
|
|
(
|
|
"baseautomation_ptr",
|
|
models.OneToOneField(
|
|
auto_created=True,
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
parent_link=True,
|
|
primary_key=True,
|
|
serialize=False,
|
|
to="assets.baseautomation",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "account check automation",
|
|
"permissions": [
|
|
("view_checkaccountexecution", "Can view check account execution"),
|
|
("add_checkaccountexecution", "Can add check account execution"),
|
|
],
|
|
},
|
|
bases=("accounts.accountbaseautomation",),
|
|
),
|
|
migrations.CreateModel(
|
|
name="CheckAccountEngine",
|
|
fields=[
|
|
(
|
|
"created_by",
|
|
models.CharField(
|
|
blank=True, max_length=128, null=True, verbose_name="Created by"
|
|
),
|
|
),
|
|
(
|
|
"updated_by",
|
|
models.CharField(
|
|
blank=True, max_length=128, null=True, verbose_name="Updated by"
|
|
),
|
|
),
|
|
(
|
|
"date_created",
|
|
models.DateTimeField(
|
|
auto_now_add=True, null=True, verbose_name="Date created"
|
|
),
|
|
),
|
|
(
|
|
"date_updated",
|
|
models.DateTimeField(auto_now=True, verbose_name="Date updated"),
|
|
),
|
|
(
|
|
"comment",
|
|
models.TextField(blank=True, default="", verbose_name="Comment"),
|
|
),
|
|
(
|
|
"id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4, primary_key=True, serialize=False
|
|
),
|
|
),
|
|
(
|
|
"name",
|
|
models.CharField(max_length=128, unique=True, verbose_name="Name"),
|
|
),
|
|
(
|
|
"slug",
|
|
models.SlugField(max_length=128, unique=True, verbose_name="Slug"),
|
|
),
|
|
(
|
|
"is_active",
|
|
models.BooleanField(default=True, verbose_name="Is active"),
|
|
),
|
|
],
|
|
options={
|
|
"abstract": False,
|
|
},
|
|
),
|
|
migrations.AddField(
|
|
model_name="accountbackupautomation",
|
|
name="date_last_run",
|
|
field=models.DateTimeField(
|
|
blank=True, null=True, verbose_name="Date last run"
|
|
),
|
|
),
|
|
migrations.AlterField(
|
|
model_name="accountbackupautomation",
|
|
name="crontab",
|
|
field=models.CharField(
|
|
blank=True, default="", max_length=128, verbose_name="Crontab"
|
|
),
|
|
),
|
|
migrations.DeleteModel(
|
|
name="AccountCheckAutomation",
|
|
),
|
|
migrations.AddField(
|
|
model_name="checkaccountautomation",
|
|
name="engines",
|
|
field=models.ManyToManyField(
|
|
related_name="check_automations",
|
|
to="accounts.checkaccountengine",
|
|
verbose_name="Engines",
|
|
),
|
|
),
|
|
migrations.RunPython(init_account_check_engine),
|
|
]
|