In a local network environment with local hostname defined manually (e.g: internal docker container networks), settings only_global_lookup=True does not reject capture.
Both situation are "manually defined hostname":
- editing
/etc/hosts (or equivalent) and with an entry like my-local-service 172.18.0.1
- accessing containers in a docker (or equivalent) infrastructure using their container-name
Capturing http://my-local-service:8080 will succeed if my-local-service serves 8080 port, even if only_global_lookup=True.
The fact is try_into_ip just try to parse the "string" into an ip address. This does not "resolve" the potential hostname into its ip equivalent.
|
try: |
|
ip = ipaddress.ip_address(_url.host.try_into_ip()) |
|
if ip.is_global: |
|
return True, "Global IP" |
|
# Non-global IP |
|
self.logger.warning(f"Attempt to open a non-public IP: {url}") |
|
return False, f"Attempted to open {url}, blocked." |
|
except ValueError: |
|
# not an IP, continue to hostname |
|
pass |
An hostname resolve round should be performed. (E.g: with addr_info = socket.getaddrinfo(host, None))
Or if it's the intended behavior, the documentation should mention that no hostname ip resolution is performed while setting only_global_lookup=True.
Regards
In a local network environment with local hostname defined manually (e.g: internal docker container networks), settings
only_global_lookup=Truedoes not reject capture.Both situation are "manually defined hostname":
/etc/hosts(or equivalent) and with an entry likemy-local-service 172.18.0.1Capturing
http://my-local-service:8080will succeed ifmy-local-serviceserves 8080 port, even ifonly_global_lookup=True.The fact is
try_into_ipjust try to parse the "string" into an ip address. This does not "resolve" the potential hostname into its ip equivalent.PlaywrightCapture/playwrightcapture/capture.py
Lines 1226 to 1235 in ebdf999
An
hostnameresolve round should be performed. (E.g: withaddr_info = socket.getaddrinfo(host, None))Or if it's the intended behavior, the documentation should mention that no hostname ip resolution is performed while setting
only_global_lookup=True.Regards