Bug #2960

IP validator allows invalid addresses

Added by Davide Principi almost 5 years ago. Updated almost 5 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:v1.6.1
Security class: Resolution:
Affected version:v1.6.0 NEEDINFO:No

Description

The IP validator accepts some values which are not actually valid IP addresses.

Step to reproduce
  • Install nethserver-dnsmasq
  • Try to create a reservation with an IP address with "0" on the left side of an octet, like 192.168.5.002, 192.168.005.003
  • The validator doesn't fail

Expected behavior

Octets starting with zero should be rejected


Related issues

Copied from NethServer 6 - Bug #2913: Web interface: IP validator allows not valid addresses CLOSED

Associated revisions

Revision 92a93021
Added by Davide Principi almost 5 years ago

Fail IPV4 validation if octet starts with "0". Refs #2960

Unit tests green. See ValidatorTest.php for more details.

History

#1 Updated by Davide Principi almost 5 years ago

  • Copied from Bug #2913: Web interface: IP validator allows not valid addresses added

#2 Updated by Davide Principi almost 5 years ago

  • Status changed from NEW to TRIAGED
  • % Done changed from 0 to 20

#3 Updated by Davide Principi almost 5 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Davide Principi
  • % Done changed from 20 to 30

Confirmed
Added test cases:

diff --git a/Nethgui/Test/Unit/Nethgui/System/ValidatorTest.php b/Nethgui/Test/Unit/Nethgui/System/ValidatorTest.php
index 12bae62..017b2d6 100644
--- a/Nethgui/Test/Unit/Nethgui/System/ValidatorTest.php
+++ b/Nethgui/Test/Unit/Nethgui/System/ValidatorTest.php
@@ -140,6 +140,8 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->object->evaluate('0.0.0.0'));
         $this->assertFalse($this->object->evaluate(''));
         $this->assertFalse($this->object->evaluate('a.b.c.d'));
+        $this->assertFalse($this->object->evaluate('192.168.5.002'));
+        $this->assertFalse($this->object->evaluate('192.168.005.003'));
     }

     /**

#4 Updated by Davide Principi almost 5 years ago

  • Status changed from ON_DEV to MODIFIED
  • Assignee deleted (Davide Principi)
  • % Done changed from 30 to 60

Unit tests are green

#5 Updated by Davide Principi almost 5 years ago

  • Status changed from MODIFIED to ON_QA
  • % Done changed from 60 to 70

In nethserver-testing:
nethserver-httpd-admin-1.3.3-1.7git7a4f0bd.ns6.noarch.rpm

#6 Updated by Davide Principi almost 5 years ago

  • Status changed from ON_QA to VERIFIED
  • % Done changed from 70 to 90

#7 Updated by Davide Principi almost 5 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100

Also available in: Atom PDF