From 9fecbdc158a494200e2f8e165fed4a0570c6a70c Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Mon, 21 Jul 2025 20:26:35 +0800 Subject: [PATCH] feat: use generic error message for denied hosts in HTTP node --- packages/components/nodes/agentflow/HTTP/HTTP.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/components/nodes/agentflow/HTTP/HTTP.ts b/packages/components/nodes/agentflow/HTTP/HTTP.ts index e18751db0..5a6920edb 100644 --- a/packages/components/nodes/agentflow/HTTP/HTTP.ts +++ b/packages/components/nodes/agentflow/HTTP/HTTP.ts @@ -233,14 +233,21 @@ class HTTP_Agentflow implements INode { } private isDeniedIP(ip: string, denyList: string[]): void { + const parsedIp = ipaddr.parse(ip) for (const entry of denyList) { if (entry.includes('/')) { try { - if (ipaddr.parse(ip).match(ipaddr.parseCIDR(entry))) throw new Error(`IP given is in deny list: ${ip}`) + const [range, _] = entry.split('/') + const parsedRange = ipaddr.parse(range) + if (parsedIp.kind() === parsedRange.kind()) { + if (parsedIp.match(ipaddr.parseCIDR(entry))) { + throw new Error('Access to this host is denied by policy.') + } + } } catch (error) { throw new Error(`isDeniedIP: ${error}`) } - } else if (ip === entry) throw new Error(`IP given is in deny list: ${ip}`) + } else if (ip === entry) throw new Error('Access to this host is denied by policy.') } } @@ -253,8 +260,6 @@ class HTTP_Agentflow implements INode { const hostname = urlObj.hostname - if (httpDenyList.includes(hostname)) throw new Error(`Hostname given is in deny list: ${hostname}`) - if (ipaddr.isValid(hostname)) { this.isDeniedIP(hostname, httpDenyList) } else {