Merge pull request #332 from chef/dr/check-non-controls

ignore auto-generated controls during verify check
This commit is contained in:
Stephan Renatus 2015-12-23 11:48:28 +01:00
commit f70c6acb8f
3 changed files with 4 additions and 3 deletions

View file

@ -105,6 +105,7 @@ module Inspec
@params[:rules].each do |group, rules_array|
@logger.debug "Verify all rules in #{group}"
rules_array.each do |id, rule|
next if id.start_with? '(generated '
error.call('Avoid rules with empty IDs') if id.nil? or id.empty?
warn.call("Rule #{id} has no title") if rule[:title].to_s.empty?
warn.call("Rule #{id} has no description") if rule[:desc].to_s.empty?

View file

@ -111,7 +111,7 @@ module Inspec
define_method :describe do |*args, &block|
path = block.source_location[0]
line = block.source_location[1]
id = "#{File.basename(path)}:#{line} #{SecureRandom.hex}"
id = "(generated from #{File.basename(path)}:#{line} #{SecureRandom.hex})"
rule = rule_class.new(id, {}) do
describe(*args, &block)
end

View file

@ -34,7 +34,7 @@ describe Inspec::ProfileContext do
load('describe true do; it { should_eq true }; end')
.must_output ''
profile.rules.keys.length.must_equal 1
profile.rules.keys[0].must_match /^unknown:1 [0-9a-f]+$/
profile.rules.keys[0].must_match /^\(generated from unknown:1 [0-9a-f]+\)$/
profile.rules.values[0].must_be_kind_of Inspec::Rule
end
@ -43,7 +43,7 @@ describe Inspec::ProfileContext do
.must_output ''
profile.rules.keys.length.must_equal 3
[0, 1, 2].each do |i|
profile.rules.keys[i].must_match /^unknown:2 [0-9a-f]+$/
profile.rules.keys[i].must_match /^\(generated from unknown:2 [0-9a-f]+\)$/
profile.rules.values[i].must_be_kind_of Inspec::Rule
end
end