mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
xinetd_conf resource: fix false positives with config file or directory doesn't exist (#2302)
xinetd_conf resource: fix false positives when config file or directory doesn't exist
This commit is contained in:
parent
e403dd6e9f
commit
986c8818d3
2 changed files with 6 additions and 8 deletions
|
@ -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]
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue