diff options
-rw-r--r-- | .github/workflows/exec.yml | 2 | ||||
-rw-r--r-- | .github/workflows/lint.yml | 2 | ||||
-rw-r--r-- | .github/workflows/unit.yml | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 11 | ||||
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | lib/ohai/common/dmi.rb | 116 | ||||
-rw-r--r-- | lib/ohai/mixin/network_helper.rb | 10 | ||||
-rw-r--r-- | lib/ohai/plugins/fips.rb | 3 | ||||
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 3 | ||||
-rw-r--r-- | lib/ohai/plugins/rpm.rb | 20 | ||||
-rw-r--r-- | lib/ohai/util/ip_helper.rb | 4 | ||||
-rw-r--r-- | lib/ohai/version.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/fips_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 2 |
15 files changed, 100 insertions, 85 deletions
diff --git a/.github/workflows/exec.yml b/.github/workflows/exec.yml index 4aabba5e..13dca0ca 100644 --- a/.github/workflows/exec.yml +++ b/.github/workflows/exec.yml @@ -22,7 +22,7 @@ jobs: name: Exec Ohai on ${{ matrix.os }} with Ruby ${{ matrix.ruby }} runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 80173c7b..d8ede63e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,7 @@ jobs: chefstyle: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 8ec47d47..8e9710b9 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -24,7 +24,7 @@ jobs: env: RUBYOPT: '--disable-error_highlight' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e647fc5..e50e63c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,21 @@ # Change Log -<!-- latest_release 18.0.16 --> -## [v18.0.16](https://github.com/chef/ohai/tree/v18.0.16) (2022-06-14) +<!-- latest_release 18.0.21 --> +## [v18.0.21](https://github.com/chef/ohai/tree/v18.0.21) (2022-08-23) #### Merged Pull Requests -- Update rubocop-performance requirement from 1.13.3 to 1.14.2 [#1751](https://github.com/chef/ohai/pull/1751) ([dependabot[bot]](https://github.com/dependabot[bot])) +- Update rubocop-performance requirement from 1.14.2 to 1.14.3 [#1757](https://github.com/chef/ohai/pull/1757) ([dependabot[bot]](https://github.com/dependabot[bot])) <!-- latest_release --> <!-- release_rollup since=18.0.14 --> ### Changes not yet released to rubygems.org #### Merged Pull Requests +- Update rubocop-performance requirement from 1.14.2 to 1.14.3 [#1757](https://github.com/chef/ohai/pull/1757) ([dependabot[bot]](https://github.com/dependabot[bot])) <!-- 18.0.21 --> +- Bump actions/checkout from 2 to 3 [#1752](https://github.com/chef/ohai/pull/1752) ([dependabot[bot]](https://github.com/dependabot[bot])) <!-- 18.0.20 --> +- Add additional SUSE and openSUSE platforms - micro, hpc [#1753](https://github.com/chef/ohai/pull/1753) ([jamesongithub](https://github.com/jamesongithub)) <!-- 18.0.19 --> +- Fix FIPS mode detection [#1754](https://github.com/chef/ohai/pull/1754) ([stanhu](https://github.com/stanhu)) <!-- 18.0.18 --> +- Do not attempt to reinitialize constants [#1758](https://github.com/chef/ohai/pull/1758) ([balasankarc](https://github.com/balasankarc)) <!-- 18.0.17 --> - Update rubocop-performance requirement from 1.13.3 to 1.14.2 [#1751](https://github.com/chef/ohai/pull/1751) ([dependabot[bot]](https://github.com/dependabot[bot])) <!-- 18.0.16 --> - chore: Included githubactions in the dependabot config [#1748](https://github.com/chef/ohai/pull/1748) ([naveensrinivasan](https://github.com/naveensrinivasan)) <!-- 18.0.15 --> <!-- release_rollup --> @@ -16,7 +16,7 @@ group :development do gem "rspec-core", "~> 3.0" gem "rspec-expectations", "~> 3.0" gem "rspec-mocks", "~> 3.0" - gem "rubocop-performance", "1.14.2" + gem "rubocop-performance", "1.14.3" gem "rubocop-rspec" end @@ -1 +1 @@ -18.0.16
\ No newline at end of file +18.0.21
\ No newline at end of file diff --git a/lib/ohai/common/dmi.rb b/lib/ohai/common/dmi.rb index faa440a7..7ca6ddf7 100644 --- a/lib/ohai/common/dmi.rb +++ b/lib/ohai/common/dmi.rb @@ -25,57 +25,59 @@ module Ohai # all-lowercase, all non-alphanumeric converted to '_' # 128-255 are 'oem_data_[id]' # Everything else is 'unknown' - ID_TO_DESCRIPTION = { - 0 => "bios", - 1 => "system", - 2 => "base_board", - 3 => "chassis", - 4 => "processor", - 5 => "memory_controller", - 6 => "memory_module", - 7 => "cache", - 8 => "port_connector", - 9 => "system_slots", - 10 => "on_board_devices", - 11 => "oem_strings", - 12 => "system_configuration_options", - 13 => "bios_language", - 14 => "group_associations", - 15 => "system_event_log", - 16 => "physical_memory_array", - 17 => "memory_device", - 18 => "32_bit_memory_error", - 19 => "memory_array_mapped_address", - 20 => "memory_device_mapped_address", - 21 => "built_in_pointing_device", - 22 => "portable_battery", - 23 => "system_reset", - 24 => "hardware_security", - 25 => "system_power_controls", - 26 => "voltage_probe", - 27 => "cooling_device", - 28 => "temperature_probe", - 29 => "electrical_current_probe", - 30 => "out_of_band_remote_access", - 31 => "boot_integrity_services", - 32 => "system_boot", - 33 => "64_bit_memory_error", - 34 => "management_device", - 35 => "management_device_component", - 36 => "management_device_threshold_data", - 37 => "memory_channel", - 38 => "ipmi_device", - 39 => "power_supply", - 40 => "additional_information", - 41 => "onboard_devices_extended_information", - 42 => "management_controller_host_interfaces", - 126 => "disabled_entries", - 127 => "end_of_table_marker", - }.freeze + unless defined?(ID_TO_DESCRIPTION) + ID_TO_DESCRIPTION = { + 0 => "bios", + 1 => "system", + 2 => "base_board", + 3 => "chassis", + 4 => "processor", + 5 => "memory_controller", + 6 => "memory_module", + 7 => "cache", + 8 => "port_connector", + 9 => "system_slots", + 10 => "on_board_devices", + 11 => "oem_strings", + 12 => "system_configuration_options", + 13 => "bios_language", + 14 => "group_associations", + 15 => "system_event_log", + 16 => "physical_memory_array", + 17 => "memory_device", + 18 => "32_bit_memory_error", + 19 => "memory_array_mapped_address", + 20 => "memory_device_mapped_address", + 21 => "built_in_pointing_device", + 22 => "portable_battery", + 23 => "system_reset", + 24 => "hardware_security", + 25 => "system_power_controls", + 26 => "voltage_probe", + 27 => "cooling_device", + 28 => "temperature_probe", + 29 => "electrical_current_probe", + 30 => "out_of_band_remote_access", + 31 => "boot_integrity_services", + 32 => "system_boot", + 33 => "64_bit_memory_error", + 34 => "management_device", + 35 => "management_device_component", + 36 => "management_device_threshold_data", + 37 => "memory_channel", + 38 => "ipmi_device", + 39 => "power_supply", + 40 => "additional_information", + 41 => "onboard_devices_extended_information", + 42 => "management_controller_host_interfaces", + 126 => "disabled_entries", + 127 => "end_of_table_marker", + }.freeze + end # list of IDs to collect from config or default to a sane list that prunes # away some of the less useful IDs - ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze + ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze unless defined?(ID_TO_CAPTURE) # the allowlisted DMI IDs. This is combination of the defaults + any additional # IDs defined in the :additional_dmi_ids config @@ -116,14 +118,16 @@ module Ohai id end - SKIPPED_CONVENIENCE_KEYS = %w{ - application_identifier - caption - creation_class_name - size - system_creation_class_name - record_id - }.freeze + unless defined?(SKIPPED_CONVENIENCE_KEYS) + SKIPPED_CONVENIENCE_KEYS = %w{ + application_identifier + caption + creation_class_name + size + system_creation_class_name + record_id + }.freeze + end # create simplified convenience access keys for each record type # for single occurrences of one type, copy to top level all fields and values diff --git a/lib/ohai/mixin/network_helper.rb b/lib/ohai/mixin/network_helper.rb index 8a75ad08..8547c11e 100644 --- a/lib/ohai/mixin/network_helper.rb +++ b/lib/ohai/mixin/network_helper.rb @@ -23,10 +23,12 @@ require "socket" unless defined?(Socket) module Ohai module Mixin module NetworkHelper - FAMILIES = { - "inet" => "default", - "inet6" => "default_inet6", - }.freeze + unless defined?(FAMILIES) + FAMILIES = { + "inet" => "default", + "inet6" => "default_inet6", + }.freeze + end def hex_to_dec_netmask(netmask) # example 'ffff0000' -> '255.255.0.0' diff --git a/lib/ohai/plugins/fips.rb b/lib/ohai/plugins/fips.rb index 7cf40fdf..fdb5c133 100644 --- a/lib/ohai/plugins/fips.rb +++ b/lib/ohai/plugins/fips.rb @@ -30,6 +30,7 @@ Ohai.plugin(:Fips) do fips Mash.new require "openssl" unless defined?(OpenSSL) - fips["kernel"] = { "enabled" => OpenSSL::OPENSSL_FIPS } + + fips["kernel"] = { "enabled" => defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode } end end diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index 3433bdf2..492c61ee 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -149,7 +149,8 @@ Ohai.plugin(:Platform) do "rhel" when /amazon/ "amazon" - when /suse/, /sles/, /opensuseleap/, /opensuse/, /sled/ + # suse matches opensuse, suse-* opensuse-*, etc. sle[sd\-_] intends to match sles, sled, sle-*, sle_* + when /suse/, /sle[sd\-_]/ "suse" when /fedora/, /arista_eos/ # In the broadest sense: RPM-based, fedora-derived distributions which are not strictly re-compiled RHEL (if it uses RPMs, and smells more like redhat and less like diff --git a/lib/ohai/plugins/rpm.rb b/lib/ohai/plugins/rpm.rb index c131ad50..c4247c54 100644 --- a/lib/ohai/plugins/rpm.rb +++ b/lib/ohai/plugins/rpm.rb @@ -22,16 +22,18 @@ Ohai.plugin(:Rpm) do provides "rpm" optional "true" - MACROS_MARKER = /========================/.freeze + MACROS_MARKER = /========================/.freeze unless defined?(MACROS_MARKER) - DO_NOT_SPLIT = %w{ - build_arch - build_os - install_arch - install_os - archcolor - optflags - }.freeze + unless defined?(DO_NOT_SPLIT) + DO_NOT_SPLIT = %w{ + build_arch + build_os + install_arch + install_os + archcolor + optflags + }.freeze + end collect_data(:aix, :darwin, :dragonflybsd, :freebsd, :linux, :netbsd, :openbsd, :solaris2) do rpm_path = which("rpm") diff --git a/lib/ohai/util/ip_helper.rb b/lib/ohai/util/ip_helper.rb index 044afaec..64360ace 100644 --- a/lib/ohai/util/ip_helper.rb +++ b/lib/ohai/util/ip_helper.rb @@ -21,8 +21,8 @@ module Ohai require "ipaddress" unless defined?(IPAddress) # Corresponding to RFC 4192 + RFC 4193 - IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10") - IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7") + IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10") unless defined?(IPV6_LINK_LOCAL_UNICAST_BLOCK) + IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7") unless defined?(IPV6_PRIVATE_ADDRESS_BLOCK) def private_address?(addr) ip = IPAddress(addr) diff --git a/lib/ohai/version.rb b/lib/ohai/version.rb index e404d483..11658634 100644 --- a/lib/ohai/version.rb +++ b/lib/ohai/version.rb @@ -19,5 +19,5 @@ module Ohai OHAI_ROOT = File.expand_path(__dir__) - VERSION = "18.0.16" + VERSION = "18.0.21" end diff --git a/spec/unit/plugins/fips_spec.rb b/spec/unit/plugins/fips_spec.rb index 0925eb16..7fdf10bb 100644 --- a/spec/unit/plugins/fips_spec.rb +++ b/spec/unit/plugins/fips_spec.rb @@ -33,14 +33,14 @@ describe Ohai::System, "plugin fips" do context "when OpenSSL reports FIPS mode true" do it "sets fips enabled true" do - stub_const("OpenSSL::OPENSSL_FIPS", true) + allow(OpenSSL).to receive(:fips_mode).and_return(true) expect(subject).to be(true) end end context "when OpenSSL reports FIPS mode false" do it "sets fips enabled false" do - stub_const("OpenSSL::OPENSSL_FIPS", false) + allow(OpenSSL).to receive(:fips_mode).and_return(false) expect(subject).to be(false) end end diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 8d27e211..b3c0dbdc 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -181,7 +181,7 @@ describe Ohai::System, "Linux plugin platform" do end end - %w{suse sles opensuse opensuseleap sled}.each do |p| + %w{suse sles opensuse opensuse-leap opensuseleap opensuse-tumbleweed opensuse-leap-micro opensuse-microos suse-microos sled sle-hpc sle_hpc sle_rt}.each do |p| it "returns suse for #{p} platform_family" do expect(plugin.platform_family_from_platform(p)).to eq("suse") end |