Sha256: 209d1dc771160e623c3bbdcd0159a3f97e3295a6c36cf655a27178535ba25236
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true module Ryo class CLI < Thor desc "dir URL", "Discover directories and files belong to a given URL" def dir(url) hash = run_discovery(url, dir: true) puts hash.to_json end desc "subdomain URL", "Discover subdomains of a given URL" def subdomain(url) hash = run_discovery(url, subdomain: true) puts hash.to_json end desc "tech URL", "Discover used technolgies of a given URL" def tech(url) hash = run_discovery(url, tech: true) puts hash.to_json end desc "whois URL", "Discover whois information of a given URL" def whois(url) hash = run_discovery(url, whois: true) puts hash.to_json end desc "discover URL", "Run discovery plugin(s) against a given URL" method_option :dir, type: :boolean, default: false method_option :subdomain, type: :boolean, default: false method_option :tech, type: :boolean, default: false method_option :whois, type: :boolean, default: false def discovery(url) hash = run_discovery(url, options) puts hash.to_json end desc "all URL", "Run all discovery plugins against a given URL" def all(url) hash = run_discovery(url, all: true) puts hash.to_json end no_commands do def validate_url(url) uri = URI.parse(url) raise InvalidURLError unless %w(http https).include?(uri.scheme) end def validate_options(options) raise InvalidOptionsError unless options.any? { |_, v| v } end def run_discovery(url, options) validate_url(url) validate_options(options) Ryo.discover url, options rescue InvalidURLError => _ { error: "Please input a valid URL" } rescue InvalidOptionsError => _ { error: "Please input at least one option" } rescue StandardError => e { error: "Warning: #{e}" } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ryo-0.2.0 | lib/ryo/cli.rb |