Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(ssrf): unset SSRF_ALLOWED_HOSTS when it was unset before

Yudhi Armyndharisf7c1fcf59bfb
diff --git a/src/common/security/ssrf-guard.spec.ts b/src/common/security/ssrf-guard.spec.ts
index 14b1183c2..ab5983e22 100644
--- a/src/common/security/ssrf-guard.spec.ts
+++ b/src/common/security/ssrf-guard.spec.ts
@@ -772,7 +772,9 @@ describe('withSafeFetch followRedirects validates every hop over real sockets',
});
afterEach(() => {
- process.env.SSRF_ALLOWED_HOSTS = savedAllowedHosts;
+ // Assigning undefined to process.env stores the string 'undefined', an allowlist entry of its own.
+ if (savedAllowedHosts === undefined) delete process.env.SSRF_ALLOWED_HOSTS;
+ else process.env.SSRF_ALLOWED_HOSTS = savedAllowedHosts;
(undiciFetch as unknown as jest.Mock).mockReset();
});