From 009da190506dbe9cb08f2dec4ef2d47ed2cd87d1 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Tue, 9 Sep 2025 16:33:22 +0800 Subject: [PATCH] perf: Change secret windows password cannot contain > ^ --- apps/accounts/automations/base/manager.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/accounts/automations/base/manager.py b/apps/accounts/automations/base/manager.py index ec535b692..65474dea6 100644 --- a/apps/accounts/automations/base/manager.py +++ b/apps/accounts/automations/base/manager.py @@ -113,6 +113,18 @@ class BaseChangeSecretPushManager(AccountBasePlaybookManager): if host.get('error'): return host + inventory_hosts = [] + if asset.type == HostTypes.WINDOWS: + if self.secret_type == SecretType.SSH_KEY: + host['error'] = _("Windows does not support SSH key authentication") + return host + + if self.secret_strategy == SecretStrategy.custom: + new_secret = self.execution.snapshot['secret'] + if '>' in new_secret or '^' in new_secret: + host['error'] = _("Windows password cannot contain special characters like > ^") + return host + host['ssh_params'] = {} accounts = self.get_accounts(account) @@ -130,11 +142,6 @@ class BaseChangeSecretPushManager(AccountBasePlaybookManager): if asset.type == HostTypes.WINDOWS: accounts = accounts.filter(secret_type=SecretType.PASSWORD) - inventory_hosts = [] - if asset.type == HostTypes.WINDOWS and self.secret_type == SecretType.SSH_KEY: - print(f'Windows {asset} does not support ssh key push') - return inventory_hosts - for account in accounts: h = deepcopy(host) h['name'] += '(' + account.username + ')' # To distinguish different accounts