Skip to content

Commit

Permalink
Merge pull request #782 from bensonhome/main
Browse files Browse the repository at this point in the history
🐛修复localscan设置扫描目录后,分析方案配置的过滤路径不生效问题
  • Loading branch information
cyw3 authored Mar 6, 2023
2 parents 8fceb07 + 3ab2e08 commit 8d4ba18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
24 changes: 16 additions & 8 deletions client/node/localtask/filtermgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@

class FilterManager(object):
@staticmethod
def get_local_filtered_paths(include_paths, exclude_paths, dog_server, repo_id, proj_id, org_sid, team_name):
def get_local_filtered_paths(include_paths, exclude_paths, dog_server, repo_id, proj_id, org_sid, team_name, server_path_filters=None):
"""
从server端获取默认过滤路径,并与本地过滤路径参数合并,得到本地使用的过滤路径
:return:
"""
default_filtered_paths = dog_server.get_default_filtered_paths(repo_id, proj_id, org_sid, team_name)
return {
"inclusion": include_paths + default_filtered_paths["inclusion"],
"exclusion": exclude_paths + default_filtered_paths["exclusion"],
"re_inclusion": default_filtered_paths["re_inclusion"],
"re_exclusion": default_filtered_paths["re_exclusion"]
}
if server_path_filters: # server端有配置过滤路径,合并
return {
"inclusion": include_paths + server_path_filters.get("inclusion", []),
"exclusion": exclude_paths + server_path_filters.get("exclusion", []),
"re_inclusion": server_path_filters.get("re_inclusion", []),
"re_exclusion": server_path_filters.get("re_exclusion", [])
}
else: # server端未配置过滤路径(未传改参数,比如尚未创建项目),获取默认过滤路径后合并
default_filtered_paths = dog_server.get_default_filtered_paths(repo_id, proj_id, org_sid, team_name)
return {
"inclusion": include_paths + default_filtered_paths["inclusion"],
"exclusion": exclude_paths + default_filtered_paths["exclusion"],
"re_inclusion": default_filtered_paths["re_inclusion"],
"re_exclusion": default_filtered_paths["re_exclusion"]
}
5 changes: 3 additions & 2 deletions client/node/localtask/requestgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ def _get_execute_request_list(self, job_context, task_list, remote_task_names, c
"""获取本地执行的任务参数列表"""
execute_request_list = []

# 如果本地有指定过滤路径,与默认过滤路径合并使用
# 如果本地有指定过滤路径,与server配置的过滤路径合并使用
if self._exclude_paths or self._include_paths:
project_path_filters = FilterManager.get_local_filtered_paths(self._include_paths, self._exclude_paths,
self._dog_server, self._repo_id,
self._proj_id, self._org_sid, self._team_name)
self._proj_id, self._org_sid, self._team_name,
job_context["path_filters"])
else: # 否则,使用server上的配置的过滤路径
project_path_filters = job_context["path_filters"]

Expand Down

0 comments on commit 8d4ba18

Please sign in to comment.