(task_name, task_target, task_type, task_tag, options)
| 47 | |
| 48 | |
| 49 | def build_task_data(task_name, task_target, task_type, task_tag, options): |
| 50 | |
| 51 | # 检查是不是IP ,域名任务等 |
| 52 | avail_task_type = [TaskType.IP, TaskType.DOMAIN, TaskType.RISK_CRUISING] |
| 53 | if task_type not in avail_task_type: |
| 54 | raise Exception("{} 无效的 task_type".format(task_type)) |
| 55 | |
| 56 | # 检查是不是风险巡航任务等 |
| 57 | avail_task_tag = [TaskTag.RISK_CRUISING, TaskTag.MONITOR, TaskTag.TASK] |
| 58 | if task_tag not in avail_task_tag: |
| 59 | raise Exception("{} 无效的 task_tag".format(task_type)) |
| 60 | |
| 61 | if not isinstance(options, dict): |
| 62 | raise Exception("{} 不是 dict".format(options)) |
| 63 | |
| 64 | options_cp = options.copy() |
| 65 | |
| 66 | # 针对IP 任务关闭下面的选项 |
| 67 | if task_type == TaskType.IP: |
| 68 | disable_options = { |
| 69 | "domain_brute": False, |
| 70 | "alt_dns": False, |
| 71 | "dns_query_plugin": False, |
| 72 | "arl_search": False |
| 73 | } |
| 74 | options_cp.update(disable_options) |
| 75 | |
| 76 | task_data = { |
| 77 | 'name': task_name, |
| 78 | 'target': task_target, |
| 79 | 'start_time': '-', |
| 80 | 'status': TaskStatus.WAITING, |
| 81 | 'type': task_type, |
| 82 | "task_tag": task_tag, |
| 83 | 'options': options_cp, |
| 84 | "end_time": "-", |
| 85 | "service": [], |
| 86 | "celery_id": "" |
| 87 | } |
| 88 | |
| 89 | # 单独对风险巡航任务处理 |
| 90 | if task_tag == TaskType.RISK_CRUISING: |
| 91 | poc_config = options.get("poc_config", []) |
| 92 | |
| 93 | if options.get("result_set_id"): |
| 94 | result_set_id = options.pop("result_set_id") |
| 95 | result_set_len = options.pop("result_set_len") |
| 96 | target_field = "目标:{}, PoC:{}".format(result_set_len, len(poc_config)) |
| 97 | task_data["result_set_id"] = result_set_id |
| 98 | else: |
| 99 | target_field = "目标:{}, PoC:{}".format(len(task_target), len(poc_config)) |
| 100 | task_data["cruising_target"] = task_target |
| 101 | |
| 102 | task_data["target"] = target_field |
| 103 | |
| 104 | return task_data |
| 105 | |
| 106 |
no test coverage detected