Skip to content

Commit 99d0b51

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 99d0b51

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;
@@ -103,6 +104,13 @@ class IpAddress implements \JsonSerializable
103104
*/
104105
public readonly Traits $traits;
105106

107+
/**
108+
* @var Anonymizer data for the anonymizer status of the requested IP
109+
* address. This object contains information about whether
110+
* the IP address belongs to an anonymous network.
111+
*/
112+
public readonly Anonymizer $anonymizer;
113+
106114
/**
107115
* @param array<string, mixed>|null $response
108116
* @param list<string> $locales
@@ -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;
@@ -178,6 +187,11 @@ public function jsonSerialize(): ?array
178187
$js['traits'] = $traits;
179188
}
180189

190+
$anonymizer = $this->anonymizer->jsonSerialize();
191+
if (!empty($anonymizer)) {
192+
$js['anonymizer'] = $anonymizer;
193+
}
194+
181195
$postal = $this->postal->jsonSerialize();
182196
if (!empty($postal)) {
183197
$js['postal'] = $postal;

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)