Jira (PUP-9505) Fact yaml should quote mac addresses.

28 views
Skip to first unread message

Alexander Fisher (JIRA)

unread,
Feb 20, 2019, 11:39:02 AM2/20/19
to puppe...@googlegroups.com
Alexander Fisher created an issue
 
Puppet / Bug PUP-9505
Fact yaml should quote mac addresses.
Issue Type: Bug Bug
Affects Versions: PUP 6.2.0
Assignee: Unassigned
Created: 2019/02/20 8:38 AM
Priority: Normal Normal
Reporter: Alexander Fisher

In puppet 6 (and not in 5), `puppet facts --render-as yaml` outputs mac addresses unquoted.
If your mac address doesn't contain any chars A-F this is a problem as other tools parsing this yaml will interpret the value as a sexagesimal (base 60) integer.
https://yaml.org/type/int.html

Cached fact data in /opt/puppetlabs/server/data/puppetserver/yaml/facts is also broken.
One tool affected by this problem is the enc script that ships with Foreman. It loads data from /opt/puppetlabs/server/data/puppetserver/yaml/facts/some_node.yaml and uploads the facts to foreman as json. Foreman understandably doesn't like the mac address it receives in the payload.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Alexander Fisher (JIRA)

unread,
Feb 20, 2019, 11:45:03 AM2/20/19
to puppe...@googlegroups.com
Alexander Fisher commented on Bug PUP-9505
 
Re: Fact yaml should quote mac addresses.

How the yaml is parsed/emitted depends on the the version of ruby...

System ruby: 2.0.0 (RHEL 7)

 irb(main):002:0> YAML.load('macaddress: 52:54:00:44:49:56')
 => {"macaddress"=>12465480}

Puppet ruby 2.5.3

 irb(main):003:0> YAML.load('macaddress: 52:54:00:44:49:56')
 => {"macaddress"=>"52:54:00:44:49:56"}

Ewoud Kohl van Wijngaarden (JIRA)

unread,
Feb 20, 2019, 12:21:04 PM2/20/19
to puppe...@googlegroups.com

And Python does yet something else:

$ echo "import yaml ; print(yaml.load('macaddress: 52:54:00:44:49:56'))" | python
{'macaddress': 41135201396}
$ echo "import yaml ; print(yaml.load('macaddress: 52:54:00:44:49:56'))" | python3
{'macaddress': 41135201396}

Long term it might be better to store this as JSON.

Alexander Fisher (JIRA)

unread,
Feb 21, 2019, 4:51:03 AM2/21/19
to puppe...@googlegroups.com

At first I thought ruby 2.5.3 didn't parse unquoted mac addresses as sexagesimal because it implements yaml 1.2.
Actually, I think it's because of this commit https://github.com/ruby/psych/commit/4ae7a3efbc5a423ee288bd734545f834b3cd426b

irb(main):007:0> YAML.load('macaddress: 44:49:56')
=> {"macaddress"=>161396}
irb(main):008:0> YAML.load('macaddress: 52:54:00:44:49:56')
=> {"macaddress"=>"52:54:00:44:49:56"}

Jorie Tappa (JIRA)

unread,
Feb 25, 2019, 12:58:04 PM2/25/19
to puppe...@googlegroups.com
Jorie Tappa updated an issue
 
Change By: Jorie Tappa
Team: Coremunity

Jorie Tappa (JIRA)

unread,
Feb 25, 2019, 12:59:03 PM2/25/19
to puppe...@googlegroups.com
Jorie Tappa updated an issue
Change By: Jorie Tappa
Sprint: Coremunity Hopper

Josh Cooper (JIRA)

unread,
Mar 28, 2019, 11:36:04 PM3/28/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Hopper Grooming

Josh Cooper (JIRA)

unread,
Apr 15, 2019, 4:49:03 PM4/15/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9505
 
Re: Fact yaml should quote mac addresses.

Native facter defines macaddress to be a string in its schema, and knows to emit it as a quoted string:

[root@ka8y738etxt42jh ~]# facter --version
3.13.1 (commit 4e1df48f76caa0eaeee90af4239a1df450d45cd7)
[root@ka8y738etxt42jh ~]# facter -y macaddress
macaddress: "00:50:56:9a:8f:a7"

But puppet facts --render-as yaml doesn't know about the type information, and emits it in the plain style:

[root@ka8y738etxt42jh ~]# puppet --version
6.4.0
[root@ka8y738etxt42jh ~]# puppet facts --render-as yaml | grep macaddress
  macaddress: 00:50:56:9a:8f:a7
  macaddress_ens160: 00:50:56:9a:8f:a7

Since fact types are not sent along with the facts to the puppetserver, I don't know if there's anything that we can do differently? /cc Branan Riley, Henrik Lindberg

Branan Riley (JIRA)

unread,
Apr 15, 2019, 5:06:03 PM4/15/19
to puppe...@googlegroups.com
Branan Riley commented on Bug PUP-9505

