feature: add configurable profile_id field

Signed-off-by: Dominik Richter <dominik@vulcanosec.com>
This commit is contained in:
Dominik Richter 2015-06-25 17:45:46 +02:00
parent 3440f6f69e
commit 34bc6a387c
3 changed files with 7 additions and 4 deletions

View file

@ -11,10 +11,11 @@ class VulcanoCLI < Thor
desc "json PATH", "read all tests in PATH and generate a JSON-profile"
option :output, aliases: :o, type: :string
option :print, aliases: :p, type: :boolean
option :id, type: :string
def json(*paths)
paths.each do |path|
Vulcano::Profiles.new.valid_folder? path unless options[:print]
vc = Vulcano::Profiles.new({ quiet: options[:print] })
vc = Vulcano::Profiles.new({ quiet: options[:print], id: options[:id] })
vc.add_folder(path)
if options[:print]
puts JSON.pretty_generate( vc.profiles )

View file

@ -52,7 +52,7 @@ module Vulcano
@log.warn "vmetadata.rb doesn't support: #{sth} #{args}"
end
def self.for_path path, log = nil
def self.for_path path, profile_id, log = nil
log ||= Log.new
dpath = File::join(path, 'vmetadata.rb')
if !File::file?(dpath)
@ -61,6 +61,7 @@ module Vulcano
end
res = Metadata.new(log)
res.instance_eval(File::read(dpath), dpath, 1)
res.dict['name'] = profile_id unless profile_id.nil? or profile_id.empty?
return res
end
end

View file

@ -10,6 +10,7 @@ module Vulcano
attr_reader :profiles
def initialize opts = {}
@profiles = {}
@profile_id = opts[:id]
@log = Log.new(opts)
end
@ -31,7 +32,7 @@ module Vulcano
@log.ok "Valid directory"
end
metadata = Metadata.for_path(path)
metadata = Metadata.for_path(path, @profile_id)
@log.ok "vmetadata.rb" unless metadata.nil? or !metadata.valid?
specs = Dir["#{path}/spec/*_spec.rb"]
@ -88,7 +89,7 @@ module Vulcano
def add_specs_in_folder path
allrules = {}
meta = Metadata.for_path(path, @log)
meta = Metadata.for_path(path, @profile_id, @log)
Dir["#{path}/spec/*_spec.rb"].each do |specfile|
rel_path = specfile.sub(File.join(path,''), '')