From 369e61d0cdd77fa3f64b4da9a4002f9f6ed9b559 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sat, 3 Oct 2015 23:39:09 +0200 Subject: [PATCH 1/3] feature: add path to target specification Signed-off-by: Dominik Richter --- lib/vulcano/backend.rb | 13 ++++++++----- test/unit/backend_test.rb | 7 +++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/vulcano/backend.rb b/lib/vulcano/backend.rb index b3bd76489..c3aa0df5e 100644 --- a/lib/vulcano/backend.rb +++ b/lib/vulcano/backend.rb @@ -24,11 +24,14 @@ module Vulcano return conf if conf['target'].to_s.empty? uri = URI.parse(conf['target'].to_s) - conf['backend'] = conf['backend'] || uri.scheme - conf['host'] = conf['host'] || uri.host - conf['port'] = conf['port'] || uri.port - conf['user'] = conf['user'] || uri.user - conf['password'] = conf['password'] || uri.password + unless uri.host.nil? and uri.scheme.nil? + conf['backend'] ||= uri.scheme + conf['host'] ||= uri.host + conf['port'] ||= uri.port + conf['user'] ||= uri.user + conf['password'] ||= uri.password + conf['path'] ||= uri.path + end # return the updated config conf diff --git a/test/unit/backend_test.rb b/test/unit/backend_test.rb index e882e0af2..1f755d56e 100644 --- a/test/unit/backend_test.rb +++ b/test/unit/backend_test.rb @@ -16,7 +16,7 @@ describe 'Vulcano::Backend' do describe 'target config helper' do it 'configures resolves target' do org = { - 'target' => 'ssh://user:pass@host.com:123', + 'target' => 'ssh://user:pass@host.com:123/path', } res = Vulcano::Backend.target_config(org) res['backend'].must_equal 'ssh' @@ -25,17 +25,19 @@ describe 'Vulcano::Backend' do res['password'].must_equal 'pass' res['port'].must_equal 123 res['target'].must_equal org['target'] + res['path'].must_equal '/path' org.keys.must_equal ['target'] end it 'resolves a target while keeping existing fields' do org = { - 'target' => 'ssh://user:pass@host.com:123', + 'target' => 'ssh://user:pass@host.com:123/path', 'backend' => rand, 'host' => rand, 'user' => rand, 'password' => rand, 'port' => rand, + 'path' => rand } res = Vulcano::Backend.target_config(org) res.must_equal org @@ -51,6 +53,7 @@ describe 'Vulcano::Backend' do res['user'].must_be_nil res['password'].must_be_nil res['port'].must_be_nil + res['path'].must_be_nil res['target'].must_equal org['target'] end end From 491da065664d6bbb9642f4d5a2bedffcb346ae18 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sat, 3 Oct 2015 23:44:43 +0200 Subject: [PATCH 2/3] add configuration of login path to executable Signed-off-by: Dominik Richter --- bin/vulcano | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/vulcano b/bin/vulcano index c22626cfe..86d5b3cb8 100755 --- a/bin/vulcano +++ b/bin/vulcano @@ -57,6 +57,8 @@ class VulcanoCLI < Thor desc: 'Login password for a remote scan, if required.' option :key, type: :string, default: nil, desc: 'Login key or certificate file for a remote scan.' + option :path, type: :string, default: nil, + desc: 'Login path to use in connectin to the target.' option :disable_sudo, type: :boolean, default: false, desc: 'To not run remote scans via sudo.' option :sudo_password, type: :string, default: nil, From fede3fb9fd00b4fdecf67a1918d7b3cc2f9150b6 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sat, 3 Oct 2015 23:49:01 +0200 Subject: [PATCH 3/3] use target path in configuring specinfra winrm Signed-off-by: Dominik Richter --- lib/vulcano/backend/specinfra_winrm.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vulcano/backend/specinfra_winrm.rb b/lib/vulcano/backend/specinfra_winrm.rb index 81620e48d..087857f90 100644 --- a/lib/vulcano/backend/specinfra_winrm.rb +++ b/lib/vulcano/backend/specinfra_winrm.rb @@ -18,7 +18,10 @@ class Vulcano::Backends::SpecinfraHelper port ||= 5985 end - "#{scheme}://#{host}:#{port}/wsman" + path = conf['path'] || '/wsman' + path.prepend('/') unless path.start_with?('/') + + "#{scheme}://#{host}:#{port}#{path}" end def self.configure(conf)