Sha256: 86ba37e79b04340e1820194e19ca266bdfd50ffeff8ceac921211fe1692256c0

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

#!/usr/bin/env ruby
require 'ostruct'
require 'optparse'
require 'hrw'

ARGV << '--help' if ARGV.empty?

options = OpenStruct.new
OptionParser.new do |opt|
  opt.banner = "usage: #{__FILE__} [OPTIONS]"

  opt.on('-u', '--url [URL]', 'remote api url') do |url|
    options.url = url
  end
end.parse!

if options.url.nil?
  if ENV.key?(Hrw::ENV)
    options.url = ENV[Hrw::ENV]
  else
    puts '[-] no url'
    exit(1)
  end
end

begin
  scanner = Hrw::Detector.detect
  specs = scanner.scan

  api = Hrw::API.new(options.url)
  hash = api.submit(specs)
  result = api.retrieve(hash)

  formatter = Hrw::Formatter.new
  vulnerable_deps = formatter.format(result)

  unless vulnerable_deps.empty?
    formatter.print_vulnerable_deps(vulnerable_deps)
    exit(1)
  end
rescue StandardError => ex
  require 'pry-byebug'
  binding.pry
  puts ex.message
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hrw-0.1.0 exe/hrw