Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-8704

resource.rb: to_hierayaml does not escape the title

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Template:
      PUP Bug Template
    • Team:
      Coremunity
    • Method Found:
      Needs Assessment
    • QA Risk Assessment:
      Needs Assessment

      Description

      Puppet Version: Anything since 4.0.0-rc1
      Puppet Server Version: n/a
      OS Name/Version: n/a

      In code inspection we found that to_hierayaml does not properly escape the resource's title in https://github.com/puppetlabs/puppet/blob/c99148fc86bfb7da15947e9f70aab2a3b55f941b/lib/puppet/resource.rb#L429

      Desired Behavior:

      puppet resource --to_yaml exec "/bin/echo foo: bar" creates valid YAML output.

      Actual Behavior:

      puppet resource --to_yaml exec "/bin/echo foo: bar" creates invalid YAML output:

      david@davids:~/git/puppet-resource_api$ puppet resource --to_yaml exec "/bin/echo foo: bar"
      exec:
        /bin/echo foo: bar:
          returns: 'notrun'
      david@davids:~/git/puppet-resource_api$ puppet resource --to_yaml exec "/bin/echo foo: bar" | ruby -ryaml -e 'puts YAML.parse(STDIN).inspect'
      Traceback (most recent call last):
      	3: from -e:1:in `<main>'
      	2: from /usr/lib/ruby/2.5.0/psych.rb:350:in `parse'
      	1: from /usr/lib/ruby/2.5.0/psych.rb:402:in `parse_stream'
      /usr/lib/ruby/2.5.0/psych.rb:402:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 21 (Psych::SyntaxError)
      david@davids:~/git/puppet-resource_api$ 
      

      The Resource API has fixed that in https://github.com/puppetlabs/puppet-resource_api/pull/77/commits/478c9254238749d9af8a1633b53f95ed1a01dcde

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              david.schmitt David Schmitt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support