From 64d57f4cf2f8644b4bb5620775b09987a0537325 Mon Sep 17 00:00:00 2001 From: Hans Ott Date: Wed, 18 Dec 2024 14:41:10 +0100 Subject: [PATCH] Improved comment --- library/sinks/HTTPRequest.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/library/sinks/HTTPRequest.ts b/library/sinks/HTTPRequest.ts index 253b46bf..7ed3a752 100644 --- a/library/sinks/HTTPRequest.ts +++ b/library/sinks/HTTPRequest.ts @@ -148,7 +148,9 @@ export class HTTPRequest implements Wrapper { wrapResponseHandler(args: unknown[], module: "http" | "https") { // Wrap the response handler if there is one // so that we can inspect the response for SSRF attacks (using redirects) - // e.g. http.request("http://example.com", (response) => {}) + // e.g. http.request("http://example.com", (response) => {...}) + // ^^^^^^^^^^^^^^^^^^^ + // We want to wrap this callback return args.map((arg) => { if (typeof arg === "function") { return wrapResponseHandler(args, module, arg); @@ -171,11 +173,13 @@ export class HTTPRequest implements Wrapper { // so that we can inspect the response for SSRF attacks (using redirects) // You can add listeners in multiple ways: - // http.request("http://example.com").on("response", (response) => {}) - // http.request("http://example.com").addListener("response", (response) => {}) - // http.request("http://example.com").once("response", (response) => {}) - // http.request("http://example.com").prependListener("response", (response) => {}) - // http.request("http://example.com").prependOnceListener("response", (response) => {}) + // http.request("http://example.com").on("response", (response) => {...}) + // ^^^^^^^^^^^^^^^^^^^ + // We want to wrap this callback + // http.request("http://example.com").addListener("response", (response) => {...}) + // http.request("http://example.com").once("response", (response) => {...}) + // http.request("http://example.com").prependListener("response", (response) => {...}) + // http.request("http://example.com").prependOnceListener("response", (response) => {...}) const methods = [ "on", "addListener",