Sha256: 3cb5008b16fae88c15e7229969d0a17de2842a0242279de96f41dc1b94b66a88

Contents?: true

Size: 856 Bytes

Versions: 29

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

require 'win32/registry'

module Facter
  module Resolvers
    module Windows
      class Fips < BaseResolver
        # :fips_enabled
        @semaphore = Mutex.new
        @fact_list ||= {}
        class << self
          private

          def post_resolve(fact_name)
            @fact_list.fetch(fact_name) { read_fact_from_registry(fact_name) }
          end

          def read_fact_from_registry(fact_name)
            reg = ::Win32::Registry::HKEY_LOCAL_MACHINE
                  .open('System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy')
            @fact_list[:fips_enabled] = reg['Enabled'] != 0 if reg.any? { |name, _value| name == 'Enabled' }
            reg.close

            @fact_list[:fips_enabled] ||= false
            @fact_list[fact_name]
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
facter-4.0.15 lib/resolvers/windows/fips_resolver.rb
facter-4.0.14 lib/resolvers/windows/fips_resolver.rb
facter-4.0.13 lib/resolvers/windows/fips_resolver.rb
facter-4.0.12 lib/resolvers/windows/fips_resolver.rb
facter-4.0.11 lib/resolvers/windows/fips_resolver.rb
facter-4.0.10.pre lib/resolvers/windows/fips_resolver.rb
facter-4.0.9.pre lib/resolvers/windows/fips_resolver.rb
facter-4.0.8.pre lib/resolvers/windows/fips_resolver.rb
facter-4.0.7.pre lib/resolvers/windows/fips_resolver.rb