"Hostname Opt type does not ensure presence of at least 1 character in hostname

Bug #1615028 reported by Dharini Chandrasekar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.config
Fix Released
Undecided
Dharini Chandrasekar

Bug Description

The HostnameOpt type in oslo.config, takes in a value to validate if it is a valid hostname.
However, it validates a "10.0" as a valid hostname. It fails to check if there is at least one chatacter in each segment of the hostname.

File: https://github.com/openstack/oslo.config/blob/master/oslo_config/types.py#L666

The unit tests for this class fail to check this case.
https://github.com/openstack/oslo.config/blob/master/oslo_config/tests/test_types.py#L675

Changed in oslo.config:
assignee: nobody → Dharini Chandrasekar (dharini-chandrasekar)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.config (master)

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

Changed in oslo.config:
status: New → In Progress
Revision history for this message
Dharini Chandrasekar (dharini-chandrasekar) wrote :

The HostnameOpt type currently does not test for the presence of at least one char.
Due to this, it accepts IPv4 addresses (complete and incomplete). ie. for example: "10.0.0.0" and "10.0" are both taken as valid hostnames while the latter should not be.
Also the Hostname opt type does not accept ipv6 addresses. Nor does it perform strict checks on IP addresses based on their versions.
Editing the HostnameOpt type to accommodate strict checks on IPs will stop it from accepting pure hostnames. (Refer https://github.com/openstack/oslo.config/blob/master/oslo_config/types.py)

Hence a reasonable solution could be to add a new type: HostAddress that will perform strict checks on both IPs and hostnames.
So for opts that can have either a hostname or an IP can be given the new type - HostAddress.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.config (master)

Reviewed: https://review.openstack.org/358045
Committed: https://git.openstack.org/cgit/openstack/oslo.config/commit/?id=babff882c0794fab81665744bcc1aa155b90eed2
Submitter: Jenkins
Branch: master

commit babff882c0794fab81665744bcc1aa155b90eed2
Author: Dharini Chandrasekar <email address hidden>
Date: Fri Aug 19 18:34:18 2016 +0000

    Fixing HostName and adding support for HostAddress

    When config options in different projects use IPOpt as the opt's
    type, it restricts operators to only IP addresses.
    When the opt is set to HostnameOpt type, currently even an
    incomplete or invalid IP passes as a valid hostname. Also, currently
    HostnameOpt does not make sure that there is a presense of at least one
    non-numeric character in the provided host name.

    According to RFC 1123, (https://tools.ietf.org/html/rfc1123),
    a valid host name can never have the dotted-decimal form #.#.#.#,
    since at least the highest-level component label will be alphabetic.

    This patch fixes the existing Hostname Opt to abide by the stated RFC
    and also adds a new opt type that would enable operators to provide
    either a hostname or an IP and at the same time perform checks on
    both IPOpt type and HostnameOpt type, by setting opt type to
    "HostAddressOpt" type. This would ensure that an invalid IP does
    not pass as a valid hostname and at the same time retains the rules
    required to be followed for the validation of an acceptable hostname.

    Change-Id: I77bdb64b7e6e56ce761d76696bc4448a9bd325eb
    Closes-Bug: #1619044
    Closes-Bug: #1615028

Changed in oslo.config:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.config 3.22.0

This issue was fixed in the openstack/oslo.config 3.22.0 release.

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.