mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
feature: skip ssh config if file isn't readable/found
Signed-off-by: Dominik Richter <dominik@vulcanosec.com>
This commit is contained in:
parent
8026915ce5
commit
7a721dba7e
1 changed files with 9 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
require 'utils/simpleconfig'
|
||||
|
||||
class SshConf
|
||||
class SshConf < Vulcano::Resource
|
||||
|
||||
def initialize( conf_path, type = nil )
|
||||
@runner = Specinfra::Runner
|
||||
|
@ -41,7 +41,15 @@ class SshConf
|
|||
end
|
||||
|
||||
def read_content
|
||||
# read the file
|
||||
if !@runner.check_file_is_file(@conf_path)
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = read_file(@conf_path)
|
||||
if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
# parse the file
|
||||
@params = SimpleConfig.new(@content,
|
||||
assignment_re: /^\s*(\S+?)\s+(.*?)\s*$/,
|
||||
multiple_values: false
|
||||
|
|
Loading…
Reference in a new issue