调用服务器接口关闭Analyse Server的scan
(cls, job_id, **kwargs)
| 318 | |
| 319 | @classmethod |
| 320 | def close_scan(cls, job_id, **kwargs): |
| 321 | """调用服务器接口关闭Analyse Server的scan |
| 322 | """ |
| 323 | # 拼接参数 |
| 324 | job = models.Job.objects.get(id=job_id) |
| 325 | if not job.scan_id: |
| 326 | logger.error("[Job: %d] 无scan_id可以关闭..." % job_id) |
| 327 | return |
| 328 | data = { |
| 329 | "job": { |
| 330 | "context_url": job.context_path, |
| 331 | "result_code": job.result_code or errcode.OK, # 如无则为成功 |
| 332 | "result_msg": job.result_msg, |
| 333 | }, |
| 334 | "tasks": [{ |
| 335 | "module": task.module, |
| 336 | "name": task.task_name, |
| 337 | "execute_version": task.execute_version, |
| 338 | "params_url": task.params_path, |
| 339 | "result_code": task.result_code, |
| 340 | "result_msg": task.result_msg, |
| 341 | "result_data_url": task.result_path, |
| 342 | "log_url": task.log_url |
| 343 | } for task in job.task_set.all()] |
| 344 | } |
| 345 | if kwargs.get("reset") is True: |
| 346 | data["reset"] = True |
| 347 | if kwargs.get("sync"): |
| 348 | data["sync_flag"] = True |
| 349 | if kwargs.get("force"): |
| 350 | data["force"] = True |
| 351 | logger.info("调用AnalyseServer结束Scan,参数如下:") |
| 352 | logger.info(json.dumps(data, indent=4)) |
| 353 | analyse_client = AnalyseClient() |
| 354 | analyse_client.api("close_scan", data=data, |
| 355 | path_params=(job.project.id, job.scan_id)) |
| 356 | |
| 357 | @classmethod |
| 358 | def close_job(cls, job_id, reclose=False): |
no test coverage detected