Skip to content

Commit f852b50

Browse files
committed
fix(ExploitDbController): 添加关键词检测以识别请求被阻止的情况
在异常处理中添加对防火墙、访问限制等关键词的检测,以便更准确地识别请求被阻止的情况并输出更有帮助的错误信息
1 parent e7a9fdd commit f852b50

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/java/xin/ctkqiang/controller/ExploitDbController.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.net.http.HttpRequest;
77
import java.net.http.HttpResponse;
88
import java.util.ArrayList;
9+
import java.util.Arrays;
910
import java.util.List;
1011

1112
import xin.ctkqiang.dto.Exploit;
@@ -35,6 +36,9 @@ public class ExploitDbController extends DatabaseController {
3536
/** JSON解析器,用于处理API响应数据 */
3637
private ObjectMapper Mapper = new ObjectMapper();
3738

39+
private static final List<String> BLOCK_KEYWORDS = Arrays.asList(
40+
"firewall", "access denied", "blocked", "forbidden", "connection refused");
41+
3842
/**
3943
* 获取数据库中所有的漏洞信息
4044
*
@@ -215,8 +219,13 @@ public void Crawl(int pageSize, boolean isExport, String extension) {
215219
}
216220

217221
} catch (IOException | InterruptedException e) {
218-
// 处理网络请求或数据处理过程中的异常
219-
System.err.println("爬取 Exploit-DB 时出错:" + e.getMessage());
222+
String msg = e.getMessage();
223+
224+
if (msg != null && BLOCK_KEYWORDS.stream().anyMatch(k -> msg.toLowerCase().contains(k))) {
225+
System.err.println("爬取 Exploit-DB : ⚠️ 请求被阻止,可能遭遇防火墙、访问限制或代理问题,请检查网络配置。");
226+
} else {
227+
System.err.println("爬取 Exploit-DB 时出错:" + msg);
228+
}
220229
}
221230

222231
// 显示最终的爬取结果

0 commit comments

Comments
 (0)