Class: Inspec::Resources::AideConf

Inherits:
Object
  • Object
show all
Includes:
FileReader, Utils::CommentParser
Defined in:
lib/inspec/resources/aide_conf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileReader

#read_file_content

Methods included from Utils::CommentParser

#parse_comment_line

Constructor Details

#initialize(aide_conf_path = nil) ⇒ AideConf

Returns a new instance of AideConf.



30
31
32
33
34
35
# File 'lib/inspec/resources/aide_conf.rb', line 30

def initialize(aide_conf_path = nil)
  @conf_path = aide_conf_path || "/etc/aide.conf"
  @content = nil
  @rules = nil
  read_content
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



25
26
27
# File 'lib/inspec/resources/aide_conf.rb', line 25

def params
  @params
end

Instance Method Details

#all_have_rule(rule) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/inspec/resources/aide_conf.rb', line 37

def all_have_rule(rule)
  # Case when file didn't exist or perms didn't allow an open
  return false if @content.nil?

  lines = @params.reject { |line| line["rules"].include? rule }
  lines.empty?
end

#resource_idObject



51
52
53
# File 'lib/inspec/resources/aide_conf.rb', line 51

def resource_id
  @conf_path || "aide_conf"
end

#to_sObject



55
56
57
# File 'lib/inspec/resources/aide_conf.rb', line 55

def to_s
  "AIDE Config"
end