2017-09-25 17:09:22 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
module Inspec::Resources
|
|
|
|
class WindowsHotfix < Inspec.resource(1)
|
|
|
|
name 'windows_hotfix'
|
2018-02-19 14:26:49 +00:00
|
|
|
supports platform: 'windows'
|
2017-09-25 17:09:22 +00:00
|
|
|
desc 'Use the windows_hotfix InSpec audit resource to test if the hotfix has been installed on the Windows system.'
|
|
|
|
example "
|
|
|
|
describe windows_hotfix('KB4012212') do
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
|
|
|
"
|
|
|
|
|
|
|
|
attr_accessor :content
|
|
|
|
|
|
|
|
def initialize(hotfix_id = nil)
|
|
|
|
@id = hotfix_id.upcase
|
|
|
|
@content = nil
|
|
|
|
os = inspec.os
|
|
|
|
return skip_resource 'The `windows_hotfix` resource is not a feature of your OS.' unless os.windows?
|
2017-10-18 11:24:11 +00:00
|
|
|
query = "get-hotfix -id #{@id}"
|
2017-09-25 17:09:22 +00:00
|
|
|
cmd = inspec.powershell(query)
|
|
|
|
@content = cmd.stdout
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
"Windows Hotfix #{@id}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def installed?
|
|
|
|
return false if @content.nil?
|
|
|
|
@content.include?(@id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|