mirror of
https://github.com/inspec/inspec
synced 2025-02-18 23:18:53 +00:00
Fix for null insecure option
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
ec76259eb1
commit
b4ad811f05
4 changed files with 18 additions and 10 deletions
|
@ -6,9 +6,9 @@ module Inspec
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
attr_reader :cache, :target, :fetcher
|
attr_reader :cache, :target, :fetcher
|
||||||
def initialize(target, cache)
|
def initialize(target, cache, opts = {})
|
||||||
@target = target
|
@target = target
|
||||||
@fetcher = Inspec::Fetcher::Registry.resolve(target)
|
@fetcher = Inspec::Fetcher::Registry.resolve(target, opts)
|
||||||
|
|
||||||
if @fetcher.nil?
|
if @fetcher.nil?
|
||||||
raise("Could not fetch inspec profile in #{target.inspect}.")
|
raise("Could not fetch inspec profile in #{target.inspect}.")
|
||||||
|
|
|
@ -2,12 +2,12 @@ require "inspec/plugin/v1"
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
class FetcherRegistry < PluginRegistry
|
class FetcherRegistry < PluginRegistry
|
||||||
def resolve(target)
|
def resolve(target, opts = {})
|
||||||
if fetcher_specified?(target)
|
if fetcher_specified?(target)
|
||||||
super(target)
|
super(target, opts)
|
||||||
else
|
else
|
||||||
Inspec::Log.debug("Assuming default supermarket source for #{target}")
|
Inspec::Log.debug("Assuming default supermarket source for #{target}")
|
||||||
super(with_default_fetcher(target))
|
super(with_default_fetcher(target), opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,13 @@ class PluginRegistry
|
||||||
#
|
#
|
||||||
# @param [String] target to resolve
|
# @param [String] target to resolve
|
||||||
# @return [Plugin] plugin instance if it can be resolved, nil otherwise
|
# @return [Plugin] plugin instance if it can be resolved, nil otherwise
|
||||||
def resolve(target)
|
def resolve(target, opts = {})
|
||||||
modules.each do |m|
|
modules.each do |m|
|
||||||
res = m.resolve(target)
|
res = if [Inspec::Fetcher::Url, Inspec::Fetcher::Git, Supermarket::Fetcher].include? m
|
||||||
|
m.resolve(target, opts)
|
||||||
|
else
|
||||||
|
m.resolve(target)
|
||||||
|
end
|
||||||
return res unless res.nil?
|
return res unless res.nil?
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -18,9 +18,9 @@ module Inspec
|
||||||
class Profile
|
class Profile
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
def self.resolve_target(target, cache)
|
def self.resolve_target(target, cache, opts = {})
|
||||||
Inspec::Log.debug "Resolve #{target} into cache #{cache.path}"
|
Inspec::Log.debug "Resolve #{target} into cache #{cache.path}"
|
||||||
Inspec::CachedFetcher.new(target, cache)
|
Inspec::CachedFetcher.new(target, cache, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if the profile contains a vendored cache, move content into global cache
|
# Check if the profile contains a vendored cache, move content into global cache
|
||||||
|
@ -70,7 +70,11 @@ module Inspec
|
||||||
|
|
||||||
def self.for_target(target, opts = {})
|
def self.for_target(target, opts = {})
|
||||||
opts[:vendor_cache] ||= Cache.new
|
opts[:vendor_cache] ||= Cache.new
|
||||||
fetcher = resolve_target(target, opts[:vendor_cache])
|
config = {}
|
||||||
|
unless opts[:runner_conf].nil? || opts[:runner_conf].empty?
|
||||||
|
config = opts[:runner_conf].respond_to?(:final_options) ? opts[:runner_conf].final_options : opts[:runner_conf]
|
||||||
|
end
|
||||||
|
fetcher = resolve_target(target, opts[:vendor_cache], config)
|
||||||
for_fetcher(fetcher, opts)
|
for_fetcher(fetcher, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue