class A2::Subcommand::Reporting::ListReports
Public Class Methods
new()
click to toggle source
Calls superclass method
A2::Paginated::new
# File lib/a2/subcommands/reporting.rb, line 29 def initialize super('list-reports', takes_commands: false, filter_key: 'type') options.on('-i', '--skip-impact IMPACT', 'Only show reports with an impact score greater than the provided value.') do |impact| @opt[:impact] = impact end end
Public Instance Methods
execute()
click to toggle source
# File lib/a2/subcommands/reporting.rb, line 36 def execute impact = @opt.delete(:impact) with_paginated_filter_json do |json| reports_json = A2::Client.new(command_parser.data).list_reports(json) reports_json = filter_by_min_impact(reports_json, impact) unless impact.nil? puts JSON.pretty_generate(reports_json) end end
filter_by_min_impact(report_json, impact)
click to toggle source
# File lib/a2/subcommands/reporting.rb, line 46 def filter_by_min_impact(report_json, impact) report_json['reports'].delete_if do |report| if impact == 'minor' if report['controls']['failed']['major'].eql?(0) && report['controls']['failed']['critical'].eql?(0) true end elsif impact == 'major' true if report['controls']['failed']['critical'].eql?(0) end end report_json end