Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apm] ip quantization fix dropped protocol bug #28677

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/obfuscate/ip_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func splitPrefix(raw string) (prefix, after string) {
// quantizeIP quantizes the ip address in the provided string, only if it exactly matches an ip with an optional port
// if the string is not an ip then empty string is returned
func quantizeIP(raw string) string {
prefix, raw := splitPrefix(raw)
host, port, suffix := parseIPAndPort(raw)
prefix, rawNoPrefix := splitPrefix(raw)
host, port, suffix := parseIPAndPort(rawNoPrefix)
if host == "" {
// not an ip address
return raw
Expand Down
3 changes: 2 additions & 1 deletion pkg/obfuscate/ip_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestQuantizePeerIpAddresses(t *testing.T) {
{"[fe80::1ff:fe23:4567:890a]:8080", "blocked-ip-address:8080"},
{"192.168.1.1:1234", "blocked-ip-address:1234"},
{"dnspoll:///10.21.120.145:6400", "dnspoll:///blocked-ip-address:6400"},
{"dnspoll:///abc.cluster.local:50051", "dnspoll:///abc.cluster.local:50051"},
{"http://10.21.120.145:6400", "http://blocked-ip-address:6400"},
{"https://10.21.120.145:6400", "https://blocked-ip-address:6400"},
{"192.168.1.1:1234,10.23.1.1:53,10.23.1.1,fe80::1ff:fe23:4567:890a,foo.dog", "blocked-ip-address:1234,blocked-ip-address:53,blocked-ip-address,foo.dog"},
Expand All @@ -47,7 +48,7 @@ func TestQuantizePeerIpAddresses(t *testing.T) {
{"ip-10-152-4-129.ec2.internal", "ip-blocked-ip-address.ec2.internal"},
}
for _, tc := range testCases {
t.Run("", func(t *testing.T) {
t.Run(tc.original, func(t *testing.T) {
assert.Equal(t, tc.quantized, QuantizePeerIPAddresses(tc.original))
})
}
Expand Down
Loading