Skip to main content

Module network

Module network 

Source
Expand description

Outbound network allowlist / denylist for HTTP tools.

Applied to tools that open arbitrary or fixed remote URLs (webfetch, websearch, GitHub REST helpers). Shell network remains binary (security.sandbox_network); domain filtering for shell would need a userspace proxy and is out of scope here.

§Semantics

  • Empty allowlist → all hosts allowed (subject to denylist).
  • Non-empty allowlist → host must match at least one pattern.
  • Denylist always wins over allowlist.

§Pattern syntax

  • example.com — apex and any subdomain (api.example.com).
  • *.example.com — subdomains only (not the apex).
  • * — match any host.

Matching is case-insensitive. Ports and userinfo are stripped before match.

Structs§

NetworkPolicy
Resolved network policy carried on crate::ToolContext.

Functions§

host_from_url
Extract hostname from an http:// or https:// URL.
host_matches_pattern
Whether host matches a single pattern (see module docs).
normalize_host
Lowercase host, strip trailing dots and IPv6 brackets.
parse_domain_list
Split a comma- or whitespace-separated env list into patterns.