Some quick poking shows we're properly passing the mac address as a String object to Ruby from CFacter, and that the YAML serialization correctly quotes a string that's possibly parseable as an integer:

irb(main):006:0> Facter.value('macaddress').class
=> String
irb(main):007:0> require 'yaml'
=> true
irb(main):008:0> YAML.dump(Facter.value('macaddress'))
=> "--- d4:81:d7:24:87:6f\n...\n"
irb(main):009:0> YAML.dump("44:49:56")
=> "--- '44:49:56'\n"

This is with Facter 3.11.5 and Ruby 2.4.3 on my laptop. I'm unsure how we're ending up with unquoted values in the YAML output - possibly this is a ruby version issue that causes different behaviors with the output here? This would probably be a Ruby bug, in that case.

Josh Cooper (JIRA)

unread,
Sep 17, 2019, 11:28:05 PM9/17/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Grooming

Josh Cooper (Jira)

unread,
Jun 11, 2020, 12:37:02 AM6/11/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sub-team: ghost
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Jun 11, 2020, 12:37:03 AM6/11/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Coremunity Night's Watch

Bogdan Irimie (Jira)

unread,
Jun 12, 2020, 5:45:04 AM6/12/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Attachment: puppet_facts__render_as_yaml
Attachment: facter4_yaml_with_numbers
Attachment: facter4_yaml_with_letters

Mihai Buzgau (Jira)

unread,
Aug 11, 2020, 8:24:05 AM8/11/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: ready for triage

Alexander Fisher (Jira)

unread,
Aug 13, 2020, 5:51:03 AM8/13/20
to puppe...@googlegroups.com
Alexander Fisher commented on Bug PUP-9505
 
Re: Fact yaml should quote mac addresses.

Yes, it's a ruby version issue and a bug IMO.   I opened a ticket https://github.com/ruby/psych/issues/387 but got zero feedback. Could this be monkey-patched or similar in puppet??

Another Foreman user hit the same issue yesterday with a fact that contains scsi-ids.  See https://community.theforeman.org/t/custom-facts-in-foreman/20036

Bogdan Irimie (Jira)

unread,
Sep 9, 2020, 9:59:04 AM9/9/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
 
Change By: Bogdan Irimie
Sprint: ready for triage ghost-16.09

Bogdan Irimie (Jira)

unread,
Sep 9, 2020, 10:00:05 AM9/9/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Story Points: 1

Bogdan Irimie (Jira)

unread,
Sep 16, 2020, 9:11:04 AM9/16/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-16.09 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Sep 23, 2020, 9:11:04 AM9/23/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-16.09, ghost-23.09 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Sep 30, 2020, 9:04:06 AM9/30/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-16.09, ghost-23.09, ghost-30.09 , ready for triage 2

Oana Tanasoiu (Jira)

unread,
Sep 30, 2020, 2:53:03 PM9/30/20
to puppe...@googlegroups.com
Oana Tanasoiu assigned an issue to Oana Tanasoiu
Change By: Oana Tanasoiu
Assignee: Oana Tanasoiu

Bogdan Irimie (Jira)

unread,
Oct 7, 2020, 9:05:04 AM10/7/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-16.09, ghost-23.09, ghost-30.09, ghost-7.10 , ready for triage 2

Josh Cooper (Jira)

unread,
Oct 8, 2020, 12:39:04 PM10/8/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9505
 
Re: Fact yaml should quote mac addresses.

Merged to master in https://github.com/puppetlabs/puppet/commit/c12840426e42580d85271efd78062ebfe9840624

FACTER_QUOTED=64:52:11:22:03:25 bundle exec puppet facts find . --render_as yaml | grep quoted
  quoted: "64:52:11:22:03:25"

Josh Cooper (Jira)

unread,
Oct 8, 2020, 12:40:04 PM10/8/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Fix Version/s: PUP 6.19.0

Oana Tanasoiu (Jira)

unread,
Oct 8, 2020, 4:37:04 PM10/8/20
to puppe...@googlegroups.com
Oana Tanasoiu updated an issue
Change By: Oana Tanasoiu
Release Notes: Bug Fix

Oana Tanasoiu (Jira)

unread,
Oct 8, 2020, 4:42:03 PM10/8/20
to puppe...@googlegroups.com
Oana Tanasoiu updated an issue
Change By: Oana Tanasoiu
Release Notes Summary: Previously when puppet facts were called with `--render-as yaml` option, `macaddress` fact was unquoted which can result in some bad data if other tools will parse the resulted yaml and will interpret the value as a sexagesimal (base 60) integer if the address address doesn't contain any chars A-F.

The fix consists in quoting all yaml strings that contain the `:` character (macaddress, ipv6 ip addresses and date/time facts)

Claire Cadman (Jira)

unread,
Oct 12, 2020, 9:24:02 AM10/12/20
to puppe...@googlegroups.com
Claire Cadman updated an issue
Change By: Claire Cadman
Labels: community doc_reviewed platform_7
Reply all
Reply to author
Forward
0 new messages