From 4f2250b7a847ecb1fc655b864692f857666d6e76 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Mon, 31 Oct 2022 18:32:07 +0800 Subject: [PATCH 1/2] perf: gather account windows --- apps/assets/automations/gather_accounts/filter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/assets/automations/gather_accounts/filter.py b/apps/assets/automations/gather_accounts/filter.py index 0c8f32536..ebaf6d9b1 100644 --- a/apps/assets/automations/gather_accounts/filter.py +++ b/apps/assets/automations/gather_accounts/filter.py @@ -39,8 +39,11 @@ class GatherAccountsFilter: @staticmethod def windows_filter(info): - # TODO + info = info[4:-2] result = {} + for i in info: + for username in i.split(): + result[username] = {} return result def run(self, method_id_meta_mapper, info): From 5bd40fcd224a14927d8a7c573a214a47d4a57260 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Mon, 31 Oct 2022 19:27:45 +0800 Subject: [PATCH 2/2] fix: swagger --- apps/acls/models/login_asset_acl.py | 2 +- apps/assets/api/account/account.py | 2 +- apps/assets/filters.py | 2 +- apps/authentication/serializers/connection_token.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/acls/models/login_asset_acl.py b/apps/acls/models/login_asset_acl.py index 3425ac8de..37bea242a 100644 --- a/apps/acls/models/login_asset_acl.py +++ b/apps/acls/models/login_asset_acl.py @@ -64,7 +64,7 @@ class LoginAssetACL(BaseACL, OrgModelMixin): Q(assets__hostname_group__contains=asset.name) | Q(assets__hostname_group__contains='*') ) - ids = [q.id for q in queryset if contains_ip(asset.ip, q.assets.get('ip_group', []))] + ids = [q.id for q in queryset if contains_ip(asset.address, q.assets.get('ip_group', []))] queryset = cls.objects.filter(id__in=ids) return queryset diff --git a/apps/assets/api/account/account.py b/apps/assets/api/account/account.py index 4aef92de0..94b29995f 100644 --- a/apps/assets/api/account/account.py +++ b/apps/assets/api/account/account.py @@ -26,7 +26,7 @@ class AccountViewSet(OrgBulkModelViewSet): } rbac_perms = { 'verify': 'assets.test_account', - 'partial_update': 'assets.change_assetaccountsecret', + 'partial_update': 'assets.change_accountsecret', } @action(methods=['post'], detail=True, url_path='verify') diff --git a/apps/assets/filters.py b/apps/assets/filters.py index 2af062718..de2550ceb 100644 --- a/apps/assets/filters.py +++ b/apps/assets/filters.py @@ -142,7 +142,7 @@ class IpInFilterBackend(filters.BaseFilterBackend): if not ips: return queryset ip_list = [i.strip() for i in ips.split(',')] - queryset = queryset.filter(ip__in=ip_list) + queryset = queryset.filter(address__in=ip_list) return queryset def get_schema_fields(self, view): diff --git a/apps/authentication/serializers/connection_token.py b/apps/authentication/serializers/connection_token.py index 8f36ddc2b..e809ed78c 100644 --- a/apps/authentication/serializers/connection_token.py +++ b/apps/authentication/serializers/connection_token.py @@ -113,7 +113,7 @@ class ConnectionTokenAssetSerializer(serializers.ModelSerializer): """ Asset """ class Meta: model = Asset - fields = ['id', 'name', 'ip', 'protocols', 'org_id'] + fields = ['id', 'name', 'address', 'protocols', 'org_id'] class ConnectionTokenAccountSerializer(serializers.ModelSerializer):