puppetlabs / puppetlabs/puppet-resource_api

missing validation of attribute names containing upper case characters

Open
#243 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
27
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Describe the Bug

register_type accepts attribute names containing upper case characters. Puppet will happily downcase those for internal processing, without RSAPI noticing. this in turn leads to random-looking failures later in processing.

Expected Behavior

RSAPI register_type and register_transport refuse to accept attribute/connection_info keys that do not conform to all-lower-case snake casing rules (all lowercase, numbers, underscores, starts with letter).

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a new type called some with a mandatory attribute called someThing
  2. Run puppet apply -e 'some { foo: }

Will fail with:

david@davids:~/tmp/foo$ pdk bundle exec puppet apply -e 'some { test: }' --verbose --trace --modulepath spec/fixtures/modules
pdk (INFO): Using Ruby 2.5.7
pdk (INFO): Using Puppet 6.10.1
Notice: Compiled catalog for localhost in environment production in 0.11 seconds
Info: Applying configuration version '1573033174'
Error: /Stage[main]/Some[test]: Could not evaluate: The following mandatory attributes were not provided:
    *  SomeThing
/opt/puppetlabs/pdk/private/puppet/ruby/2.5.0/gems/puppet-resource_api-1.8.7/lib/puppet/resource_api.rb:342:in `raise_missing_attrs'
/opt/puppetlabs/pdk/private/puppet/ruby/2.5.0/gems/puppet-resource_api-1.8.7/lib/puppet/resource_api.rb:289:in `retrieve'
/opt/puppetlabs/pdk/share/cache/ruby/2.5.0/gems/puppet-6.10.1/lib/puppet/type.rb:1133:in `retrieve_resource'
[...]

Additional Context

This problem was originally reported and diagnosed by Brian Dinga on the community slack.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search for the register_type and register_transport entry points and reproduce the reported mixed-case attribute failure. Verify the existing registration behavior for attribute and connection_info keys, then confirm that invalid names are refused according to the stated lowercase snake-case rules. No specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.