Repository navigation
Traffic filter: per-country, market and abuser-score exceptions - #3602
Merged
Merged
Conversation
… categories Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ranks matches with the access rules' harshness, now shared from @prosopo/captcha-severity, so the order of the exceptions list no longer changes the outcome. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 25, 2026
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.
What changed
Each traffic filter category (proxy, VPN, abuser, and so on) can now have a list of exceptions. An exception matches on any mix of:
countries: two-letter country codes for the visitor's IP (the UK isGB)inMarket:truematches visitors whose country is in the account's market,falsematches visitors outside itminAbuserScore: the IP's abuser score (0–1, inclusive)When an exception matches, its action (block or challenge, plus any captcha settings) is used instead of the category's own action. When several match, the harshest wins: a block beats any challenge, and a stricter captcha beats a milder one. The order of the list doesn't matter. The ranking is the one access rules already use. It has moved out of
blacklistRequestInspector.tsinto@prosopo/captcha-severityaspolicyHarshnessandharshestPolicy, and the access rules now call it from there, with the same ordering as before.The account's market countries now reach providers as
trafficFilter.marketCountriesinside each site's settings. The private portal adds them when it pushes a site. This PR also adds them on the provider's own pull from the portal database (getUpdatedClients). The new shared helperwithMarketCountriesalways replaces whatever market a site has saved with the account's, so a stale copy can't stick.What it does
Block out-of-market proxies; challenge in-market ones with a hard puzzle unless their abuser score is 0.5 or more:
proxy: { action: block, exceptions: [{ inMarket: true, action: challenge, captchaType: puzzle, … }, { inMarket: true, minAbuserScore: 0.5, action: block }] }. A GB proxy at 0.7 matches both, and the block wins.Challenge proxies from our market, block the rest:
proxy: { action: block, exceptions: [{ inMarket: true, action: challenge }] }Block UK abusers scoring 0.5 or more, challenge the rest:
abuser: { action: challenge, exceptions: [{ countries: ["GB"], minAbuserScore: 0.5, action: block }] }An
inMarketexception never matches while the account has no market set, or when the visitor has no known country. If no exceptions are set, nothing changes. Mongo stores the new fields too; without that they would be dropped on save.Tests
checkTrafficFilterunit tests:getUpdatedClientsintegration test: against an in-memory Mongo, the account's market ends up in the site's traffic filter.@prosopo/captcha-severitytests forpolicyHarshnessandharshestPolicy. The access-rule ranking tests pass unchanged.withMarketCountriestests (sets the market, replaces a stale one, leaves sites without a traffic filter alone).checkTrafficFilter. GB and IE proxies were challenged; FR proxies and proxies with no country were blocked. A GB abuser at 0.6 was blocked; GB at 0.3 and FR at 0.9 were challenged.Pairs with prosopo/captcha-private#5496.
🤖 Generated with Claude Code