mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
feature: mysql config resource updated
Signed-off-by: Dominik Richter <dominik@vulcanosec.com>
This commit is contained in:
parent
232de91d9a
commit
40ed9799b7
2 changed files with 29 additions and 2 deletions
|
@ -4,6 +4,24 @@
|
|||
|
||||
require 'utils/parseconfig'
|
||||
|
||||
class MysqlConfEntry
|
||||
def initialize( path, params )
|
||||
@params = params
|
||||
@path = path
|
||||
end
|
||||
def method_missing name, *args
|
||||
k = name.to_s
|
||||
res = @params[k]
|
||||
return true if res.nil? && @params.key?(k)
|
||||
@params[k]
|
||||
end
|
||||
def to_s
|
||||
group = ' '
|
||||
group = "[#{@path.join('][')}] " unless @path.nil? or @path.empty?
|
||||
"MySQL Config entry [#{@path.join(' ')}]"
|
||||
end
|
||||
end
|
||||
|
||||
class MysqlConf
|
||||
|
||||
def initialize( conf_path )
|
||||
|
@ -25,7 +43,12 @@ class MysqlConf
|
|||
opts.each do |opt|
|
||||
res = res[opt] unless res.nil?
|
||||
end
|
||||
res
|
||||
MysqlConfEntry.new(opts, res)
|
||||
end
|
||||
|
||||
def method_missing name
|
||||
@params || read_content
|
||||
@params[name.to_s]
|
||||
end
|
||||
|
||||
def read_content
|
||||
|
@ -35,7 +58,7 @@ class MysqlConf
|
|||
while !to_read.empty?
|
||||
raw_conf = read_file(to_read[0])
|
||||
@content += raw_conf
|
||||
|
||||
|
||||
params = ParseConfig.new(raw_conf).params
|
||||
@params.merge!(params)
|
||||
|
||||
|
|
|
@ -78,6 +78,10 @@ class ParseConfig
|
|||
group = /^\[(.+)\]$/.match(line).to_a[1]
|
||||
self.add(group, {})
|
||||
|
||||
else
|
||||
rest = line.strip
|
||||
self.add(rest, true) unless rest.empty?
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue