The hostname regex pattern doesn't match valid hostnames

Bug #1396932 reported by Kevin Benton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Kevin Benton
Icehouse
Fix Released
Undecided
Unassigned
Juno
Fix Released
Undecided
Unassigned

Bug Description

The regex used to match hostnames is opinionated, and it's opinions differ from RFC 1123 and RFC 952.

The following hostnames will fail that are valid.

6952x
openstack-1
a1a
x.x1x
example.org.

Changed in neutron:
assignee: nobody → Kevin Benton (kevinbenton)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/137560

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/137560
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=35662d07628452d14306f5197871ad64f6396ff3
Submitter: Jenkins
Branch: master

commit 35662d07628452d14306f5197871ad64f6396ff3
Author: Kevin Benton <email address hidden>
Date: Thu Nov 27 01:45:29 2014 -0800

    Fix hostname validation for nameservers

    Fixes the hostname validation to align with the RFC's demands[1].
    This was done by replacing the full regex with a function that
    broke the FQDN into individual components that were easier to
    reason about with regular expressions.

    Also added several test cases for domains so if someone wants
    to convert it back to pure regex there will be better test vectors.

    1. RFC 1123 says an all-digit hostname is allowed in section 2.1. It
       says that this more liberal syntax MUST be supported.

    Closes-Bug: #1396932
    Change-Id: I003cf14d95070707e43e40d55da62e11a28dfa4e

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/139061

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/139063

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/juno)

Reviewed: https://review.openstack.org/139061
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=209160ba5804c21b833cb285c26da2789975cb90
Submitter: Jenkins
Branch: stable/juno

commit 209160ba5804c21b833cb285c26da2789975cb90
Author: Kevin Benton <email address hidden>
Date: Thu Nov 27 01:45:29 2014 -0800

    Fix hostname validation for nameservers

    Fixes the hostname validation to align with the RFC's demands[1].
    This was done by replacing the full regex with a function that
    broke the FQDN into individual components that were easier to
    reason about with regular expressions.

    Also added several test cases for domains so if someone wants
    to convert it back to pure regex there will be better test vectors.

    1. RFC 1123 says an all-digit hostname is allowed in section 2.1. It
       says that this more liberal syntax MUST be supported.

    Conflicts:
     neutron/tests/unit/test_attributes.py

    Closes-Bug: #1396932
    Change-Id: I003cf14d95070707e43e40d55da62e11a28dfa4e
    (cherry picked from commit 35662d07628452d14306f5197871ad64f6396ff3)

tags: added: in-stable-juno
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/icehouse)

Reviewed: https://review.openstack.org/139063
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=d39349cf47dfe9ac3f52089402d69cd1be8b013b
Submitter: Jenkins
Branch: stable/icehouse

commit d39349cf47dfe9ac3f52089402d69cd1be8b013b
Author: Kevin Benton <email address hidden>
Date: Thu Nov 27 01:45:29 2014 -0800

    Fix hostname validation for nameservers

    Fixes the hostname validation to align with the RFC's demands[1].
    This was done by replacing the full regex with a function that
    broke the FQDN into individual components that were easier to
    reason about with regular expressions.

    Also added several test cases for domains so if someone wants
    to convert it back to pure regex there will be better test vectors.

    1. RFC 1123 says an all-digit hostname is allowed in section 2.1. It
       says that this more liberal syntax MUST be supported.

    Conflicts:
     neutron/tests/unit/test_attributes.py

    Closes-Bug: #1396932
    Change-Id: I003cf14d95070707e43e40d55da62e11a28dfa4e
    (cherry picked from commit 35662d07628452d14306f5197871ad64f6396ff3)

tags: added: in-stable-icehouse
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Revision history for this message
Ihar Hrachyshka (ihar-hrachyshka) wrote :

It's weird that we spent time on fixing the regexp while base db plugin does not allow non-address nameservers in the first place. A better thing would be to just kill the regexp.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/168886

Thierry Carrez (ttx)
Changed in neutron:
milestone: kilo-1 → 2015.1.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (master)

Reviewed: https://review.openstack.org/168886
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=fd162a82776d64af9abc5595d1b8d2473dfce8f2
Submitter: Jenkins
Branch: master

commit fd162a82776d64af9abc5595d1b8d2473dfce8f2
Author: Ihar Hrachyshka <email address hidden>
Date: Mon Mar 30 14:35:15 2015 +0200

    Kill hostname validation for subnet:dns_nameservers

    DNS servers that are hostnames seem like a bad idea. They are also not
    supported by base_db_plugin_v2 [1] anyway, so there is no big reason to
    pass them thru API validation only to receive InvalidInput later inside
    plugin code.

    [1]: http://git.openstack.org/cgit/openstack/neutron/tree/neutron/db/db_base_plugin_v2.py#n1049

    Change-Id: I2db00fe266fe0748d0e6327fbad22fa16b751da8
    Related-Bug: #1396932

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (neutron-pecan)

Related fix proposed to branch: neutron-pecan
Review: https://review.openstack.org/185072

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.