mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Added code comments and rename control_list_exist? method to controls_list_exist?
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
b180914889
commit
428a8a7194
2 changed files with 8 additions and 3 deletions
|
@ -53,7 +53,7 @@ module Inspec
|
|||
|
||||
def control(id, opts = {}, &block)
|
||||
opts[:skip_only_if_eval] = @skip_only_if_eval
|
||||
if control_exist_in_controls_list?(id) || control_list_empty?
|
||||
if control_exist_in_controls_list?(id) || controls_list_empty?
|
||||
register_control(Inspec::Rule.new(id, profile_id, resources_dsl, opts, &block))
|
||||
end
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ module Inspec
|
|||
res = describe(*args, &block)
|
||||
end
|
||||
|
||||
if control_exist_in_controls_list?(id) || control_list_empty?
|
||||
if control_exist_in_controls_list?(id) || controls_list_empty?
|
||||
register_control(rule, &block)
|
||||
end
|
||||
|
||||
|
@ -182,14 +182,17 @@ module Inspec
|
|||
end
|
||||
end
|
||||
|
||||
# Returns true if configuration hash is not empty and it contains the list of controls is not empty
|
||||
def profile_config_exist?
|
||||
!@conf.empty? && @conf.key?("profile") && !@conf["profile"].include_controls_list.empty?
|
||||
end
|
||||
|
||||
def control_list_empty?
|
||||
# Returns true if configuration hash is empty or configuration hash does not have the list of controls that needs to be included
|
||||
def controls_list_empty?
|
||||
!@conf.empty? && @conf.key?("profile") && @conf["profile"].include_controls_list.empty? || @conf.empty?
|
||||
end
|
||||
|
||||
# Check if the given control exist in the --controls option
|
||||
def control_exist_in_controls_list?(id)
|
||||
if profile_config_exist?
|
||||
id_exist_in_list = @conf["profile"].include_controls_list.any? do |inclusion|
|
||||
|
|
|
@ -228,6 +228,8 @@ module Inspec
|
|||
@runner_context.all_rules
|
||||
end
|
||||
|
||||
# This creates the list of controls provided in the --controls options which need to be include
|
||||
# for evaluation.
|
||||
def include_controls_list
|
||||
return [] if @controls.nil? || @controls.empty?
|
||||
|
||||
|
|
Loading…
Reference in a new issue