diff --git a/dev_log/V3.5.16/pagezhou_202007011630.yml b/dev_log/V3.5.16/pagezhou_202007011630.yml deleted file mode 100644 index c450b384d2..0000000000 --- a/dev_log/V3.5.16/pagezhou_202007011630.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfix: - - 修复BK-发送通知插件v1.0版本的通知方式参数勾选到全局变量时,在新建任务填写参数页面不显示的问题 diff --git a/dev_log/dev/homholueng_202008171837.yaml b/dev_log/dev/homholueng_202008171837.yaml new file mode 100644 index 0000000000..041688d214 --- /dev/null +++ b/dev_log/dev/homholueng_202008171837.yaml @@ -0,0 +1,2 @@ +bugfix: + - 修复无权限返回数据中实例信息没有父层级的问题 \ No newline at end of file diff --git a/iam/utils.py b/iam/utils.py index 453fb7c82c..d60f70fc7f 100644 --- a/iam/utils.py +++ b/iam/utils.py @@ -73,17 +73,32 @@ def gen_perms_apply_data(system, subject, action_to_resources_list): instances = [] for resources in resources_list: - instances.append( - [ + for resource in resources: + inst_item = [] + topo_path = resource.attribute.get("_bk_iam_path_") + + if topo_path: + for part in topo_path[1:-1].split("/"): + rtype, rid = part.split(",") + inst_item.append( + { + "type": rtype, + "type_name": meta.get_resource_name(system_id, rtype), + "id": rid, + "name": part, + } + ) + + inst_item.append( { "type": resource.type, "type_name": meta.get_resource_name(system_id, resource.type), "id": resource.id, "name": resource.attribute.get("name", "") if resource.attribute else "", } - for resource in resources - ] - ) + ) + + instances.append(inst_item) resource_types["instances"] = instances related_resource_types.append(resource_types)