Method: Inspec::Resources::SecurityPolicy#load

Defined in:
lib/resources/security_policy.rb

#loadObject

load security content



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/resources/security_policy.rb', line 32

def load
  # export the security policy
  cmd = inspec.command('secedit /export /cfg win_secpol.cfg')
  return nil if cmd.exit_status.to_i != 0

  # store file content
  cmd = inspec.command('Get-Content win_secpol.cfg')
  @exit_status = cmd.exit_status.to_i
  return nil if @exit_status != 0
  @policy = cmd.stdout
  @loaded = true

  # returns self
  self

ensure
  # delete temp file
  inspec.command('Remove-Item win_secpol.cfg').exit_status.to_i
end