Bug 1661245
| Summary: | bad detection of a string aka mac address | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Cyril Lopez <cylopez> |
| Component: | libyaml | Assignee: | John Eckersberg <jeckersb> |
| Status: | CLOSED NOTABUG | QA Contact: | BaseOS QE - Apps <qe-baseos-apps> |
| Severity: | high | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.6 | CC: | hberaud |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2018-12-20 15:17:38 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
This mac is a sexagesimal, must be quoted The real error come from this regex: ^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?(?:0|[1-9][0-9_]*)|[-+]?0x[0-9a-fA-F_]+|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$ Who recognize 52:54:00:58:15:35 like an integer... When we try this regex on 52:54:00:86:94:61 the problem doesn't occur This regex come from the PyYAML library. The regex is defined in the resolver of pyyaml https://github.com/yaml/pyyaml/blob/master/lib3/yaml/resolver.py#L186 The problem occur under python version 2 and 3 and so PyYAML 2 and 3 The YAML specification speak about a decimal integer notation, with a leading “-” character for negative values, matching the regular expression: 0 | -? [1-9] [0-9]* https://yaml.org/spec/1.2/spec.html#id2803828 The current regex defined by PyYAML have a problem and introduce this bug The right regex is => ^(?:[-+]?0b[0-1_]+|[-+]?0o?[0-7_]+|[-+]?[0-9_]+|[-+]?0x[0-9a-fA-F_]+)$ I will to fix that on PyYAML and try to backport fix downstream after that With the following regex we can capture the following elements who correspond to the YAML standard definition 1.1 and 1.2 ^(?:[-+]?0b[0-1_]+|[-+]?0o?[0-7_]+|[-+]?0?(?:0|[1-9][0-9_]*)|[-+]?0x[0-9a-fA-F_]+)$ Consider the following sample tests : 52:54:00:86:94:61 52:54:00:58:15:35 52:54:00:72:b7:e5 52:54:00:59:16:35 54 0b564 0x64 123456789 0123456789 0b0 0xb 0o13 0xB This regex catch the following result set: 54 0x64 123456789 0123456789 0b0 0xb 0o13 0xB We are compatible with the following YAML specifications for the octal and hexadecimal representations: 1.1 => https://yaml.org/spec/current.html#id2507367 1.2 => http://yaml.org/spec/1.2/spec.html#id2764652 Currently PyYAML doesn't deal with retro compatibility and also doesn't catch the octal and hexa representation. concerning the sexagesimal the representation come from https://yaml.org/type/int.html the support was dropped[1] since the version 1.1 of the yaml specifications. [1] https://yaml.org/spec/1.2/spec.html#id2805071 PyYAML only support YAML 1.1 (https://pyyaml.org/wiki/PyYAML) so sexagesimal can be fixed directly on. My previous comments and especially my regex doesn't that PyYAML consider YAML standards version 1.1 So quotes are the right solution. But the real problem is that the format of the MAC address look like a sexagesimal format without really being one. s/can be fixed directly on/cannot be fixed directly on/ |
Description of problem: When I load a yaml with a MAC address as 52:54:00:58:15:35, this is converted in 41135249735 If I change to 52:54:00:58:65:35, is not converted. Version-Release number of selected component (if applicable): libyaml-0.1.4-11.el7_0.x86_64 python-2.7.5-76.el7.x86_64 How reproducible: The YAML file --- parameter_defaults: EnableFencing: true FencingConfig: devices: - agent: fence_xvm host_mac: 52:54:00:72:b7:e5 params: multicast_address: 225.0.0.12 key_file: /etc/cluster/fence_xvm.key port: controller01 interval: 10m pcmk_host_list: ctl01 - agent: fence_xvm host_mac: 52:54:00:86:94:61 params: multicast_address: 225.0.0.13 key_file: /etc/cluster/fence_xvm.key port: controller02 interval: 10m pcmk_host_list: ctl02 - agent: fence_xvm host_mac: 52:54:00:58:15:35 params: multicast_address: 225.0.0.14 key_file: /etc/cluster/fence_xvm.key port: controller03 interval: 10m pcmk_host_list: ctl03 ... Steps to Reproduce: 1. take the file below as my.yaml 2. python -c 'import yaml, sys; print yaml.load(sys.stdin)' < my.yaml Actual results: {'parameter_defaults': {'FencingConfig': {'devices': [{'params': {'port': 'controller01', 'multicast_address': '225.0.0.12', 'interval': '10m', 'key_file': '/etc/cluster/fence_xvm.key', 'pcmk_host_list': 'ctl01'}, 'agent': 'fence_xvm', 'host_mac': '52:54:00:72:b7:e5'}, {'params': {'port': 'controller02', 'multicast_address': '225.0.0.13', 'interval': '10m', 'key_file': '/etc/cluster/fence_xvm.key', 'pcmk_host_list': 'ctl02'}, 'agent': 'fence_xvm', 'host_mac': '52:54:00:86:94:61'}, {'params': {'port': 'controller03', 'multicast_address': '225.0.0.14', 'interval': '10m', 'key_file': '/etc/cluster/fence_xvm.key', 'pcmk_host_list': 'ctl03'}, 'agent': 'fence_xvm', 'host_mac': 41135249735}]}, 'EnableFencing': True}} Expected results: {'parameter_defaults': {'FencingConfig': {'devices': [{'params': {'port': 'controller01', 'multicast_address': '225.0.0.12', 'interval': '10m', 'key_file': '/etc/cluster/fence_xvm.key', 'pcmk_host_list': 'ctl01'}, 'agent': 'fence_xvm', 'host_mac': '52:54:00:72:b7:e5'}, {'params': {'port': 'controller02', 'multicast_address': '225.0.0.13', 'interval': '10m', 'key_file': '/etc/cluster/fence_xvm.key', 'pcmk_host_list': 'ctl02'}, 'agent': 'fence_xvm', 'host_mac': '52:54:00:86:94:61'}, {'params': {'port': 'controller03', 'multicast_address': '225.0.0.14', 'interval': '10m', 'key_file': '/etc/cluster/fence_xvm.key', 'pcmk_host_list': 'ctl03'}, 'agent': 'fence_xvm', 'host_mac': '52:54:00:58:15:35'}]}, 'EnableFencing': True}} Additional info: