Sha256: 41dc1b37a8e9fa9e012b187a13a102439c4dc278a671e899f7dcba26719f133f

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

require "json"
require "thor"

require "thread/pool"

module WhatWeb
  class CLI < Thor
    desc "scan URL", "Scan against a given URL"
    method_option :aggressive, type: :boolean, default: false
    method_option :user_agent, type: :string
    method_option :max_threads, type: :numeric, default: 10
    def scan(url)
      user_agent = options[:user_agent]
      is_aggressive = options[:aggressive]
      max_threads = options[:max_threads]

      with_error_handling do
        hash = WhatWeb.execute_plugins(url, user_agent: user_agent, is_aggressive: is_aggressive, max_threads: max_threads)
        puts hash.to_json
      end
    end

    desc "list_plugins", "List all plugins"
    def list_plugins
      with_error_handling do
        puts WhatWeb.plugin_names.to_json
      end
    end

    no_commands do
      def with_error_handling
        yield
      rescue StandardError => e
        puts "Warning: #{e}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_whatweb-0.4.1 lib/whatweb/cli.rb
simple_whatweb-0.4.0 lib/whatweb/cli.rb