diff --git a/lib/resources/xinetd.rb b/lib/resources/xinetd.rb index c5218cbdd..d62d921cf 100644 --- a/lib/resources/xinetd.rb +++ b/lib/resources/xinetd.rb @@ -53,15 +53,14 @@ module Inspec::Resources return @contents[path] if @contents.key?(path) file = inspec.file(path) if !file.file? - return skip_resource "Can't find file \"#{path}\"" + raise Inspec::Exceptions::ResourceSkipped, "Can't find file: #{path}" + end + + if file.content.nil? || file.content.empty? + raise Inspec::Exceptions::ResourceSkipped, "Can't read file: #{path}" end @contents[path] = file.content - if @contents[path].nil? || @contents[path].empty? - return skip_resource "Can't read file \"#{path}\"" - end - - @contents[path] end def read_params @@ -69,7 +68,6 @@ module Inspec::Resources flat_params = parse_xinetd(read_content) # we need to map service data in order to use it with filtertable params = { 'services' => {} } - # map services that were defined and map it to the service hash flat_params.each do |k, v| name = k[/^service (.+)$/, 1] diff --git a/lib/utils/parser.rb b/lib/utils/parser.rb index 672f44ed6..c9d8e0a89 100644 --- a/lib/utils/parser.rb +++ b/lib/utils/parser.rb @@ -217,7 +217,7 @@ module XinetdParser return [] if dir.nil? unless inspec.file(dir).directory? - return skip_resource "Cannot read folder in #{dir}" + raise Inspec::Exceptions::ResourceSkipped, "Can't find folder: #{dir}" end files = inspec.command("find #{dir} -type f").stdout.split("\n")