Skip to content

Commit f621b07

Browse files
oschwaldclaude
andcommitted
Add anonymizer property to IpAddress model
Expose the GeoIP2 Insights anonymizer data in the minFraud IpAddress model. This was previously available in the underlying GeoIP2 library (since 3.3.0) but not exposed in minFraud responses. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 201f2b0 commit f621b07

5 files changed

Lines changed: 71 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ CHANGELOG
44
3.6.0
55
------------------
66

7+
* Added the `anonymizer` property to `MaxMind\MinFraud\Model\IpAddress`. This
8+
contains anonymizer data from the GeoIP2 Insights response, including VPN
9+
detection confidence, provider name, and network last seen date. This was
10+
previously available in the GeoIP2 library but not exposed in minFraud
11+
responses.
712
* Added `banquest`, `summit_payments`, and `yaadpay` to the payment processor
813
validation.
914

src/MinFraud/Model/IpAddress.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace MaxMind\MinFraud\Model;
66

77
use GeoIp2\Model\Insights;
8+
use GeoIp2\Record\Anonymizer;
89
use GeoIp2\Record\City;
910
use GeoIp2\Record\Continent;
1011
use GeoIp2\Record\Country;
@@ -18,6 +19,13 @@
1819
*/
1920
class IpAddress implements \JsonSerializable
2021
{
22+
/**
23+
* @var Anonymizer data for the anonymizer status of the requested IP
24+
* address. This object contains information about whether
25+
* the IP address belongs to an anonymous network.
26+
*/
27+
public readonly Anonymizer $anonymizer;
28+
2129
/**
2230
* @var City city data for the requested IP address
2331
*/
@@ -123,6 +131,7 @@ public function __construct(?array $response, array $locales = ['en'])
123131
$this->representedCountry = $insights->representedCountry;
124132
$this->subdivisions = $insights->subdivisions;
125133
$this->traits = $insights->traits;
134+
$this->anonymizer = $insights->anonymizer;
126135

127136
$this->location = new GeoIp2Location($response['location'] ?? []);
128137
$this->risk = $response['risk'] ?? null;
@@ -143,6 +152,11 @@ public function jsonSerialize(): ?array
143152
{
144153
$js = [];
145154

155+
$anonymizer = $this->anonymizer->jsonSerialize();
156+
if (!empty($anonymizer)) {
157+
$js['anonymizer'] = $anonymizer;
158+
}
159+
146160
$city = $this->city->jsonSerialize();
147161
if (!empty($city)) {
148162
$js['city'] = $city;

tests/MaxMind/Test/MinFraud/Model/InsightsTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,38 @@ public function testInsightsProperties(): void
124124
'correct mobile network code'
125125
);
126126

127+
// Test anonymizer object
128+
foreach ([
129+
'isAnonymous',
130+
'isAnonymousVpn',
131+
'isHostingProvider',
132+
'isPublicProxy',
133+
'isTorExitNode',
134+
] as $property) {
135+
$this->assertTrue(
136+
$insights->ipAddress->anonymizer->{$property},
137+
"anonymizer {$property} is true"
138+
);
139+
}
140+
141+
$this->assertSame(
142+
$array['ip_address']['anonymizer']['confidence'],
143+
$insights->ipAddress->anonymizer->confidence,
144+
'correct anonymizer confidence'
145+
);
146+
147+
$this->assertSame(
148+
$array['ip_address']['anonymizer']['provider_name'],
149+
$insights->ipAddress->anonymizer->providerName,
150+
'correct anonymizer provider name'
151+
);
152+
153+
$this->assertSame(
154+
$array['ip_address']['anonymizer']['network_last_seen'],
155+
$insights->ipAddress->anonymizer->networkLastSeen,
156+
'correct anonymizer network last seen'
157+
);
158+
127159
$this->assertSame(
128160
$array['billing_phone']['country'],
129161
$insights->billingPhone->country,

tests/data/minfraud/factors-response.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
"network": "152.216.7.0/24",
112112
"organization": "STONEHOUSE office network",
113113
"user_type": "government"
114+
},
115+
"anonymizer": {
116+
"confidence": 99,
117+
"is_anonymous": true,
118+
"is_anonymous_vpn": true,
119+
"is_hosting_provider": true,
120+
"is_public_proxy": true,
121+
"is_tor_exit_node": true,
122+
"network_last_seen": "2025-01-15",
123+
"provider_name": "TestVPN"
114124
}
115125
},
116126
"billing_address": {

tests/data/minfraud/insights-response.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
"network": "152.216.7.0/24",
112112
"organization": "STONEHOUSE office network",
113113
"user_type": "government"
114+
},
115+
"anonymizer": {
116+
"confidence": 99,
117+
"is_anonymous": true,
118+
"is_anonymous_vpn": true,
119+
"is_hosting_provider": true,
120+
"is_public_proxy": true,
121+
"is_tor_exit_node": true,
122+
"network_last_seen": "2025-01-15",
123+
"provider_name": "TestVPN"
114124
}
115125
},
116126
"billing_address": {

0 commit comments

Comments
 (0)