Jira (PUP-10585) Puppet::Util::Yaml safe_load not loading "Time" class which leads to compilation error for time serial data

37 views
Skip to first unread message

Henry Wang (Jira)

unread,
Jul 14, 2020, 11:47:03 PM7/14/20
to puppe...@googlegroups.com
Henry Wang created an issue
 
Puppet / Bug PUP-10585
Puppet::Util::Yaml safe_load not loading "Time" class which leads to compilation error for time serial data
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2020/07/14 8:46 PM
Environment:

PE 2019.8, but I think this should happen for:

(1) any environment using safe_load

(2) any classes not in the default list

Priority: High High
Reporter: Henry Wang

Puppet Version: 6.16.0

Puppet Server Version: PE 2019.8
OS Name/Version: RHEL

Customer is using `audit -> mtime` in a file resource. When the time is saved into transactionstore.yaml. The next puppet agent run will fail with the following error:

Error: Transaction store file /opt/puppetlabs/puppet/cache/state/transactionstore.yaml is corrupt ((/opt/puppetlabs/puppet/cache/state/transactionstore.yaml): Tried to load unspecified class: Time); replacing
Wrapped exception:
Tried to load unspecified class: Time 

This should be because Puppet::Util::Yaml is using safe_load now and by default "Time" class is not permitted to load.

Desired Behavior: Understand that there should be some security concerns to contain only few classes by default. The Puppet::Util::Yaml has a parameter called 'allowed_classes'. Thus, an option to configure 'allowed_classes' from Puppet (for example) Hiera is expected. Otherwise, as long as there are needs such as auditing time from this case, the Classes out of the list will trigger the same error message.

Actual Behavior: 

Error: Transaction store file /opt/puppetlabs/puppet/cache/state/transactionstore.yaml is corrupt ((/opt/puppetlabs/puppet/cache/state/transactionstore.yaml): Tried to load unspecified class: Time); replacing
Wrapped exception:
Tried to load unspecified class: Time

How to Reproduce:

Define a file resource in manifest:

file { $file_path :
audit => mtime,
} 

(1) Touch the file.

(2) edited the file once. 

(3) Run puppet agent -t, can see successful logging the time.

Info: Loading facts
Info: Caching catalog for pe-201980-agent.platform9.puppet.net
Info: Applying configuration version 'pe-201980-master-production-6e5f8c73c43'
Notice: /Stage[main]/Ggtest::Selva/File[/tmp/text.abc]/mtime: audit change: previously recorded value '2020-07-15 03:11:23 +0000' has been changed to '2020-07-15 03:43:48 +0000'
Notice: Applied catalog in 0.12 seconds
[root@pe-201980-agent ~]# 

Meanwhile, the content of /opt/puppetlabs/puppet/cache/state/transactionstore.yaml managed to store that data.

---
resources:
  File[/tmp/text.abc]:
    parameters:
      mtime:
        system_value:
        - 2020-07-15 03:43:48.772919060 +00:00
      ensure:
        system_value: 

(4) run puppet agent once more with the following error of unable to load Time class:

Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for pe-201980-agent.platform9.puppet.net
Error: Transaction store file /opt/puppetlabs/puppet/cache/state/transactionstore.yaml is corrupt ((/opt/puppetlabs/puppet/cache/state/transactionstore.yaml): Tried to load unspecified class: Time); replacing
Wrapped exception:
Tried to load unspecified class: Time
Info: Applying configuration version 'pe-201980-master-production-6e5f8c73c43'
Notice: Applied catalog in 0.07 seconds
[root@pe-201980-agent ~]# 

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Henry Wang (Jira)

unread,
Jul 14, 2020, 11:48:03 PM7/14/20
to puppe...@googlegroups.com
Henry Wang updated an issue
Change By: Henry Wang
Environment: Tested in PE 2019.8, but I think this should happen for:


(1) any environment using safe_load

(2) any classes not in the default list

