Skip to main content

glovebox-hosts

The one answer to "which host is this" that every part of glovebox uses: the egress proxy's verdict service, the launcher, the WebFetch hook, the session driver and the evals.

A host is compared in one spelling: ASCII only, surrounding whitespace removed, lowercased, and an IP literal in its standard form. A name that is not ASCII, or that starts or ends with a dot, is refused with HostError rather than folded, so two readers can never disagree about it.

>>> from glovebox_hosts import canonical_host, split_authority, granting_entries
>>> split_authority("[2001:DB8::1]:443")
('2001:db8::1', 443)
>>> granting_entries("API.example.com", ["example.com"])
['example.com']
>>> granting_entries("a.b.example.com", ["example.com"])
[]

A grant on a name reaches that host alone, and a *.S grant every name below S. A bar (constraining_entries) reaches any depth. A grant may not name a *. wildcard over a public suffix, or over a name with one below it (suffix_below): grant_name_refusal says why, reading the Public Suffix List that tldextract bundles. A grant on a public suffix itself is allowed, since it reaches that one host. That is the package's one dependency, and it is imported only when a grant name is judged.

pod_grants reads a Kata pod's glovebox.dev/egress-grants annotation as every node reads it, so an admission webhook can refuse a pod at submission for the same reason the node would refuse it later. It returns the granted hosts at their tiers, the address grants and the port grants, and raises GrantRefused with the node's own message for the first entry the node refuses. How wide an address grant may be is each node's own setting, so it is not checked here.

A Kubernetes node also refuses an address grant by range. refused_block(network, cluster_ranges(cidrs)) returns the block that a node refuses, or None. Here cidrs is the node's --cluster-cidr list, as a tuple of ipaddress.ip_network values. ALWAYS_REFUSED holds the ranges no node grants, such as loopback, link-local and multicast. cluster_ranges adds the named cluster ranges, and every private range of each IP version the list does not name. The node also refuses its own addresses, which only the node knows.

A host with a port, such as {"host": "git.example.com:22", "rw": true}, is a port grant. The node relays a raw stream to that port on the name's public addresses, so it needs "rw": true. A host without a port keeps its plain host meaning.

>>> from glovebox_hosts import GrantRefused, pod_grants
>>> granted = pod_grants('["httpbin.org", {"host": "git.example.com:22", "rw": true}]')
>>> granted.hosts
{'httpbin.org': 'ro'}
>>> granted.ports
[PortGrant(host='git.example.com', port=22)]
>>> pod_grants('["*.amazonaws.com"]')
Traceback (most recent call last):
...
glovebox_hosts.GrantRefused: glovebox.dev/egress-grants: '*.amazonaws.com' is a wildcard over a name with the public suffix ...

encode_pod_grants is the writer for the same annotation. It writes each entry as a bare read-only string, sorted and once, and never adds "rw". It raises GrantRefused for an address or HOST:PORT, which opens a raw tunnel that only a person grants, read-write, on the node. It reads its text back with pod_grants, so it also raises for any other entry the node would refuse.

glovebox_hosts.flock holds an exclusive file lock: held for a block, or acquire and release when the hold spans two calls. It lives here because the host tools and the monitor package can both import it.

Metadata

Release files for glovebox-hosts 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glovebox-hosts 0.9.1
File Size Uploaded Provenance Actions
glovebox_hosts-0.9.1.tar.gz 28.3 kB Without provenance Details for glovebox_hosts-0.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glovebox-hosts 0.9.1
File Interpreter ABI Platform Actions
glovebox_hosts-0.9.1-py3-none-any.whl Python 3 none any Details for glovebox_hosts-0.9.1-py3-none-any.whl

Total release size: 58.6 kB

Release files / glovebox_hosts-0.9.1.tar.gz

Download URL glovebox_hosts-0.9.1.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a64660ba5fb940c995bc139d2ec5441ee6eb87ef7f513cd2ad7cc88e2e7b4abe
BLAKE2b-256 checksum
How to use checksums
1311ebe639e89db3aa4a530a353f5bab66ff8b22b63b79a03bbc026ae5b9e048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / glovebox_hosts-0.9.1-py3-none-any.whl

Download URL glovebox_hosts-0.9.1-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c01ecb41419ea6847bda174b3d33a42106380f1f561562f34838ce55b5a666a7
BLAKE2b-256 checksum
How to use checksums
305ff3a443b840d9cdb1e88500d3b1311153c7393bbb92b215e858f6bfba9b27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for glovebox-hosts 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page