feat(net): support the '*' wildcard in --net-allow-bind#137
Conversation
|
Traced the Landlock path end-to-end — the bind-access semantics are exactly right: A few non-blocking notes:
Nit: |
|
Thanks for your review. I have addressed them and refactored the FFI API together too. |
Signed-off-by: Cong Wang <cwang@multikernel.io>
b405fcd to
68a50a3
Compare
|
Re-read the update — all cleanly addressed, and asserting |
Closes #133.
--net-allow-bind '*'allows the sandbox to bind any TCP port, including an ephemeralbind(0), while the rest of the network policy stays active. Previously the only way to approximate this was--net-allow-bind 0-65535, which installs 65536 individual Landlock rules.Sandbox.net_allow_bindbecomes aBindPortsenum (Ports(Vec<u16>)orAll); pre-1.0 hard break.*with port lists is rejected at build time, as is*in--net-deny-bind; repeating the bare wildcard is idempotent. Mutual exclusion with--net-deny-bindis unchanged.AlldropsLANDLOCK_ACCESS_NET_BIND_TCPfrom the handled access set (the same mechanism--net-deny-bindalready uses), so no per-port rules are installed. Connect-side handling is untouched.sandlock_sandbox_builder_net_allow_bind_port/net_deny_bind_portare removed in favor of spec-string entriessandlock_sandbox_builder_net_allow_bind(spec)/net_deny_bind(spec), matching hownet_allow/net_denyalready work. Port-spec grammar and the wildcard rule are parsed and validated in one place (the core builder); the Python and Go SDKs forward specs verbatim, and their local port/wildcard parsing (bind_all()/bind_ports()/deny_bind_ports(), GoParsePorts/HasPortWildcard) is deleted.allow_bind = ["*"]), the C ABI, the Python SDK (net_allow_bind=["*"]), and the Go SDK (NetAllowBind: []string{"*"}).net_allowenforcers); Python config/profile/end-to-end tests; a Go end-to-end wildcard test.🤖 Generated with Claude Code