Class: Ardecy::Harden::Perms::DirCheck

Inherits:
Object
  • Object
show all
Includes:
Display
Defined in:
lib/ardecy/harden/perms.rb

Instance Method Summary collapse

Methods included from Display

#display_fix_list, #kernel_show, #perm_show, #result, #show_bad_mod, #title

Constructor Details

#initialize(args) ⇒ DirCheck

Returns a new instance of DirCheck.



11
12
13
14
15
16
# File 'lib/ardecy/harden/perms.rb', line 11

def initialize(args)
  @args = args
  @res = 'OK'
  @exp = 0755
  @tab = 2
end

Instance Method Details

#fixObject



34
35
36
37
38
# File 'lib/ardecy/harden/perms.rb', line 34

def fix
  return unless @args[:fix]

  File.chmod @exp, @name unless @res =~ /OK/
end

#scanObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/ardecy/harden/perms.rb', line 23

def scan
  return unless Dir.exist? @name

  perm = File.stat(@name).mode & 07777
  @line = "Permission on #{@name}"

  perm_show(@line, @exp) if @args[:audit]
  @res = 'FAIL' if perm > @exp
  @tab ? result(@res, @tab) : result(@res) if @args[:audit]
end

#xObject



18
19
20
21
# File 'lib/ardecy/harden/perms.rb', line 18

def x
  scan
  fix
end