diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-04-18 21:56:13 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-04-18 22:07:45 -0700 |
commit | 0656a02111ad32ccccdc92e29d53a32b2c8dd66e (patch) | |
tree | 1cd3e7e5143d1f5c2ad77fa813f5ac7ccaf4063c /lib/chef/node.rb | |
parent | c36403d741d7d51159fac3233e7eb5801eb44db4 (diff) | |
download | chef-0656a02111ad32ccccdc92e29d53a32b2c8dd66e.tar.gz |
fix default/override attribute blacklists and whitelistslcg/fix-the-blacklist
looks like these have been broken for some time, the tests were only
testing automatic level (which has no "combined" hash version) and
the specs were injecting a plain old hash, so were failing to catch
this error on multiple different levels.
since the automatic level worked and since mostly people use automatic
blacklisting to remove junk from ohai it was very uncommon to hit
this bug.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node.rb')
-rw-r--r-- | lib/chef/node.rb | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index c945bb640f..021cf33eb8 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -480,13 +480,10 @@ class Chef # Transform the node to a Hash def to_hash - index_hash = Hash.new + index_hash = attributes.to_hash index_hash["chef_type"] = "node" index_hash["name"] = name index_hash["chef_environment"] = chef_environment - attribute.each do |key, value| - index_hash[key] = value - end index_hash["recipe"] = run_list.recipe_names if run_list.recipe_names.length > 0 index_hash["role"] = run_list.role_names if run_list.role_names.length > 0 index_hash["run_list"] = run_list.run_list_items @@ -497,10 +494,10 @@ class Chef display = {} display["name"] = name display["chef_environment"] = chef_environment - display["automatic"] = automatic_attrs - display["normal"] = normal_attrs - display["default"] = attributes.combined_default - display["override"] = attributes.combined_override + display["automatic"] = attributes.automatic.to_hash + display["normal"] = attributes.normal.to_hash + display["default"] = attributes.combined_default.to_hash + display["override"] = attributes.combined_override.to_hash display["run_list"] = run_list.run_list_items display end @@ -515,11 +512,11 @@ class Chef "name" => name, "chef_environment" => chef_environment, "json_class" => self.class.name, - "automatic" => attributes.automatic, - "normal" => attributes.normal, + "automatic" => attributes.automatic.to_hash, + "normal" => attributes.normal.to_hash, "chef_type" => "node", - "default" => attributes.combined_default, - "override" => attributes.combined_override, + "default" => attributes.combined_default.to_hash, + "override" => attributes.combined_override.to_hash, # Render correctly for run_list items so malformed json does not result "run_list" => @primary_runlist.run_list.map { |item| item.to_s }, } |