make it into a cmdline program

This commit is contained in:
kenna-bmcdevitt 2020-10-27 02:19:16 -05:00
parent fa13eeab27
commit 474b6eb30e
3 changed files with 24 additions and 3 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,24 @@
#!/usr/bin/env ruby
require './microsoft_kb_checker.rb'
require 'optparse'
ARGV << '-h' if ARGV.empty?
params = {}
OptionParser.new do |opts|
opts.banner = "Usage: microsoft_cve_audit.rb [OPTIONS]"
opts.on('-c NAME', '--cve', "The cve id to check.") { |c| params[:cve_id] = c }
opts.on('-o NAME', '--os', "The operating system to check.") {|o| params[:os_name] = o }
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end.parse!(into: params)
raise OptionParser::MissingArgument if params[:cve_id].nil?
raise OptionParser::MissingArgument if params[:os_name].nil?
puts MicrosoftKbChecker.new(params).query_cve

View file

@ -108,8 +108,6 @@ class MicrosoftKbChecker
AVAILABLE_OS.include?(options[:os_name])
end
def select_os(json)
json.dig('affectedProducts').select do |os|
os.values_at('name', 'platform').include? options[:os_name]