Sha256: acddb7fd1379ce43f0b890e4360e18cb172f467003e494944cac96c24700dfd1

Contents?: true

Size: 921 Bytes

Versions: 5

Compression:

Stored size: 921 Bytes

Contents

# encoding: utf-8

module Inspec::Resources
  class WindowsHotfix < Inspec.resource(1)
    name 'windows_hotfix'
    supports platform: 'windows'
    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?
      query = "get-hotfix -id #{@id}"
      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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inspec-2.1.81 lib/resources/windows_hotfix.rb
inspec-2.1.21 lib/resources/windows_hotfix.rb
inspec-2.1.10 lib/resources/windows_hotfix.rb
inspec-2.0.32 lib/resources/windows_hotfix.rb
inspec-2.0.17 lib/resources/windows_hotfix.rb