Merge pull request #43 from chef/detect

Add detect command
This commit is contained in:
Christoph Hartmann 2015-09-23 10:36:51 +02:00
commit fc9bc11b71
3 changed files with 62 additions and 29 deletions

View file

@ -44,7 +44,9 @@ You should now be able to run:
vulcano --help
```
## Configuration
## Usage
### exec
Run tests against different targets:
@ -62,6 +64,21 @@ vulcano exec test.rb -t winrm://Administrator@windowshost --password 'your-passw
vulcano exec test.rb -t docker://container_id
```
### detect
Verify your configuration and detect
```bash
id=$( docker run -dti ubuntu:14.04 /bin/bash )
vulcano detect -t docker://$id
```
Which will provide you with:
```
{"family":"ubuntu","release":"14.04","arch":null}
```
## Custom resources
You can easily create your own resources. Here is a custom resource for an

View file

@ -42,9 +42,7 @@ class VulcanoCLI < Thor
end
end
desc 'exec PATHS', 'run all test files'
option :id, type: :string,
desc: 'Attach a profile ID to all test results'
def self.target_options
option :target, aliases: :t, type: :string, default: nil,
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
option :backend, aliases: :b, type: :string, default: nil,
@ -69,6 +67,12 @@ class VulcanoCLI < Thor
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.'
end
desc 'exec PATHS', 'run all test files'
option :id, type: :string,
desc: 'Attach a profile ID to all test results'
target_options
option :format, type: :string, default: 'progress'
def exec(*tests)
runner = Vulcano::Runner.new(options)
@ -77,5 +81,17 @@ class VulcanoCLI < Thor
rescue RuntimeError => e
puts e.message
end
desc 'detect', 'detect the target OS'
target_options
def detect
runner = Vulcano::Runner.new(options)
rel = File.join(File.dirname(__FILE__), *%w{.. lib utils detect.rb})
detect_util = File.expand_path(rel)
runner.add_tests([detect_util])
runner.run
rescue RuntimeError => e
puts e.message
end
end
VulcanoCLI.start(ARGV)

View file

@ -6,10 +6,10 @@
# print OS detection infos
conf = {
os_name: os[:name],
os_family: os[:family],
os_release: os[:release],
os_arch: os[:arch],
name: os[:name],
family: os[:family],
release: os[:release],
arch: os[:arch],
}
puts JSON.dump(conf)
exit 0