Method: Chef::Compliance::Reporter::Automate#strip_profiles_meta

Defined in:
lib/chef/compliance/reporter/automate.rb

#strip_profiles_meta(report, missing_report_shas, run_time_limit) ⇒ Object

TODO: This mutates the report and probably doesn’t need to.



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/chef/compliance/reporter/automate.rb', line 183

def strip_profiles_meta(report, missing_report_shas, run_time_limit)
  report[:profiles].each do |p|
    next if missing_report_shas.include?(p[:sha256])

    p.delete_if { |f| SEEN_PROFILE_UNNECESSARY_FIELDS.include?(f) }

    next unless p[:controls].is_a?(Array)

    p[:controls].each do |c|
      c.delete_if { |f| SEEN_PROFILE_UNNECESSARY_CONTROL_FIELDS.include?(f) }
      c.delete(:waiver_data) if c[:waiver_data] == {}

      next unless c[:results].is_a?(Array)

      c[:results].each do |r|
        if r[:run_time].is_a?(Float) && r[:run_time] < run_time_limit
          r.delete(:start_time)
          r.delete(:run_time)
        end
      end
    end
  end
  report[:run_time_limit] = run_time_limit
  report
end