fix(net): register provider and fix CIDR parity gaps - #194
Merged
sspaink merged 1 commit intoAug 10, 2026
Conversation
The BuiltinProvider entry for opa-builtins-net was commented out in its
META-INF/services file, so ServiceLoader never discovered it and none of
the seven net builtins were reachable for consumers.
Registering it exposed 13 failing compliance cases:
- net.cidr_merge gave a bare IPv4 address a /32. Go applies
net.IP.DefaultMask(), the classful default, so ["192.0.128.0",
"192.0.129.0"] merges to 192.0.128.0/23 rather than two /32s.
- net.cidr_merge threw AddressConversionException on mixed IPv4 and
IPv6 input, because mergeToPrefixBlocks cannot span versions. Each
version is now merged separately and the results unioned.
- net.cidr_is_valid accepted a bare address such as "192.168.1.2".
Go's net.ParseCIDR requires the prefix.
- net.lookup_ip_addr returned IPv6 in Java's uncompressed form
(0:0:0:0:0:0:0:1) rather than the canonical ::1 a policy compares
against.
- net.cidr_expand and net.cidr_contains_matches reported messages that
did not match OPA's wording.
Also rejects the empty string, which no fixture covers. The parser
accepts "" and resolves it to the loopback address, so
net.cidr_contains("", "127.0.0.1") answered true — a policy granting
access on an empty CIDR would have allowed the request. Go's ParseCIDR
and ParseIP both reject it, so every parse site now sets
allowEmpty(false).
Adds CidrBuiltinsTest, including a ServiceLoader assertion; the module
had no unit tests, which is why the registration gap went unnoticed.
Nine of the eleven tests fail against the unfixed code.
Removes the seven net entries from known-missing-builtins.txt (64 -> 57).
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
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 #192 and #193. The
BuiltinProviderentry foropa-builtins-netwas commented out in itsMETA-INF/servicesfile, so none of the seven net builtins were reachable for consumers.Registering it exposed 13 failing compliance cases:
net.cidr_mergegave a bare IPv4 address a/32. Go appliesnet.IP.DefaultMask(), the classful default, so["192.0.128.0", "192.0.129.0"]merges to192.0.128.0/23rather than two/32s.net.cidr_mergethrewAddressConversionExceptionon mixed IPv4 and IPv6 input, becausemergeToPrefixBlockscannot span versions. Each version is now merged separately and the results unioned.net.cidr_is_validaccepted a bare address such as"192.168.1.2". Go'snet.ParseCIDRrequires the prefix.net.lookup_ip_addrreturned IPv6 in Java's uncompressed form (0:0:0:0:0:0:0:1) rather than the canonical::1a policy compares against.net.cidr_expandandnet.cidr_contains_matchesreported messages that did not match OPA's wording.It also rejects the empty string, which no fixture covers. The parser accepts
""and resolves it to the loopback address, sonet.cidr_contains("", "127.0.0.1")answeredtrue— a policy gating on an unset CIDR would have allowed the request. Go'sParseCIDRandParseIPboth reject it, so every parse site now setsallowEmpty(false).Adds
CidrBuiltinsTest, including a ServiceLoader assertion; the module had no unit tests, which is why the registration gap went unnoticed. Nine of the eleven tests fail against the unfixed code.Removes the seven net entries from
known-missing-builtins.txt(64 → 57).