修改了bug
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { tool } from 'langchain';
|
||||
import * as z from 'zod';
|
||||
import { checkUrlAllowed } from './url_guard.js';
|
||||
|
||||
export const httpGetTool = tool(
|
||||
async ({ url, headers = {}, timeout = 30000 }) => {
|
||||
try {
|
||||
new URL(url);
|
||||
} catch (e) {
|
||||
return JSON.stringify({ success: false, error: `Invalid URL: ${url}` });
|
||||
// SSRF 防护:仅允许 http/https 且目标不得为环回/内网地址
|
||||
const blocked = checkUrlAllowed(url);
|
||||
if (blocked) {
|
||||
return JSON.stringify({ success: false, error: blocked });
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user