Skip to content

Make the IPv4|6 regex much more strict #660

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

Closed
wants to merge 1 commit into from
Closed

Make the IPv4|6 regex much more strict #660

wants to merge 1 commit into from

Conversation

daenney
Copy link

@daenney daenney commented Oct 1, 2016

This will correctly match IPv4 and IPv6 addresses and discard invalid ones.

This will correctly match IPv4 and IPv6 addresses and discard invalid
ones.
@daenney
Copy link
Author

daenney commented Oct 1, 2016

There's something wrong with rspec(-puppet) and Ruby 2.1.5:

/home/travis/build/puppetlabs/puppetlabs-stdlib/vendor/bundle/ruby/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:512:in `extract_scope_from': You must explicitly give a scope (:each, :all, or :suite) when using symbols as metadata for a hook. (ArgumentError)

@daenney
Copy link
Author

daenney commented Oct 1, 2016

Though much more strict it still passes all the tests that we had defined so this Won't Break Anything™️ while properly rejecting anything that's not an IP address according to the specs.

Also, the previous IPv6 regex did not support addresses with a :: in there it would seem. Which is totally valid. What is curious though is that the tests seem fine with it... I would expect things to have failed.

@daenney
Copy link
Author

daenney commented Oct 1, 2016

Should I extend this to support CIDR matching for IPv4 and 6 too? Both the old and the new regexes don't support notations like ::1/128 for example.

@daenney
Copy link
Author

daenney commented Oct 2, 2016

Poke @hunner and @HelenCampbell

@daenney
Copy link
Author

daenney commented Oct 3, 2016

@DavidS Do you know why the tests explode on Ruby 2.1.5?

@DavidS
Copy link
Contributor

DavidS commented Oct 3, 2016

@daenney it seems that a change somewhere causes rspec-core 2.99 to be installed. That seems to cause all sorts of issues.

@DavidS
Copy link
Contributor

DavidS commented Oct 3, 2016

@daenney I flushed travis' gem caches for stdlib, and rekicked your cells. This seems to have fixed the issue. I do not completely understand why, tho.

Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, but the Compat types are specifically designed to match the behaviour of the validate_* functions bug-for-bug. See https://tickets.puppetlabs.com/browse/MODULES-3534 for this specific set.

Feel free to add properly designed IP types as Stdlib::IPv4Address, Stdlib::IPv6Address and Stdlib::IPAddress.

@igalic
Copy link
Contributor

igalic commented Oct 14, 2016

has anyone considered asking @thrnio for merging their module into stdlib? https://github.com/thrnio/puppet-ip
(or maybe just depend on it?)

@daenney daenney closed this Oct 14, 2016
@hunner
Copy link
Contributor

hunner commented Oct 17, 2016

I don't know that persisting bugs is a good option. Okay, so it'll be a slight migration hurdle for people with broken manifests; it's still a bug and should be fixed. No one should be taking advantage of this anyway and so shouldn't actually run into it.

@DavidS
Copy link
Contributor

DavidS commented Oct 18, 2016

@hunner the whole point of the ::compat:: types is bug-for-bug compatibility. There is no reason to NOT add properly designed IP types as Stdlib::IPv4Address, Stdlib::IPv6Address and Stdlib::IPAddress, other than nobody's currently doing the work for them.

@hunner
Copy link
Contributor

hunner commented Oct 19, 2016

Oh I see I see, it's not just fixing them, but specifically making the change somewhere other than Stdlib::Compat::*

@DavidS
Copy link
Contributor

DavidS commented Oct 19, 2016

exactly.

On 19 October 2016 at 18:48, Hunter Haugen notifications@github.com wrote:

Oh I see I see, it's not just fixing them, but specifically making the
change somewhere other than Stdlib::Compat::*


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#660 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABsQDJsa3k9ZBhNNqtN2X7Rsmi8RUyNks5q1lfdgaJpZM4KLxKQ
.

@daenney daenney deleted the fix-ip-regexes branch February 22, 2017 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants