Fixed the issue of infinite loop outputting the same content in the Agent audit mode, and resolved the problem of incomplete display of the frontend Activity log in Agent audit mode.
Build and Push CodeReview / build (push) Waiting to run Details

This commit is contained in:
vinland100 2026-01-12 13:39:48 +08:00
parent 6c2a15ad90
commit a98e3e531b
3 changed files with 89 additions and 6 deletions

View File

@ -155,9 +155,28 @@ Thought: [总结所有发现]
Final Answer: [JSON 格式的漏洞报告]
```
## ⚠️ 输出格式要求(严格遵守
## 🚨🚨🚨 输出格式强制要求(违反将导致系统无法解析!
**禁止使用 Markdown 格式标记** 你的输出必须是纯文本格式
**关键规则完成分析时必须使用 "Final Answer:" 前缀**
### ✅ 正确的完成格式(必须遵守):
```
Thought: 分析完成共发现2个漏洞
Final Answer: {"findings": [...], "summary": "..."}
```
### ❌ 错误格式(系统无法识别,会导致无限循环!):
```json
{"findings": [...], "summary": "..."}
```
**禁止**
1. 直接输出 JSON 而不带 "Final Answer:" 前缀
2. 使用 ```json 代码块而不带 "Final Answer:" 前缀
3. 省略 "Final Answer:" 直接给出结论
4. 重复输出相同的 JSON 内容
**禁止使用 Markdown 格式标记**
正确
```

View File

@ -80,9 +80,28 @@ Thought: [总结收集到的所有信息]
Final Answer: [JSON 格式的结果]
```
## ⚠️ 输出格式要求(严格遵守
## 🚨🚨🚨 输出格式强制要求(违反将导致系统无法解析!
**禁止使用 Markdown 格式标记** 你的输出必须是纯文本格式
**关键规则完成信息收集时必须使用 "Final Answer:" 前缀**
### ✅ 正确的完成格式(必须遵守):
```
Thought: 信息收集完成项目使用Python/Django框架
Final Answer: {"project_structure": {...}, "tech_stack": {...}, ...}
```
### ❌ 错误格式(系统无法识别,会导致无限循环!):
```json
{"project_structure": {...}, "tech_stack": {...}}
```
**禁止**
1. 直接输出 JSON 而不带 "Final Answer:" 前缀
2. 使用 ```json 代码块而不带 "Final Answer:" 前缀
3. 省略 "Final Answer:" 直接给出结论
4. 重复输出相同的 JSON 内容
**禁止使用 Markdown 格式标记**
正确格式
```

View File

@ -223,9 +223,28 @@ Thought: [总结验证结果]
Final Answer: [JSON 格式的验证报告]
```
## ⚠️ 输出格式要求(严格遵守
## 🚨🚨🚨 输出格式强制要求(违反将导致系统无法解析!
**禁止使用 Markdown 格式标记** 你的输出必须是纯文本格式
**关键规则完成验证时必须使用 "Final Answer:" 前缀**
### ✅ 正确的完成格式(必须遵守):
```
Thought: 验证完成共确认2个漏洞
Final Answer: {"findings": [...], "summary": {...}}
```
### ❌ 错误格式(系统无法识别,会导致无限循环!):
```json
{"findings": [...], "summary": {...}}
```
**禁止**
1. 直接输出 JSON 而不带 "Final Answer:" 前缀
2. 使用 ```json 代码块而不带 "Final Answer:" 前缀
3. 省略 "Final Answer:" 直接给出结论
4. 重复输出相同的 JSON 内容
**禁止使用 Markdown 格式标记**
正确格式
```
@ -714,9 +733,35 @@ class VerificationAgent(BaseAgent):
if final_result and "findings" in final_result:
verified_count = len([f for f in final_result["findings"] if f.get("is_verified")])
fp_count = len([f for f in final_result["findings"] if f.get("verdict") == "false_positive"])
confirmed_count = len([f for f in final_result["findings"] if f.get("verdict") == "confirmed"])
likely_count = len([f for f in final_result["findings"] if f.get("verdict") == "likely"])
self.add_insight(f"验证了 {len(final_result['findings'])} 个发现,{verified_count} 个确认,{fp_count} 个误报")
self.record_work(f"完成漏洞验证: {verified_count} 个确认, {fp_count} 个误报")
# 🔥 FIX: 发送验证结果到 Activity Log让用户看到完成状态
await self.emit_event(
"info",
f"验证结果: {confirmed_count} 确认, {likely_count} 可能, {fp_count} 误报"
)
# 🔥 FIX: 为每个高危发现单独发送事件
for f in final_result["findings"]:
if isinstance(f, dict):
severity = f.get("severity", "medium")
verdict = f.get("verdict", "uncertain")
title = f.get("title", "未命名发现")[:60]
# 只为高危发现发送单独事件
if severity in ["critical", "high"] and verdict in ["confirmed", "likely"]:
await self.emit_finding(
title=title,
severity=severity,
vuln_type=f.get("vulnerability_type", "unknown"),
file_path=f.get("file_path", ""),
is_verified=(verdict == "confirmed")
)
await self.emit_llm_complete(
f"验证完成",
self._total_tokens