Skip to content

Replace netaddr gem with stdlib IPAddr - #5330

Open
johha wants to merge 1 commit into
mainfrom
replace-netaddr-with-ipaddr
Open

Replace netaddr gem with stdlib IPAddr#5330
johha wants to merge 1 commit into
mainfrom
replace-netaddr-with-ipaddr

Conversation

@johha

@johha johha commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The netaddr gem is effectively unmaintained (no releases despite open requests). Security group rule validation only needs parsing, family detection, and range-endpoint ordering, all of which IPAddr covers.

Behaviour is preserved:

  • leading-zero IPv4 octets are normalised before parsing (IPAddr rejects them, netaddr accepted them);
  • range endpoints must be plain addresses, so a prefix is rejected there.

Add a rule_validator spec covering the v2 validate_destination path, which previously had no dedicated coverage.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@johha
johha force-pushed the replace-netaddr-with-ipaddr branch from 44010c0 to 27636b0 Compare August 3, 2026 10:19
Comment thread lib/cloud_controller/rule_validator.rb Outdated
The netaddr gem is effectively unmaintained (no releases despite open
requests). Security group rule validation only needs parsing, family
detection, and range-endpoint ordering, all of which IPAddr covers.

This also aligns validation with downstream enforcement. netaddr accepted
zero-padded IPv4 octets (e.g. 010.0.0.53, or ::ffff:010.0.0.1) that Diego
rejects at enforcement time via Go's net.ParseIP, so such rules passed CC
but never applied. IPAddr rejects them, surfacing the error to the operator
at creation instead of failing silently later. The v3 message validator
already rejected leading zeros; this brings the v2 path into line.

Zero-padded IPv6 hextets remain valid (RFC 4291), unchanged. Range endpoints
must be plain addresses, so a prefix is rejected there.

Add a rule_validator spec covering the v2 validate_destination path (IPv4
leading-zero rejection, IPv6 padding, IPv4-mapped addresses), which
previously had no dedicated coverage, and fix pre-existing test fixtures
that relied on netaddr accepting malformed addresses (a trailing-dot range
endpoint and a zero-padded octet).
@johha
johha force-pushed the replace-netaddr-with-ipaddr branch from 27636b0 to 4158efc Compare August 5, 2026 08:22
@johha
johha requested a review from kathap August 5, 2026 08:23
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.

2 participants