mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
bugfix: mysql resouce skipping and checking
Signed-off-by: Dominik Richter <dominik@vulcanosec.com>
This commit is contained in:
parent
40ed9799b7
commit
b3495e9fc5
4 changed files with 16 additions and 5 deletions
|
@ -6,6 +6,7 @@ require 'utils/parseconfig'
|
|||
|
||||
class MysqlConfEntry
|
||||
def initialize( path, params )
|
||||
@runner = Specinfra::Runner
|
||||
@params = params
|
||||
@path = path
|
||||
end
|
||||
|
@ -22,7 +23,7 @@ class MysqlConfEntry
|
|||
end
|
||||
end
|
||||
|
||||
class MysqlConf
|
||||
class MysqlConf < Vulcano::Resource
|
||||
|
||||
def initialize( conf_path )
|
||||
@runner = Specinfra::Runner
|
||||
|
@ -56,7 +57,13 @@ class MysqlConf
|
|||
@params = {}
|
||||
to_read = [@conf_path]
|
||||
while !to_read.empty?
|
||||
if !@runner.check_file_is_file(to_read[0])
|
||||
return skip_resource("Can't find file \"#{to_read[0]}\"")
|
||||
end
|
||||
raw_conf = read_file(to_read[0])
|
||||
if raw_conf.empty? && @runner.get_file_size(to_read[0]).stdout.strip.to_i > 0
|
||||
return skip_resource("Can't read file \"#{to_read[0]}\"")
|
||||
end
|
||||
@content += raw_conf
|
||||
|
||||
params = ParseConfig.new(raw_conf).params
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
# copyright: 2015, Dominik Richter
|
||||
# license: All rights reserved
|
||||
|
||||
class MysqlSession
|
||||
class MysqlSession < Vulcano::Resource
|
||||
def initialize user, pass
|
||||
@user = user
|
||||
@pass = pass
|
||||
@runner = Specinfra::Runner
|
||||
initialize_fallback if user.nil? or pass.nil?
|
||||
skip_resource if @user.nil? or @pass.nil?
|
||||
skip_resource("Can't run MySQL SQL checks without authentication") if @user.nil? or @pass.nil?
|
||||
end
|
||||
|
||||
def describe(query, db = "", &block)
|
||||
|
|
|
@ -53,9 +53,9 @@ class SshConf
|
|||
end
|
||||
class PostgresConf
|
||||
def initialize *args; end
|
||||
def params; {} end
|
||||
def params *a, &b; {} end
|
||||
end
|
||||
class MysqlConf
|
||||
def initialize *args; end
|
||||
def params; {} end
|
||||
def params *a, &b; {} end
|
||||
end
|
|
@ -130,3 +130,7 @@ module Vulcano
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
def os *a, &b
|
||||
{}
|
||||
end
|
Loading…
Reference in a new issue