summaryrefslogtreecommitdiff
path: root/lib/chef/node
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-01-25 12:52:13 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2018-01-25 12:52:13 -0800
commite56f8d58b80334256085907961aac9ca9f56f125 (patch)
treecd0841af833a7a49a37eb52a4abfa68b284f8b0f /lib/chef/node
parent378eaf9a32fe339f34da16f3bef44f2ef18ea16a (diff)
downloadchef-e56f8d58b80334256085907961aac9ca9f56f125.tar.gz
fix node assignment of ImmutableArrays to VividMashes/AttrArrays
node.default['foo'] = node['bar'] need to have node['bar'] have its cache vivified otherwise we potentially get an empty hash or array. in the case of hashes, the assignment must have been walking though the values with #each or something which poked the cache on the target hash which caused it to vivify, so this bug only affected Arrays where the AttrArray initializer likely did a quick-n-dirty copy of the internal structure of the ImmutableArray which was empty. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node')
-rw-r--r--lib/chef/node/attribute_collections.rb2
-rw-r--r--lib/chef/node/mixin/state_tracking.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb
index 6922bcf200..0271febea5 100644
--- a/lib/chef/node/attribute_collections.rb
+++ b/lib/chef/node/attribute_collections.rb
@@ -92,6 +92,7 @@ class Chef
private
def convert_value(value)
+ value.ensure_generated_cache! if value.respond_to?(:ensure_generated_cache!)
case value
when VividMash
value
@@ -189,6 +190,7 @@ class Chef
# AttrArray for consistency and to ensure that the added parts of the
# attribute tree will have the correct cache invalidation behavior.
def convert_value(value)
+ value.ensure_generated_cache! if value.respond_to?(:ensure_generated_cache!)
case value
when VividMash
value
diff --git a/lib/chef/node/mixin/state_tracking.rb b/lib/chef/node/mixin/state_tracking.rb
index 690d261df6..0c3d4c33a4 100644
--- a/lib/chef/node/mixin/state_tracking.rb
+++ b/lib/chef/node/mixin/state_tracking.rb
@@ -1,5 +1,5 @@
#--
-# Copyright:: Copyright 2016-2017, Chef Software Inc.
+# Copyright:: Copyright 2016-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");