mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 21:35:18 +00:00
fix: validate debug proxy connect ports
This commit is contained in:
@@ -18,5 +18,7 @@ describe("parseConnectTarget", () => {
|
||||
|
||||
it("rejects invalid CONNECT ports", () => {
|
||||
expect(() => parseConnectTarget("[::1]:99999")).toThrow("Invalid CONNECT target port");
|
||||
expect(() => parseConnectTarget("api.openai.com:1e3")).toThrow("Invalid CONNECT target port");
|
||||
expect(() => parseConnectTarget("api.openai.com:0x50")).toThrow("Invalid CONNECT target port");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,6 +64,9 @@ export function parseConnectTarget(rawTarget: string | undefined): {
|
||||
}
|
||||
const hostname = trimmed.slice(0, lastColon).trim() || "127.0.0.1";
|
||||
const portText = trimmed.slice(lastColon + 1).trim();
|
||||
if (!/^\d+$/.test(portText)) {
|
||||
throw new Error("Invalid CONNECT target port");
|
||||
}
|
||||
const port = Number(portText);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
||||
throw new Error("Invalid CONNECT target port");
|
||||
|
||||
Reference in New Issue
Block a user