lint resources

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-09-09 18:37:16 +02:00
parent 74da29c3ed
commit 903b9642e4
11 changed files with 44 additions and 41 deletions

View file

@ -33,7 +33,7 @@ class ApacheConf < Vulcano.resource(1)
def filter_comments(data)
content = ''
data.each_line do |line|
if (!line.match(/^\s*#/)) then
if !line.match(/^\s*#/)
content << line
end
end
@ -56,7 +56,7 @@ class ApacheConf < Vulcano.resource(1)
end
to_read = [@conf_path]
while !to_read.empty?
until to_read.empty?
raw_conf = read_file(to_read[0])
@content += raw_conf
@ -64,7 +64,7 @@ class ApacheConf < Vulcano.resource(1)
params = SimpleConfig.new(
raw_conf,
assignment_re: /^\s*(\S+)\s+(.*)\s*$/,
multiple_values: true
multiple_values: true,
).params
@params.merge!(params)

View file

@ -46,14 +46,13 @@ class AuditPolicy < Vulcano.resource(1)
}
# extract value
if target != nil
values = nil
unless target.nil?
# split csv values and return value
value = target.split(',')[4]
else
value = nil
values = target.split(',')[4]
end
value
values
end
def to_s

View file

@ -1,5 +1,5 @@
# copyright: 2015, Vulcano Security GmbH
# encoding: utf-8
# copyright: 2015, Vulcano Security GmbH
# license: All rights reserved
class Command < Vulcano.resource(1)

View file

@ -62,7 +62,7 @@ class EtcGroup < Vulcano.resource(1)
gid: 2,
group_id: 2,
group_list: 3,
users: 3
users: 3,
}
res = entries
conditions.each do |k, v|
@ -90,9 +90,15 @@ class EtcGroupView
@filter = filter
end
def groups; @parent.groups(@filter); end
def groups
@parent.groups(@filter)
end
def gids; @parent.gids(@filter); end
def gids
@parent.gids(@filter)
end
def users; @parent.users(@filter); end
def users
@parent.users(@filter)
end
end

View file

@ -16,7 +16,7 @@ end
class GroupPolicy < Vulcano.resource(1)
name 'group_policy'
def getRegistryValue(entry)
def get_registry_value(entry)
keys = entry['registry_information'][0]
cmd = "(Get-Item 'Registry::#{keys['path']}').GetValue('#{keys['key']}')"
command_result ||= vulcano.run_command(cmd)
@ -24,7 +24,7 @@ class GroupPolicy < Vulcano.resource(1)
val
end
def convertValue(value)
def convert_value(value)
val = value.strip
val = val.to_i if val.match(/^\d+$/)
val
@ -36,11 +36,11 @@ class GroupPolicy < Vulcano.resource(1)
entry = gpo(@name, meth.to_s)
# get data
val = getRegistryValue(entry)
val = get_registry_value(entry)
# verify data
if (val[:exit_code] == 0)
return convertValue(val[:data])
return convert_value(val[:data])
else
return nil
end

View file

@ -12,7 +12,7 @@ class MysqlConfEntry
@path = path
end
def method_missing(name, *args)
def method_missing(name, *_)
k = name.to_s
res = @params[k]
return true if res.nil? && @params.key?(k)
@ -20,8 +20,6 @@ class MysqlConfEntry
end
def to_s
group = ' '
group = "[#{@path.join('][')}] " unless @path.nil? or @path.empty?
"MySQL Config entry [#{@path.join(' ')}]"
end
end
@ -69,7 +67,7 @@ class MysqlConf < Vulcano.resource(1)
end
to_read = [@conf_path]
while !to_read.empty?
until to_read.empty?
raw_conf = read_file(to_read[0])
@content += raw_conf

View file

@ -35,13 +35,12 @@ class MysqlSession < Vulcano.resource(1)
def initialize_fallback
# support debian mysql administration login
debian = vulcano.run_command('test -f /etc/mysql/debian.cnf && cat /etc/mysql/debian.cnf').stdout
unless debian.empty?
user = debian.match(/^\s*user\s*=\s*([^ ]*)\s*$/)
pass = debian.match(/^\s*password\s*=\s*([^ ]*)\s*$/)
return if user.nil? or pass.nil?
@user = user[1]
@pass = pass[1]
return
end
return if debian.empty?
user = debian.match(/^\s*user\s*=\s*([^ ]*)\s*$/)
pass = debian.match(/^\s*password\s*=\s*([^ ]*)\s*$/)
return if user.nil? or pass.nil?
@user = user[1]
@pass = pass[1]
end
end

View file

@ -68,13 +68,13 @@ class Deb < PkgManagement
params = SimpleConfig.new(
cmd.stdout.chomp,
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: false
multiple_values: false,
).params
{
name: params['Package'],
installed: true,
version: params['Version'],
type: 'deb'
type: 'deb',
}
end
end
@ -87,13 +87,13 @@ class Rpm < PkgManagement
params = SimpleConfig.new(
cmd.stdout.chomp,
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: false
multiple_values: false,
).params
{
name: params['Name'],
installed: true,
version: params['Version'],
type: 'rpm'
type: 'rpm',
}
end
end
@ -109,7 +109,7 @@ class Brew < PkgManagement
name: "#{pkg.name}",
installed: true,
version: "#{pkg.installed.version}",
type: 'brew'
type: 'brew',
}
end
end
@ -123,14 +123,14 @@ class Pacman < PkgManagement
params = SimpleConfig.new(
cmd.stdout.chomp,
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: false
multiple_values: false,
).params
{
name: params['Name'],
installed: true,
version: params['Version'],
type: 'pacman'
type: 'pacman',
}
end
end

View file

@ -18,13 +18,13 @@ class PipPackage < Vulcano.resource(1)
params = SimpleConfig.new(
cmd.stdout,
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: false
multiple_values: false,
).params
@cache = {
name: params['Name'],
installed: true,
version: params['Version'],
type: 'pip'
type: 'pip',
}
end

View file

@ -45,7 +45,7 @@ class PostgresConf < Vulcano.resource(1)
end
to_read = [@conf_path]
while !to_read.empty?
until to_read.empty?
raw_conf = read_file(to_read[0])
@content += raw_conf

View file

@ -51,9 +51,10 @@ class SshConf < Vulcano.resource(1)
end
# parse the file
@params = SimpleConfig.new(@conf.content,
@params = SimpleConfig.new(
@conf.content,
assignment_re: /^\s*(\S+?)\s+(.*?)\s*$/,
multiple_values: true
multiple_values: true,
).params
end
end