lib/inspec/dsl.rb in inspec-3.4.1 vs lib/inspec/dsl.rb in inspec-3.5.0
- old
+ new
@@ -1,10 +1,11 @@
# encoding: utf-8
# copyright: 2015, Dominik Richter
# author: Dominik Richter
# author: Christoph Hartmann
require 'inspec/log'
+require 'inspec/plugin/v2'
module Inspec::DSL
def require_controls(id, &block)
opts = { profile_id: id, include_all: false, backend: @backend, conf: @conf, dependencies: @dependencies }
::Inspec::DSL.load_spec_files_for_profile(self, opts, &block)
@@ -53,20 +54,20 @@
def self.load_spec_files_for_profile(bind_context, opts, &block)
dependencies = opts[:dependencies]
profile_id = opts[:profile_id]
dep_entry = dependencies.list[profile_id]
- # do not load any controls if the profile is not supported
- return unless dep_entry.profile.supports_platform?
-
if dep_entry.nil?
raise <<~EOF
- Cannot load #{profile_id} since it is not listed as a dependency of #{bind_context.profile_name}.
+ Cannot load '#{profile_id}' since it is not listed as a dependency of #{bind_context.profile_name}.
Dependencies available from this context are:
#{dependencies.list.keys.join("\n ")}
EOF
end
+
+ # Do not load any controls if the profile is not supported
+ return unless dep_entry.profile.supports_platform?
context = dep_entry.profile.runner_context
# if we don't want all the rules, then just make 1 pass to get all rule_IDs
# that we want to keep from the original
filter_included_controls(context, dep_entry.profile, &block) if !opts[:include_all]