获取工具任务参数
(languages, labels, input_params)
| 64 | |
| 65 | @staticmethod |
| 66 | def get_scan_tasks(languages, labels, input_params): |
| 67 | """获取工具任务参数""" |
| 68 | tasks = [] |
| 69 | # 使用标签指定工具规则类型(标签优先使用命令行参数,其次从 input_params 中获取) |
| 70 | if not labels: |
| 71 | labels = input_params.get("labels", []) |
| 72 | if labels: |
| 73 | for label in labels: |
| 74 | config_dir = os.path.join(settings.TOOL_BASE_DIR, f"quickscan/tasks/{label}") |
| 75 | if not os.path.exists(config_dir): |
| 76 | raise NodeError(code=E_NODE_TASK_CONFIG, |
| 77 | msg=f"config dir({config_dir}) not exist, please init tca.") |
| 78 | new_task_json_files = QuickScan.get_task_json_files(config_dir, languages) |
| 79 | |
| 80 | new_tasks = [] |
| 81 | for file_path in new_task_json_files: |
| 82 | if not file_path.endswith(".json"): |
| 83 | continue |
| 84 | with open(file_path, "r") as rf: |
| 85 | task_config = json.load(rf) |
| 86 | new_tasks.append(task_config) |
| 87 | # 不同的标签可能会包含同样的工具,这里通过merge合并相同工具 |
| 88 | tasks = QuickScan.merge_tasks(tasks, new_tasks) |
| 89 | else: |
| 90 | raise NodeError(code=E_NODE_TASK_CONFIG, msg=f"no label param, please specify lable by --label.") |
| 91 | # LogPrinter.info(f"----->>> tasks: {[task['task_name'] for task in tasks]}") |
| 92 | return tasks |
| 93 | |
| 94 | @staticmethod |
| 95 | def get_proj_config(scm_url, languages, labels, input_params): |
no test coverage detected