diff --git a/apps/assets/models/cmd_filter.py b/apps/assets/models/cmd_filter.py index d91d50988..b17a4263d 100644 --- a/apps/assets/models/cmd_filter.py +++ b/apps/assets/models/cmd_filter.py @@ -171,7 +171,7 @@ class CommandFilterRule(OrgModelMixin): 'type': TicketType.command_confirm, 'applicant': session.user_obj, 'apply_run_user_id': session.user_id, - 'apply_run_asset_id': session.asset_id, + 'apply_run_asset': str(session.asset), 'apply_run_system_user_id': session.system_user_id, 'apply_run_command': run_command[:4090], 'apply_from_session_id': str(session.id), diff --git a/apps/perms/const.py b/apps/perms/const.py index 5b8e1baca..ec51c5a2b 100644 --- a/apps/perms/const.py +++ b/apps/perms/const.py @@ -1,4 +1,2 @@ # -*- coding: utf-8 -*- # -from django.db.models import TextChoices -from django.utils.translation import ugettext_lazy as _ diff --git a/apps/rbac/const.py b/apps/rbac/const.py index 1a3cc93b4..20038de19 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -69,6 +69,11 @@ exclude_permissions = ( ('tickets', 'ticket', 'add,delete,change', 'ticket'), ('tickets', 'ticketstep', '*', '*'), ('tickets', 'approvalrule', '*', '*'), + ('tickets', 'applyloginticket', '*', '*'), + ('tickets', 'applyloginassetticket', '*', '*'), + ('tickets', 'applycommandticket', '*', '*'), + ('tickets', 'applyassetticket', '*', '*'), + ('tickets', 'applyapplicationticket', '*', '*'), ('tickets', 'superticket', 'delete', 'superticket'), ('tickets', 'ticketsession', 'view,delete', 'ticketsession'), ('xpack', 'interface', '*', '*'), diff --git a/apps/tickets/migrations/0016_auto_20220609_1758.py b/apps/tickets/migrations/0016_auto_20220609_1758.py index 55d88385e..663db3a75 100644 --- a/apps/tickets/migrations/0016_auto_20220609_1758.py +++ b/apps/tickets/migrations/0016_auto_20220609_1758.py @@ -59,7 +59,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='ticket', name='state', - field=models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), + field=models.CharField(choices=[('pending', 'Open'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('closed', 'Cancel'), ('reopen', 'Reopen')], default='pending', max_length=16, verbose_name='State'), ), @@ -72,14 +72,14 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='ticketassignee', name='state', - field=models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), + field=models.CharField(choices=[('pending', 'Open'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('closed', 'Cancel'), ('reopen', 'Reopen')], default='pending', max_length=64), ), migrations.AlterField( model_name='ticketstep', name='state', - field=models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), + field=models.CharField(choices=[('pending', 'Open'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('closed', 'Closed')], default='pending', max_length=64, verbose_name='State'), ), @@ -111,6 +111,7 @@ class Migration(migrations.Migration): models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tickets.ticket')), ('apply_run_command', models.CharField(max_length=4096, verbose_name='Run command')), + ('apply_run_asset', models.CharField(max_length=128, verbose_name='Run asset')), ('apply_from_cmd_filter', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='assets.commandfilter', verbose_name='From cmd filter')), @@ -120,9 +121,6 @@ class Migration(migrations.Migration): ('apply_from_session', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='terminal.session', verbose_name='Session')), - ('apply_run_asset', - models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='assets.asset', - verbose_name='Run asset')), ('apply_run_system_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='assets.systemuser', verbose_name='Run system user')), diff --git a/apps/tickets/migrations/0017_auto_20220623_1027.py b/apps/tickets/migrations/0017_auto_20220623_1027.py index 258ff676a..d3a9a1953 100644 --- a/apps/tickets/migrations/0017_auto_20220623_1027.py +++ b/apps/tickets/migrations/0017_auto_20220623_1027.py @@ -263,11 +263,6 @@ def command_confirm_migrate(apps, *args): name=name_username[0], username=name_username[1] ).first() if name_username else None - hostname_ip = analysis_instance_name(meta.get('apply_run_asset')) - apply_run_asset = asset_model.objects.filter( - org_id=instance.org_id, hostname=hostname_ip[0], ip=hostname_ip[1] - ).first() if hostname_ip else None - name_username = analysis_instance_name(meta.get('apply_run_system_user')) apply_run_system_user = system_user_model.objects.filter( org_id=instance.org_id, name=name_username[0], username=name_username[1] @@ -287,7 +282,7 @@ def command_confirm_migrate(apps, *args): data = { 'ticket_ptr_id': instance.pk, 'apply_run_user': apply_run_user, - 'apply_run_asset': apply_run_asset, + 'apply_run_asset': meta.get('apply_run_asset', ''), 'apply_run_system_user': apply_run_system_user, 'apply_run_command': meta.get('apply_run_command', '')[:4090], 'apply_from_session_id': apply_from_session_id, diff --git a/apps/tickets/models/ticket/command_confirm.py b/apps/tickets/models/ticket/command_confirm.py index 94d27fde7..c42e9c166 100644 --- a/apps/tickets/models/ticket/command_confirm.py +++ b/apps/tickets/models/ticket/command_confirm.py @@ -9,10 +9,7 @@ class ApplyCommandTicket(Ticket): 'users.User', on_delete=models.SET_NULL, null=True, verbose_name=_('Run user') ) - apply_run_asset = models.ForeignKey( - 'assets.Asset', on_delete=models.SET_NULL, - null=True, verbose_name=_('Run asset') - ) + apply_run_asset = models.CharField(max_length=128, verbose_name=_('Run asset'), default='') apply_run_system_user = models.ForeignKey( 'assets.SystemUser', on_delete=models.SET_NULL, null=True, verbose_name=_('Run system user') @@ -30,4 +27,3 @@ class ApplyCommandTicket(Ticket): 'assets.CommandFilterRule', on_delete=models.SET_NULL, null=True, verbose_name=_('From cmd filter rule') ) -