zendesk.jira (Jira)

unread,
Jul 14, 2020, 11:50:04 PM7/14/20
to puppe...@googlegroups.com

zendesk.jira (Jira)

unread,
Jul 14, 2020, 11:50:04 PM7/14/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 15, 2020, 12:56:05 AM7/15/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10585
 
Re: Puppet::Util::Yaml safe_load not loading "Time" class which leads to compilation error for time serial data

This was supposed to have been fixed in PUP-7834, specifically commit 0b6563eea09fba09b6201e1a3c41cbc5a688600d.

Josh Cooper (Jira)

unread,
Jul 15, 2020, 1:30:03 AM7/15/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10585

Using 6.4.5:

Error: Transaction store file /opt/puppetlabs/puppet/cache/state/transactionstore.yaml is corrupt ((/opt/puppetlabs/puppet/cache/state/transactionstore.yaml): Tried to load unspecified class: Time); replacing
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/yaml.rb:32:in `rescue in safe_load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/yaml.rb:26:in `safe_load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/yaml.rb:42:in `safe_load_file'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/persistence.rb:65:in `block in load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:236:in `benchmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/persistence.rb:63:in `load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:104:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:239:in `block (2 levels) in apply'

Looks like storage.rb was updated to allow Time but not persistence.rb

Josh Cooper (Jira)

unread,
Jul 15, 2020, 1:59:03 AM7/15/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 15, 2020, 1:59:04 AM7/15/20
to puppe...@googlegroups.com

Henry Wang (Jira)

unread,
Jul 15, 2020, 2:39:03 AM7/15/20
to puppe...@googlegroups.com
Henry Wang commented on Bug PUP-10585
 
Re: Puppet::Util::Yaml safe_load not loading "Time" class which leads to compilation error for time serial data

Josh Cooper Fantastic! yeah, I saw it, double confirm in 6.16.0, same persistence.rb:

Error: Transaction store file /opt/puppetlabs/puppet/cache/state/transactionstore.yaml is corrupt ((/opt/puppetlabs/puppet/cache/state/transactionstore.yaml): Tried to load unspecified class: Time); replacing
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/yaml.rb:32:in `rescue in safe_load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/yaml.rb:26:in `safe_load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/yaml.rb:42:in `safe_load_file'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/persistence.rb:65:in `block in load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:238:in `benchmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/persistence.rb:63:in `load' 

Glad team has decided to whitelist Time as well as Symbol classes.

 

Josh Cooper (Jira)

unread,
Jul 15, 2020, 1:34:03 PM7/15/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 16, 2020, 12:58:03 PM7/16/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 16, 2020, 12:59:03 PM7/16/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 16, 2020, 1:05:04 PM7/16/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: If the previous agent run enforced a time-based property of a resource, then the next agent run generated an error and lost the ability to report on corrective changes accurately. This could occur when using the {{audit}} metaparameter to monitor file mtime.

Claire Cadman (Jira)

unread,
Aug 13, 2020, 5:53:03 AM8/13/20
to puppe...@googlegroups.com

Vadym Chepkov (Jira)

unread,
Aug 20, 2020, 1:04:03 PM8/20/20
to puppe...@googlegroups.com
Vadym Chepkov commented on Bug PUP-10585
 
Re: Puppet::Util::Yaml safe_load not loading "Time" class which leads to compilation error for time serial data

Josh Cooper, not sure if I need to open another ticket, but seems some edge cases still exists for audit metaparameter,

For instance, on Windows platform, this code also produces one-time errors

 
file { $pkg_source:
    audit  => 'owner',
}

err:[/Stage[main]/Splunk::Install/File[E:/Apps/staging/splunk/splunkforwarder-7.3.7-9d9aa3f78593-x64-release.msi]]: Could not evaluate: undefined method `+' for :absent:Symbol

Josh Cooper (Jira)

unread,
Aug 20, 2020, 1:13:03 PM8/20/20
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages