I have a data bag that is used as part of a chef recipe.
When I execute a chef-client command that runs this recipe, the data bag is decrypted and its unencrypted value is logged as part of the chef-client output.
When is the reveal of the sensitive data happening? It should not be happening at decryption. Usually it is when you try and use the decrypted data to write out a template or by calling some orher type of chef resoutce.
template '[pathe to file]' do
source 'template.erb'
sensitive true
end
Apologies for wasting your time on this y'all but it seems like this logic is contained in one of one of our cookbooks:
# commandline length limit? YES! 8200
# concat all environment variables under the nuget product bag into a ;-separated key-value-pair string
arr_additional_args = []
flattened_args = flatten_hash(node[new_resource.cookbook_name])
Chef::Log.info("Additional Chef Arguments to be passed to installer: #{flattened_args}")
flattened_args.each_key do |key|
if key.upcase.include? "PASSWORD" or key.include? "PWD" or key.include? "SCRUB"
flattened_args[key] = msBuildScrubString(flattened_args[key])
end
end
flattened_args.each_pair {|k,v| arr_additional_args.push("#{k}=#{v}") }
Chef::Log.debug("Chef Arguments array after: #{arr_additional_args}")
#If the arguments have semi-colons, comma, quote or double quote in them it will break msbuild property string: replace them with appropriate encoded characters - they will be automatically restored in MSbuild.
arr_additional_args.map!{|v| v.gsub(";","%3B")}
arr_additional_args.map!{|v| v.gsub(",","%2C")}
arr_additional_args.map!{|v| v.gsub("'","%27")}
arr_additional_args.map!{|v| v.gsub('"',"%22")}
additional_args = arr_additional_args.join(";")
Chef::Log.info("Additional Chef Arguments to be passed to installer: #{additional_args}")
I guess I will have to include some conditional logic in here to check for the presence of the 'sensitive' attribute and if its value is set to 'true' not to log these.
Thanks for your replies and I hope that this this helps someone else.