lib/inspec/profile.rb in inspec-0.24.0 vs lib/inspec/profile.rb in inspec-0.25.0

- old
+ new

@@ -55,20 +55,24 @@ @params ||= load_params end def info res = params.dup + # add information about the controls controls = res[:controls].map do |id, rule| next if id.to_s.empty? data = rule.dup data.delete(:checks) data[:impact] ||= 0.5 data[:impact] = 1.0 if data[:impact] > 1.0 data[:impact] = 0.0 if data[:impact] < 0.0 [id, data] end res[:controls] = Hash[controls.compact] + + # add information about the required attributes + res[:attributes] = res[:attributes].map(&:to_hash) unless res[:attributes].nil? || res[:attributes].empty? res end # Check if the profile is internall well-structured. The logger will be # used to print information on errors and warnings which are found. @@ -246,16 +250,19 @@ runner.add_profile(self, opts) runner.rules.values.each do |rule| f = load_rule_filepath(prefix, rule) load_rule(rule, f, controls, groups) end + params[:attributes] = runner.attributes else # load from context @runner_context.rules.values.each do |rule| f = load_rule_filepath(prefix, rule) load_rule(rule, f, controls, groups) end + params[:attributes] = @runner_context.attributes end + params end def load_rule_filepath(prefix, rule) file = rule.instance_variable_get(:@__file) file = file[prefix.length..-1] if file.start_with?(prefix)