Class: Ardecy::Harden::Modules::Drop

Inherits:
Object
  • Object
show all
Includes:
Display
Defined in:
lib/ardecy/harden/modules.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) ⇒ Drop

Returns a new instance of Drop.



13
14
15
16
# File 'lib/ardecy/harden/modules.rb', line 13

def initialize(args)
  @res = 'OK'
  @args = args
end

Instance Method Details

#fixObject



43
44
45
46
47
# File 'lib/ardecy/harden/modules.rb', line 43

def fix
  return if @res =~ /OK/

  BLACKLIST << "install #{@name} /bin/false"
end

#quit_unless_modulesObject



18
19
20
21
22
23
# File 'lib/ardecy/harden/modules.rb', line 18

def quit_unless_modules
  unless File.exist? '/proc/modules'
    warn '/proc/modules no found'
    exit 1
  end
end

#research_foundObject



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

def research_found
  quit_unless_modules

  File.readlines('/proc/modules').each do |l|
    return true if l =~ /^#{@name}/
  end
  false
end

#xObject



34
35
36
37
38
39
40
41
# File 'lib/ardecy/harden/modules.rb', line 34

def x
  @res = 'FAIL' if research_found
  if @args[:audit]
    show_bad_mod(@name)
    @tab ? result(@res, @tab) : result(@res)
  end
  fix
end