Project

General

Profile

Bug #2285

Validation doesn't prevent "invalid address" error when creating subnets

Added by Joost Ringoot about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Web Interface
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When adding a subnet in the provisiong and having accidently a whitespace in front of the Network: eg " 192.168.16.0" instead of "192.168.16.0" I get this error:

Oops, we're sorry but something went wrong

x invalid address

If you feel this is an error with Foreman itself, please open a new issue with Foreman ticketing system, You would probably need to attach the Full trace and relevant log entries.

Back

ArgumentError
invalid address
app/models/subnet.rb:72:in `new'
app/models/subnet.rb:72:in `cidr'
app/models/subnet.rb:38:in `to_label'
app/views/subnets/index.html.erb:17:in `_app_views_subnets_index_html_erb___1480953890_70168276658080_0'
app/views/subnets/index.html.erb:14:in `_app_views_subnets_index_html_erb___1480953890_70168276658080_0'
lib/foreman/thread_session.rb:31:in `clear_thread'

It appears when doing this for the first subnet.
I can add other subnets but I can not modify them, since this page shows where I would expect to see the already defined subnets

Associated revisions

Revision 31aa5db5 (diff)
Added by Joseph Magen almost 6 years ago

fixes #2285 - subnet validation - length of addresses, strip whitespace and fix common typos

Revision 3d0287be (diff)
Added by Joseph Magen almost 6 years ago

fixes #2285 - subnet validation - length of addresses, strip whitespace and fix common typos
(cherry picked from commit 31aa5db511a6decf800e68a2b6f6eb3dbf0ae29c)

History

#1 Updated by Dominic Cleal about 6 years ago

  • Subject changed from problem with creating subnets to Validation doesn't prevent "invalid address" error when creating subnets
  • Category set to Web Interface

There are validators for the various IP addresses, but it looks like they won't prevent execution of the IPAddr.new calls, which then throw exceptions with invalid IPs.

#2 Updated by Alex Rodenberg about 6 years ago

I accidentally had put in 2555.255.255.0 and same thing happened to me.. any way for me to delete this entry so I have a functional subnet menu again ?

#3 Updated by Alex Rodenberg about 6 years ago

UPDATE subnets SET mask = "255.255.255.0" WHERE mask = "2555.255.255.0";

fixed it.

I guess the regex used does not catch what it's supposed to.

From subnet.rb:
validates_format_of :network, :mask, :with => Net::Validations::IP_REGEXP

#4 Updated by Dominic Cleal about 6 years ago

  • Target version set to 1.2.0

#5 Updated by Joseph Magen almost 6 years ago

  • Status changed from New to Assigned
  • Assignee set to Joseph Magen

#6 Updated by Dominic Cleal almost 6 years ago

  • Status changed from Assigned to Ready For Testing

#7 Updated by Joseph Magen almost 6 years ago

Joost, I assume that the reason that you can create, but not edit, subnets is because of your role/permissions defined in foreman.

#8 Updated by Dominic Cleal almost 6 years ago

Joseph Magen wrote:

Joost, I assume that the reason that you can create, but not edit, subnets is because of your role/permissions defined in foreman.

I think it's simply the exception being thrown breaking the UI. If you created an invalid subnet, the index page wouldn't be displayed as the to_label would throw exceptions from IPAddr.new when rendering the CIDR notation.

#9 Updated by Joseph Magen almost 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF