feat: add inCidr and notInCidr CIDR matching conditions#10
Conversation
IP conditions could only exact-match, so allowlist and blocklist rules had no way to target address ranges. inCidr matches when the attribute address falls inside any listed CIDR block; notInCidr when it falls inside none. IPv4 and IPv6 are supported via bytewise prefix comparison of inet_pton-packed addresses, a bare address defaults to a host route (/32 or /128), families never cross-match, and malformed input fails closed for both operators. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Greptile SummaryThis PR adds CIDR-based matching to the rule engine. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "fix: match nothing when a CIDR list has ..." | Re-trigger Greptile |
An empty or fully malformed values list made notInCidr vacuously true,
so a bypass rule built with Condition::notInCidr('ip', []) admitted all
traffic despite the validator rejecting such definitions. Both CIDR
operators now match nothing when zero entries parse, keeping runtime
fail-closed even when validation is skipped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Recommendation: hold this until there's a live consumerFlagging a scope concern before this merges. Edge already owns a complete, deployed IP-allowlist enforcement subsystem in
That is what actually enforces DAT-1944 today ( The implementation here is correct and I'd keep the dedicated Suggest: hold/close this until the consolidation is actually scheduled (i.e. when the HTTP-WAF IP-rule consumer lands, or when we decide to migrate edge's |
What
Adds two new condition types to the rule engine:
inCidrandnotInCidr, plus CIDR value validation in theConditionsvalidator and builder methodsCondition::inCidr()/Condition::notInCidr().Why
IP-based rules can only exact-match today (
equal/notEqualon the resolved address). Both consumers need range matching: the edge database network allowlist (DAT-1944) and HTTP WAF IP rules for functions/sites. This closes that gap in the shared library so both inherit the same semantics.Semantics
inCidrnotInCidr1.2.3.4,2001:db8::1)/32//128host route/0blockComparison is a bytewise prefix compare over
inet_pton-packed addresses, so there are no integer/float conversions to break on 64-bit boundaries or IPv6.The
Conditionsvalidator rejectsinCidr/notInCidrdefinitions with empty value lists or entries that are not valid CIDR blocks or bare addresses.Rollout
Consumption in appwrite-labs cloud and edge follows in separate changes after this is released.
🤖 Generated with Claude Code