lib/bundler/audit/cli.rb in mrjoy-bundler-audit-0.3.4 vs lib/bundler/audit/cli.rb in mrjoy-bundler-audit-0.3.5

- old
+ new

@@ -34,11 +34,16 @@ desc 'check', 'Checks the Gemfile.lock for insecure dependencies' method_option :verbose, :type => :boolean, :aliases => '-v' method_option :ignore, :type => :array, :aliases => '-i' def check - scanner = Scanner.new + begin + scanner = Scanner.new + rescue ArgumentError + print_setup_instructions + exit 1 + end vulnerable = false # attempt update the database before doing a scan scanner.database.update! @@ -69,13 +74,24 @@ puts "ruby-advisory-db: #{Database.new.size} advisories" end desc 'version', 'Prints the bundler-audit version' def version - database = Database.new + cmd = File.basename($0) + advisories = nil + begin + database = Database.new + advisories = " (advisories: #{database.size})" + rescue ArgumentError + # Don't have a database yet. + end - puts "#{File.basename($0)} #{VERSION} (advisories: #{database.size})" + say "#{cmd} #{VERSION}#{advisories}", :bold + if advisories.nil? + print_setup_instructions + exit 1 + end end protected def say(message="", color=nil) @@ -104,9 +120,19 @@ say end protected + + def print_setup_instructions + say "" + print_warning "You don't have a copy of the Ruby vulnerabilities database yet." + print_warning "To get the database, please run:" + say "" + print_warning " #{$0} update" + say "" + end + def print_affected_gem(gem) say "Name: ", :red say gem.name say "Version: ", :red