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
|
class MysqlConfEntry
|
||||||
def initialize( path, params )
|
def initialize( path, params )
|
||||||
|
@runner = Specinfra::Runner
|
||||||
@params = params
|
@params = params
|
||||||
@path = path
|
@path = path
|
||||||
end
|
end
|
||||||
|
@ -22,7 +23,7 @@ class MysqlConfEntry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class MysqlConf
|
class MysqlConf < Vulcano::Resource
|
||||||
|
|
||||||
def initialize( conf_path )
|
def initialize( conf_path )
|
||||||
@runner = Specinfra::Runner
|
@runner = Specinfra::Runner
|
||||||
|
@ -56,7 +57,13 @@ class MysqlConf
|
||||||
@params = {}
|
@params = {}
|
||||||
to_read = [@conf_path]
|
to_read = [@conf_path]
|
||||||
while !to_read.empty?
|
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])
|
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
|
@content += raw_conf
|
||||||
|
|
||||||
params = ParseConfig.new(raw_conf).params
|
params = ParseConfig.new(raw_conf).params
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
# copyright: 2015, Dominik Richter
|
# copyright: 2015, Dominik Richter
|
||||||
# license: All rights reserved
|
# license: All rights reserved
|
||||||
|
|
||||||
class MysqlSession
|
class MysqlSession < Vulcano::Resource
|
||||||
def initialize user, pass
|
def initialize user, pass
|
||||||
@user = user
|
@user = user
|
||||||
@pass = pass
|
@pass = pass
|
||||||
@runner = Specinfra::Runner
|
@runner = Specinfra::Runner
|
||||||
initialize_fallback if user.nil? or pass.nil?
|
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
|
end
|
||||||
|
|
||||||
def describe(query, db = "", &block)
|
def describe(query, db = "", &block)
|
||||||
|
|
|
@ -53,9 +53,9 @@ class SshConf
|
||||||
end
|
end
|
||||||
class PostgresConf
|
class PostgresConf
|
||||||
def initialize *args; end
|
def initialize *args; end
|
||||||
def params; {} end
|
def params *a, &b; {} end
|
||||||
end
|
end
|
||||||
class MysqlConf
|
class MysqlConf
|
||||||
def initialize *args; end
|
def initialize *args; end
|
||||||
def params; {} end
|
def params *a, &b; {} end
|
||||||
end
|
end
|
|
@ -130,3 +130,7 @@ module Vulcano
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def os *a, &b
|
||||||
|
{}
|
||||||
|
end
|
Loading…
Reference in a new issue