bugfix: mysql resouce skipping and checking

Signed-off-by: Dominik Richter <dominik@vulcanosec.com>
This commit is contained in:
Dominik Richter 2015-06-22 16:18:40 +02:00
parent 40ed9799b7
commit b3495e9fc5
4 changed files with 16 additions and 5 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -130,3 +130,7 @@ module Vulcano
end
end
def os *a, &b
{}
end