2015-06-07 19:41:54 +00:00
|
|
|
#!/usr/bin/env ruby
|
2015-09-03 18:36:46 +00:00
|
|
|
# encoding: utf-8
|
2015-06-07 19:41:54 +00:00
|
|
|
# Copyright 2015 Dominik Richter. All rights reserved.
|
|
|
|
|
|
|
|
require 'thor'
|
|
|
|
require 'json'
|
|
|
|
require_relative '../lib/vulcano'
|
|
|
|
|
|
|
|
class VulcanoCLI < Thor
|
2015-09-03 18:35:23 +00:00
|
|
|
desc 'json PATH', 'read all tests in PATH and generate a JSON-profile'
|
2015-06-07 19:41:54 +00:00
|
|
|
option :output, aliases: :o, type: :string
|
|
|
|
option :print, aliases: :p, type: :boolean
|
2015-06-25 15:45:46 +00:00
|
|
|
option :id, type: :string
|
2015-06-07 19:41:54 +00:00
|
|
|
def json(*paths)
|
2015-08-12 19:03:41 +00:00
|
|
|
require_relative '../lib/verify'
|
2015-06-07 19:41:54 +00:00
|
|
|
paths.each do |path|
|
2015-06-10 15:54:35 +00:00
|
|
|
Vulcano::Profiles.new.valid_folder? path unless options[:print]
|
2015-06-25 15:45:46 +00:00
|
|
|
vc = Vulcano::Profiles.new({ quiet: options[:print], id: options[:id] })
|
2015-06-07 19:41:54 +00:00
|
|
|
vc.add_folder(path)
|
|
|
|
if options[:print]
|
2015-09-04 07:59:30 +00:00
|
|
|
puts JSON.pretty_generate(vc.profiles)
|
2015-06-07 19:41:54 +00:00
|
|
|
else
|
2015-09-04 07:59:30 +00:00
|
|
|
dst = options[:output] || File.join(path, '.vulcano.json')
|
2015-09-04 07:15:20 +00:00
|
|
|
if File.exist? dst
|
2015-06-07 19:41:54 +00:00
|
|
|
puts "----> updating #{dst}"
|
|
|
|
else
|
|
|
|
puts "----> creating #{dst}"
|
|
|
|
end
|
2015-09-04 07:15:20 +00:00
|
|
|
fdst = File.expand_path(dst)
|
|
|
|
File.write(fdst, JSON.dump(vc.profiles))
|
2015-06-07 19:41:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-03 18:35:23 +00:00
|
|
|
desc 'check PATH', 'check all tests in PATH'
|
2015-06-10 15:03:12 +00:00
|
|
|
def check(*paths)
|
2015-08-12 19:03:41 +00:00
|
|
|
require_relative '../lib/verify'
|
2015-06-10 15:03:12 +00:00
|
|
|
paths.each do |path|
|
|
|
|
puts "#{path}"
|
|
|
|
Vulcano::Profiles.new.valid_folder? path
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
2015-06-07 19:41:54 +00:00
|
|
|
|
2015-09-03 18:35:23 +00:00
|
|
|
desc 'exec PATHS', 'run all test files'
|
2015-08-13 00:05:32 +00:00
|
|
|
option :id, type: :string,
|
|
|
|
desc: 'Attach a profile ID to all test results'
|
2015-08-30 02:46:46 +00:00
|
|
|
option :target, aliases: :t, type: :string, default: nil,
|
2015-08-13 00:05:32 +00:00
|
|
|
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
|
2015-08-30 02:46:46 +00:00
|
|
|
option :backend, aliases: :b, type: :string, default: nil,
|
2015-08-13 00:05:32 +00:00
|
|
|
desc: 'Choose a backend: exec (run locally), ssh, winrm.'
|
|
|
|
option :host, type: :string,
|
|
|
|
desc: 'Specify a remote host which is tested.'
|
|
|
|
option :port, type: :numeric,
|
|
|
|
desc: 'Specify the login port for a remote scan.'
|
2015-09-10 11:18:18 +00:00
|
|
|
option :user, type: :string, default: nil,
|
2015-08-13 00:05:32 +00:00
|
|
|
desc: 'The login user for a remote scan.'
|
|
|
|
option :password, type: :string, default: nil,
|
|
|
|
desc: 'Login password for a remote scan, if required.'
|
|
|
|
option :key_file, type: :string, default: nil,
|
|
|
|
desc: 'Login key or certificate file for a remote scan.'
|
|
|
|
option :disable_sudo, type: :boolean, default: false,
|
|
|
|
desc: 'To not run remote scans via sudo.'
|
|
|
|
option :sudo_password, type: :string, default: nil,
|
|
|
|
desc: 'Specify a sudo password, if it is required.'
|
|
|
|
option :sudo_options, type: :string, default: '',
|
|
|
|
desc: 'Additional sudo options for a remote scan.'
|
|
|
|
option :winrm_self_signed, type: :boolean, default: false,
|
|
|
|
desc: 'Allow remote scans with WinRM to run on self-signed certificates.'
|
|
|
|
option :winrm_ssl, type: :boolean, default: false,
|
|
|
|
desc: 'Configure WinRM scans to run via SSL instead of pure HTTP.'
|
2015-09-02 14:44:14 +00:00
|
|
|
option :format, type: :string, default: 'progress'
|
2015-08-28 17:13:05 +00:00
|
|
|
def exec(*tests)
|
2015-09-18 14:56:31 +00:00
|
|
|
runner = Vulcano::Runner.new(options)
|
2015-08-28 17:13:05 +00:00
|
|
|
runner.add_tests(tests)
|
2015-08-12 22:16:50 +00:00
|
|
|
runner.run
|
2015-08-29 23:31:36 +00:00
|
|
|
rescue RuntimeError => e
|
|
|
|
puts e.message
|
2015-08-12 19:03:41 +00:00
|
|
|
end
|
2015-06-07 19:41:54 +00:00
|
|
|
end
|
|
|
|
VulcanoCLI.start(ARGV)
|