Puppet: System Administration Automated

Support

Ticket #151 (closed enhancement: fixed)

Opened 3 years ago

Last modified 10 months ago

host does not validate IP and hostname

Reported by: ghislain Assigned to: luke
Priority: normal Milestone:
Component: library Version:
Severity: normal Keywords: hosts validation
Cc: Triage Stage: Ready for checkin
Attached Patches: Code Complexity: Easy

Description

host does not validate ip or hostname.

for ip ipv4 is quite easy:

(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}

for ipv6 i think you have to process it and then validate as it have several way of being printed:

uppercase it
split on ':'
for the 6 first , if less than 4 lenght then add 4-lenght 0 before it  ( 7A => 007A, '' => 0000)
for the rest: if they are 2	then  hexa block no surprise
               then  if less than 4-lenght then add 4-lenght 0 before it  
	         if there is 1 then  it must be an ipv4 adress, 
               each number should be converted to a hexadecimal number  
               to rebuild the last 2 hex bloc. So use validate ipv4 and then process
               by split(.) then int_to_hex it
now validate the 8 blocks:
([\dA-F]{4}:){7}[\dA-F]{4}

for the hostname:

split by '.'
each part must have lenght =< 75 characters
validate : ([\d\w]+|[\d\w][\d\w\-]+[\d\w])
(must start/end with a letter/digit)


I think we should have a validation library that we can call in the puppet code and also extend with our own validation routines. This should prevent each type to have its own validation for IP or simple things like hostnames...

regards, Ghislain.

Change History

04/05/07 21:33:57 changed by luke

  • specification set to Unnecessary.
  • patch set to None.
  • complexity set to Easy.
  • milestone set to unplanned.
  • owner changed from luke to community.
  • approval set to Unnecessary.
  • compatibility set to Full.
  • stage set to Accepted.

Validation should be pretty easy using the builtin ipaddr library.

07/13/07 05:04:48 changed by barjunk

Where would this need to get implemented. I'd consider taking a whack at this.

07/13/07 17:20:13 changed by luke

Just add some calls to the validate() hook in the host type.

11/24/07 04:06:38 changed by luke

  • type changed from defect to enhancement.

01/22/08 01:59:35 changed by jamtur01

  • owner changed from community to luke.
  • patch changed from None to Code.
  • stage changed from Accepted to Ready for checkin.
  • milestone deleted.

Fixed in commit [1ccc9c3b47e7e96f70fa48b2a21c5e10dc103d6e] in branch 0.24.x.

01/25/08 12:51:24 changed by jamtur01

This commit is better [9a290bb646e23191184230243ef58cc0c9501400] in branch 0.24.x

01/25/08 12:51:46 changed by jamtur01

Well ugly and regex - but works.

02/05/08 03:53:44 changed by jamtur01

Updated function and added a test in commit [16df87c419655106b1585b1e443a2050270518e5] in branch 0.24.x. This should now work and be tested. Might want to take a close look as its my first test.

02/05/08 06:57:03 changed by luke

  • status changed from new to closed.
  • resolution set to fixed.

Merged and pushed.