google/tsunami-security-scanner · error · ValueError
Invalid address family
Error message
Invalid address family: %s
What it means
get_address_family() converts a Python socket.AddressFamily to Tsunami's AddressFamily enum and raises ValueError for anything other than AF_INET or AF_INET6. Only IPv4 and IPv6 families are supported when building URIs from a NetworkService.
Solutions
- Only call get_address_family for TCP/UDP services with AF_INET or AF_INET6 addresses.
- Filter out non-IP network services (e.g. AF_UNIX) before URI construction.
- Inspect the service's address_family value and map any new family explicitly if upstream adds support.
Example fix
// before
family = network_service_utils.get_address_family(service.address_family)
// after
if service.address_family in (socket.AF_INET, socket.AF_INET6):
family = network_service_utils.get_address_family(service.address_family) Defensive patterns
Strategy: type-guard
Validate before calling
if service.address_family not in (socket.AF_INET, socket.AF_INET6): raise SkipService
Type guard
def has_ip_family(service) -> bool:
return service.address_family in (socket.AF_INET, socket.AF_INET6) Try / catch
try:
family = network_service_utils.get_address_family(service.address_family)
except ValueError as e:
logging.warning("Unsupported address family: %s", e)
family = None Prevention
- Only construct NetworkServices from AF_INET/AF_INET6 sockets.
- Filter out unix/link-layer services before URI building.
- Keep tests aligned with supported address families.
When it happens
Trigger: Calling get_address_family (directly or via build_uri_network_service) with a socket address family such as AF_UNIX or AF_LINK at network_service_utils.py:184.
Common situations: Network services derived from Unix-domain sockets or link-layer addresses; tests constructing NetworkService with a default/invalid AddressFamily; platform-specific address families leaking into scan data.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Invalid network service
- URI scheme should be one of the following: 'http', 'https'
- Name cannot be None.
- Value cannot be None.
- Illegal header name .
AI-assisted analysis of google/tsunami-security-scanner@363ba87b35 (2026-09-13).
Data as JSON: /api/errors/3cd40870a4d11169.
Report an issue: GitHub.
Appendix: source
Thrown at plugin_server/py/common/data/network_service_utils.py:184
def build_web_app_root_path(network_service: NetworkService) -> str:
if network_service.service_context:
root_path = network_service.service_context.web_service_context.application_root
else:
root_path = "/"
if not root_path.startswith("/"):
root_path = "/" + root_path
if not root_path.endswith("/"):
root_path = root_path + "/"
return root_path
def get_address_family(address_family: socket.AddressFamily) -> AddressFamily:
if address_family == socket.AF_INET:
return AddressFamily.IPV4
elif address_family == socket.AF_INET6:
return AddressFamily.IPV6
else:
raise ValueError("Invalid address family: %s" % address_family)
def sanitize_port(port: Optional[int], scheme: str) -> int:
if isinstance(port, type(None)):
return get_port(-1, scheme)
return get_port(port, scheme)
def get_port(port: int, scheme: str) -> int:
if port >= 0:
return port
return 80 if scheme == "http" else 443
def validate_scheme(scheme: str) -> None:
if scheme == "http" or scheme == "https":
pass
else:View on GitHub (pinned to 363ba87b35)