fix(policy): add multi-country support and fix rule evaluation for COUNTRY_IS_NOT rules (#3432) - #3474
Open
Adityakk9031 wants to merge 1 commit into
Open
fix(policy): add multi-country support and fix rule evaluation for COUNTRY_IS_NOT rules (#3432)#3474Adityakk9031 wants to merge 1 commit into
Adityakk9031 wants to merge 1 commit into
Conversation
…UNTRY_IS_NOT rules (fosrl#3432)
Adityakk9031
requested review from
miloschwartz and
oschwartz10612
as code owners
July 21, 2026 08:04
Contributor
Author
|
@oschwartz10612 and @miloschwartz have a look |
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.
Description
Fixes #3432
Problem
Previously:
COUNTRYandCOUNTRY_IS_NOTaccess rules only accepted a single country code (orALL), preventing users from configuring multi-country rules (e.g.,US, CA).COUNTRY_IS_NOTrules (e.g. Rule 1:COUNTRY_IS_NOT US->DROPand Rule 2:COUNTRY_IS_NOT CA->DROP), sequential short-circuiting rule evaluation caused all traffic to be dropped (since an IP fromUSwas notCAand was dropped by Rule 2, and an IP fromCAwas dropped by Rule 1).Fix
server/lib/validators.ts), frontend validators (policy-access-rule-validation.ts), and blueprint schemas (server/lib/blueprints/types.ts) to accept comma-separated country codes (e.g.US, CA, MX).isIpInGeoIPandcheckRulesinserver/routers/badger/verifySession.tsto parse comma-separated country lists and group consecutiveCOUNTRY_IS_NOTrules with matching actions. This evaluates them as a unified exclusion set (IP NOT IN {US, CA}) rather than prematurely dropping allowed countries.PolicyAccessRulesTable.tsxto provide a multi-select country popover UI with flag previews and summary counts.server/lib/validators.test.tsfor single and multi-country rule validation.Type of Change
How Has This Been Tested?
server/lib/validators.test.ts.npx tsx server/lib/validators.test.ts.Checklist