Skip to content

Conversation

@alexandre-daubois
Copy link
Member

fabpot added a commit to symfony/symfony that referenced this pull request Aug 22, 2024
…` parameters to `IpUtils::anonymize()` (alexandre-daubois)

This PR was merged into the 7.2 branch.

Discussion
----------

[HttpFoundation] Add optional `$v4Bytes` and `$v6Bytes` parameters to `IpUtils::anonymize()`

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | on
| New feature?  | yes
| Deprecations? | no
| Issues        | Fix #50778
| License       | MIT
| Doc PR | symfony/symfony-docs#20138

This PR answers to the need of more anonymization of IP addresses. This adds 2 new parameters to the `IpUtils::anonymize()` that you can use this way:

```php
$ipv4 = '123.234.235.236';
$anonymousIpv4 = IpUtils::anonymize($ipv4, v4Bytes: 3);
// $anonymousIpv4 = '123.0.0.0'

$ipv6 = '2a01:198:603:10:396e:4789:8e99:890f';
$anonymousIpv6 = IpUtils::anonymize($ipv6, v6Bytes: 10);
// $anonymousIpv6 = '2a01:198:603::'
```

Commits
-------

53c4f92 [HttpFoundation] Add optional `$v4Bytes` and `$v6Bytes` parameters to `IpUtils::anonymize()`
@OskarStark OskarStark removed the Waiting Code Merge Docs for features pending to be merged label Aug 22, 2024
@javiereguiluz
Copy link
Member

Nice one! Thanks Alex

@javiereguiluz javiereguiluz merged commit 55d50b0 into symfony:7.2 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants