@@ -59,6 +59,7 @@ def normalize_sqlmap_result(raw: dict) -> dict:
5959 return result
6060
6161
62+ # 轮询获取运行状态信息
6263@shared_task (
6364 bind = True ,
6465 autoretry_for = (Exception ,),
@@ -105,28 +106,30 @@ def poll_single_sqlmap_task(self, task_id: str):
105106 result_resp .raise_for_status ()
106107 data = result_resp .json ()
107108
108- # 展平sqlmap返回日志
109- normalized = normalize_sqlmap_result (data )
110-
111- print (normalized )
112-
113- # 解析 sqlmap 返回
114- scan_result = SqlmapScanResult (
115- target_url = normalized ["data" ]["target" ]["url" ],
116- dbms = normalized ["data" ]["dbms" ].get ("name" ),
117- vulnerable = bool (normalized ["data" ]["injections" ]),
118- injection_points = normalized ["data" ]["injections" ],
119- dump_data = None , # 后续支持 sqlmap dump 再填
120- raw_output = normalized ,
121- command = "" ,
122- started_at = datetime .utcnow (),
123- finished_at = datetime .utcnow (),
124- )
125-
126- session .add (scan_result )
127- task .status = ScanStatus .success
128-
129- session .commit ()
109+ print (data )
110+
111+ # # 展平sqlmap返回日志
112+ # normalized = normalize_sqlmap_result(data)
113+ #
114+ # print(normalized)
115+ #
116+ # # 解析 sqlmap 返回
117+ # scan_result = SqlmapScanResult(
118+ # target_url=normalized["data"]["target"]["url"],
119+ # dbms=normalized["data"]["dbms"].get("name"),
120+ # vulnerable=bool(normalized["data"]["injections"]),
121+ # injection_points=normalized["data"]["injections"],
122+ # dump_data=None, # 后续支持 sqlmap dump 再填
123+ # raw_output=normalized,
124+ # command="",
125+ # started_at=datetime.utcnow(),
126+ # finished_at=datetime.utcnow(),
127+ # )
128+ #
129+ # session.add(scan_result)
130+ # task.status = ScanStatus.success
131+ #
132+ # session.commit()
130133
131134 except Exception :
132135 session .rollback ()
@@ -164,9 +167,10 @@ def sqlmap_scan_task(self, payload: dict):
164167 # 3. 扫描启动成功后,调用 celery_task_add 写入 DB
165168 celery_task_add (
166169 session = session ,
167- task_id = self .request .id , # Celery 任务 ID
170+ task_id = sqlmap_task_id ,
171+ celery_task_id = self .request .id , # Celery 任务 ID
168172 scan_url = str (payload ["url" ]), # 转成 str,防止 HttpUrl 错误
169- status = "RUNNING " ,
173+ status = "running " ,
170174 scan_risk = payload .get ("risk" , 1 ),
171175 scan_level = payload .get ("level" , 1 ),
172176 )
0 commit comments