From f4c31d8e869ee1672c99861132fb3cd8a3ea02cc Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 25 Jul 2018 10:22:32 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/asset.py | 2 +- apps/perms/api.py | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/assets/models/asset.py b/apps/assets/models/asset.py index 7a2b3fe57..b26c50216 100644 --- a/apps/assets/models/asset.py +++ b/apps/assets/models/asset.py @@ -154,7 +154,7 @@ class Asset(models.Model): return False, warning def is_unixlike(self): - if self.platform not in ("Windows",): + if self.platform not in ("Windows", "Windows2016"): return True else: return False diff --git a/apps/perms/api.py b/apps/perms/api.py index 88be52fe2..66b7d8056 100644 --- a/apps/perms/api.py +++ b/apps/perms/api.py @@ -73,10 +73,7 @@ class UserGrantedAssetsApi(ListAPIView): util = AssetPermissionUtil(user) for k, v in util.get_assets().items(): - if k.is_unixlike(): - system_users_granted = [s for s in v if s.protocol in ['ssh', 'telnet']] - else: - system_users_granted = [s for s in v if s.protocol in ['rdp', 'telnet']] + system_users_granted = [s for s in v if s.protocol == k.protocol] k.system_users_granted = system_users_granted queryset.append(k) return queryset @@ -124,10 +121,7 @@ class UserGrantedNodesWithAssetsApi(ListAPIView): for node, _assets in nodes.items(): assets = _assets.keys() for k, v in _assets.items(): - if k.is_unixlike(): - system_users_granted = [s for s in v if s.protocol in ['ssh', 'telnet']] - else: - system_users_granted = [s for s in v if s.protocol in ['rdp', 'telnet']] + system_users_granted = [s for s in v if s.protocol == k.protocol] k.system_users_granted = system_users_granted node.assets_granted = assets queryset.append(node)