Method: Chef::ResourceCollection::ResourceSet#validate_lookup_spec!
- Defined in:
- lib/chef/resource_collection/resource_set.rb
#validate_lookup_spec!(query_object) ⇒ Object
Returns true if +query_object+ is a valid string for looking up a resource, or raises InvalidResourceSpecification if not. === Arguments
- query_object should be a string of the form "resource_type[resource_name]", a single element Hash (e.g., :service => "apache2"), or a Chef::Resource (this is the happy path). Other arguments will raise an exception. === Returns
- true returns true for all valid input. === Raises
- Chef::Exceptions::InvalidResourceSpecification for all invalid input.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/chef/resource_collection/resource_set.rb', line 124 def validate_lookup_spec!(query_object) # expect query_object to be from a controlled source # codeql[ruby/polynomial-redos] case query_object when Chef::Resource, SINGLE_RESOURCE_MATCH, MULTIPLE_RESOURCE_MATCH, NAMELESS_RESOURCE_MATCH, Hash true when String raise Chef::Exceptions::InvalidResourceSpecification, "The string `#{query_object}' is not valid for resource collection lookup. Correct syntax is `resource_type[resource_name]'" else raise Chef::Exceptions::InvalidResourceSpecification, "The object `#{query_object.inspect}' is not valid for resource collection lookup. " + "Use a String like `resource_type[resource_name]' or a Chef::Resource object" end end |