Skip to content

Commit 8312093

Browse files
committed
update test cases
1 parent 8ba5b8d commit 8312093

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

aikido_zen/sinks/tests/socket_test.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_socket_getaddrinfo_block_all_new_requests():
107107
def test_socket_getaddrinfo_no_cache():
108108
"""Test that getaddrinfo works normally when cache is not available"""
109109
# Mock get_cache to return None
110-
with patch("aikido_zen.sinks.socket.report_and_check_hostname.get_cache", return_value=None):
110+
with patch("aikido_zen.thread.thread_cache.get_cache", return_value=None):
111111
# Test that allowed domain doesn't throw an error when cache is unavailable
112112
try:
113113
socket.getaddrinfo("localhost", 80)
@@ -255,3 +255,28 @@ def test_socket_getaddrinfo_ip_address_as_hostname():
255255
assert hostnames[0]["hostname"] == "8.8.8.8"
256256
assert hostnames[0]["port"] == 53
257257
assert hostnames[0]["hits"] == 1
258+
259+
260+
def test_punycode_normalization():
261+
# Reset cache and set up blocking
262+
cache = get_cache()
263+
cache.reset()
264+
cache.config.update_domains(
265+
[
266+
{"hostname": "ssrf-rédirects.testssandbox.com", "mode": "block"},
267+
]
268+
)
269+
270+
with pytest.raises(Exception) as exc_info:
271+
socket.getaddrinfo("xn--ssrf-rdirects-ghb.testssandbox.com", 80)
272+
assert (
273+
"Zen has blocked an outbound connection to ssrf-rédirects.testssandbox.com"
274+
in str(exc_info.value)
275+
)
276+
277+
with pytest.raises(Exception) as exc_info:
278+
socket.getaddrinfo("ssrf-rédirects.testssandbox.com", 80)
279+
assert (
280+
"Zen has blocked an outbound connection to ssrf-rédirects.testssandbox.com"
281+
in str(exc_info.value)
282+
)

0 commit comments

Comments
 (0)