docs(permissions): correct the network pattern form - #1910
Open
wasaybuilds wants to merge 1 commit into
Open
Conversation
Network permission resources are formatted as URIs — tcp://host:port for fetch/http/listen and dns://hostname for dns — and patterns are matched against that whole string by a path glob whose single * does not cross /. The docs described a pattern as "a host (or host:port)" and the shipped allow-one-host example used a bare host, so the documented policy matched nothing: an allowlist denied everything and a blocklist permitted every host. Documents the URI form, fixes the example, and pins the semantics with a kernel test so the documented shape has coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1884, where
networkrules were reported as inert in both directions. The rules are evaluated; they just never match.format_tcp_resourcegivestcp://{host}:{port}for fetch/http/listen,format_dns_resourcegivesdns://{hostname}— andpermission_resource_matchesglobs the pattern against that whole string withpermission_glob_matches, where a single*does not cross/.permissions.mdxsaid a network pattern is "a host (orhost:port)", and the shippedallow-one-hostexample usedpatterns: ["api.example.com"]. Neither form can ever match, so a documented allowlist denies everything and a documented blocklist permits every host.tcp://api.example.com:*/dns://api.example.com, and adds a kernel test pinning the semantics — the existing network-pattern coverage only uses the URI form, which is why CI stayed green while the documented form was broken.Matcher behaviour against
tcp://api.example.com:443, verified by portingpermission_glob_matchesbyte-for-byte to JS and running the matrix:This only corrects the documentation to describe what the matcher does. If you would rather the matcher accept a bare
host/host:port— which would make every policy written from the old docs start working — that is the alternative fix and I am happy to send it instead; I left the permission matcher alone since it is the security boundary.I could not run
cargo testlocally (no Rust toolchain on this machine), so the added test needs CI. Every assertion in it was checked against the ported matcher first.