From 6f765ebef5a6592f8d198b3ce11cfd0a730993ac Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 22 Feb 2023 13:08:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?perf:=20=E4=BF=AE=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=B9=B3=E5=8F=B0=E5=86=85=E7=BD=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/serializers/account/account.py | 7 ++++--- apps/assets/const/types.py | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index 8cf92671e..34333cfe4 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -101,9 +101,10 @@ class AccountSerializer(AccountSerializerCreateMixin, BaseAccountSerializer): class Meta(BaseAccountSerializer.Meta): model = Account - fields = BaseAccountSerializer.Meta.fields \ - + ['su_from', 'asset'] \ - + ['template', 'push_now', 'source'] + fields = BaseAccountSerializer.Meta.fields + [ + 'su_from', 'asset', 'template', + 'push_now', 'source', 'connectivity' + ] extra_kwargs = { **BaseAccountSerializer.Meta.extra_kwargs, 'name': {'required': False, 'allow_null': True}, diff --git a/apps/assets/const/types.py b/apps/assets/const/types.py index 3c0989517..cde7c8aba 100644 --- a/apps/assets/const/types.py +++ b/apps/assets/const/types.py @@ -329,9 +329,8 @@ class AllTypes(ChoicesMixin): internal_platforms.append(d['name']) user_platforms = platform_cls.objects.exclude(name__in=internal_platforms) - user_platforms.update(internal=False) - for platform in user_platforms: print("\t- Update platform: {}".format(platform.name)) platform_data = cls.get_type_default_platform(platform.category, platform.type) cls.create_or_update_by_platform_data(platform.name, platform_data, platform_cls=platform_cls) + user_platforms.update(internal=False) From 312fe690159ea4985917b12bebef129263a8ab5b Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 22 Feb 2023 14:10:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/api/applet/host.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/terminal/api/applet/host.py b/apps/terminal/api/applet/host.py index 38c42cd18..89bc1f96c 100644 --- a/apps/terminal/api/applet/host.py +++ b/apps/terminal/api/applet/host.py @@ -58,7 +58,7 @@ class AppletHostDeploymentViewSet(viewsets.ModelViewSet): def applets(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) - applet_id = serializer.validated_data.pop('applet_id') + applet_id = serializer.validated_data.pop('applet_id', '') instance = serializer.save() task = run_applet_host_deployment_install_applet.delay(instance.id, applet_id) instance.save_task(task.id) From 156ad665c340690f5e4ca306b869568ad36ff7c8 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 22 Feb 2023 14:52:39 +0800 Subject: [PATCH 3/4] fix: rbac perms --- apps/rbac/const.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/rbac/const.py b/apps/rbac/const.py index 1c0f594f9..2092cd9ff 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -60,6 +60,7 @@ exclude_permissions = ( ('accounts', 'automationexecution', '*', 'automationexecution'), ('accounts', 'accountbackupexecution', 'delete,change', 'accountbackupexecution'), ('accounts', 'changesecretrecord', 'add,delete,change', 'changesecretrecord'), + ('accounts', 'account', 'change', 'accountsecret'), ('perms', 'userassetgrantedtreenoderelation', '*', '*'), ('perms', 'permedaccount', '*', '*'), From 89c4635162c25cc8b69e6e788b4c47fc0354045c Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Wed, 22 Feb 2023 15:15:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?perf:=20change=20secrett=20=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=20(#9686)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/automations/change_secret/manager.py | 6 ++++-- apps/accounts/automations/push_account/manager.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/accounts/automations/change_secret/manager.py b/apps/accounts/automations/change_secret/manager.py index a6c14fa23..6cd36f080 100644 --- a/apps/accounts/automations/change_secret/manager.py +++ b/apps/accounts/automations/change_secret/manager.py @@ -87,7 +87,9 @@ class ChangeSecretManager(AccountBasePlaybookManager): accounts = accounts.filter(secret_type=self.secret_type) if not accounts: - print('没有发现待改密账号: %s 用户名: %s 类型: %s' % (asset.name, account.username, self.secret_type)) + print('没有发现待改密账号: %s 用户名: %s 类型: %s' % ( + asset.name, self.snapshot_account_usernames, self.secret_type + )) return [] method_attr = getattr(automation, self.method_type() + '_method') @@ -98,7 +100,7 @@ class ChangeSecretManager(AccountBasePlaybookManager): host['secret_type'] = self.secret_type if asset.type == HostTypes.WINDOWS and self.secret_type == SecretType.SSH_KEY: - print(f'Windows {asset} does not support ssh key push \n') + print(f'Windows {asset} does not support ssh key push') return inventory_hosts for account in accounts: diff --git a/apps/accounts/automations/push_account/manager.py b/apps/accounts/automations/push_account/manager.py index 42a53fcb1..770ca9d25 100644 --- a/apps/accounts/automations/push_account/manager.py +++ b/apps/accounts/automations/push_account/manager.py @@ -59,7 +59,6 @@ class PushAccountManager(ChangeSecretManager, AccountBasePlaybookManager): accounts = asset.accounts.all() accounts = self.get_accounts(account, accounts) - inventory_hosts = [] host['secret_type'] = self.secret_type if asset.type == HostTypes.WINDOWS and self.secret_type == SecretType.SSH_KEY: