class SecurityReport::CLI

Attributes

format[RW]

Public Class Methods

new() click to toggle source
# File lib/security_report/cli.rb, line 7
def initialize
  @format = 'plain'
end

Public Instance Methods

help() click to toggle source
# File lib/security_report/cli.rb, line 11
    def help
      puts <<~HELPTEXT
        security_report [options] files...

        -h, --help
          Print this message
        --format
          Provide the format: plain or table (default: plain)
        --update
          Update the vulnerability database before running
      HELPTEXT
      exit
    end
reporter() click to toggle source
# File lib/security_report/cli.rb, line 25
def reporter
  case format
  when 'plain'
    require 'security_report/plain_reporter'
    @reporter = PlainReporter.new
  when 'table'
    require 'security_report/table_reporter'
    @reporter = TableReporter.new
  else
    puts "Unknown format '#{format}'"
    exit 1
  end
end
run(files) click to toggle source
# File lib/security_report/cli.rb, line 45
def run(files)
  auditor = Auditor.audit(files)
  reporter.report(auditor.results, auditor.skipped)
  exit 1 if auditor.results.any?
end
update() click to toggle source
# File lib/security_report/cli.rb, line 39
def update
  return if Database.update
  puts 'Failed updating database!'
  exit 1
end