inspec/lib/resources/auditd_rules.rb

44 lines
990 B
Ruby
Raw Normal View History

2015-07-26 20:44:01 +00:00
# encoding: utf-8
# copyright: 2015, Vulcano Security GmbH
# license: All rights reserved
class AuditDaemonRules < Vulcano.resource(1)
name 'audit_daemon_rules'
2015-07-26 20:44:01 +00:00
def initialize
@content = @vulcano.run_command("/sbin/auditctl -l").stdout.chomp
2015-07-26 20:44:01 +00:00
@opts = {
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: true
}
end
def params
@params ||= SimpleConfig.new(@content, @opts).params
2015-07-26 20:44:01 +00:00
end
def method_missing name
params[name.to_s]
2015-07-26 20:44:01 +00:00
end
def status name
@status_opts = {
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: false
}
@status_content ||= @vulcano.run_command("/sbin/auditctl -s").stdout.chomp
2015-07-26 20:44:01 +00:00
@status_params = SimpleConfig.new(@status_content, @status_opts).params
status = @status_params["AUDIT_STATUS"]
if (status == nil) then return nil end
items = Hash[status.scan(/([^=]+)=(\w*)\s*/)]
return items[name]
end
def to_s
'Audit Daemon Rules'
2015-07-26 20:44:01 +00:00
end
end