mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
feature: include other rules
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
243c7b9892
commit
1b36802589
1 changed files with 30 additions and 1 deletions
|
@ -17,6 +17,10 @@ class VulcanoRule < VulcanoBaseRule
|
|||
VulcanoRule.__send__(m, *a, &b)
|
||||
end
|
||||
|
||||
def self.registry
|
||||
@rules ||= {}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_rspec_ids(obj)
|
||||
|
@ -30,5 +34,30 @@ class VulcanoRule < VulcanoBaseRule
|
|||
end
|
||||
|
||||
def rule id, &block
|
||||
VulcanoRule.new(id, &block)
|
||||
existing = VulcanoRule.registry[id]
|
||||
if existing.nil?
|
||||
VulcanoRule.registry[id] = VulcanoRule.new(id, &block)
|
||||
else
|
||||
# TODO: alter existing rule
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def include_rules id
|
||||
base_path = '/etc/vulcanosec/tests'
|
||||
path = File.join( base_path, id )
|
||||
# find all files to be included
|
||||
files = []
|
||||
if File::directory? path
|
||||
# include all library paths, if they exist
|
||||
libdir = File::join(path, 'lib')
|
||||
if File::directory? libdir and !$LOAD_PATH.include?(libdir)
|
||||
$LOAD_PATH.unshift(libdir)
|
||||
end
|
||||
files = Dir[File.join(path, 'spec','*_spec.rb')]
|
||||
end
|
||||
# include all files
|
||||
files.each do |file|
|
||||
eval(File::read(file))
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue