ohai 17.9.1 → 17.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49537c9f0a1551c3e5e1b635c6a54445ee8236c2c66c0999746abc33435e3214
4
- data.tar.gz: 694e91edf4f6557102863738ce899f755afb54bf6f04c7f1a581b062d5f1e0dc
3
+ metadata.gz: 1f1c149d4e95abb73e9d2ec15f6318c5b6b588ff2369b68ca1b8a3d26cd69826
4
+ data.tar.gz: 52dd3e1df41fd3709051a85fe5cba9775ebc739998de03079f9afc8dee9fa652
5
5
  SHA512:
6
- metadata.gz: 9c8ec65795b008c9f7b3117f76ffeb7216d2ba31a8e75a2d03d292d07d43844e488562cceef350550fef70a1be5c6b2e3ce9830d250642544d777b1509f2b8a0
7
- data.tar.gz: 91e845ae052b1d5967720a1f2bfbf7c241cf19c26207121c14f37ae54bd56208b5665c9925128a37f8aec12768e20309a57a499ee6c7b5169db661de10665db3
6
+ metadata.gz: f6aa99445c427e776d6ce7eed4077a9f887997b5fe2a3f17f2c9cc4f19bf6fe542afc5e48b780c6b552f9a777040d751ac571d0f3751b0932c574ac86c844831
7
+ data.tar.gz: 1b43dc4b727518ec92627e4833897aec7f05f2000f11bdb4595fd6a06e0fe9cca3a25c7b41bc6914988fd1e29f7bc26f101e98703b385e82a341fd02c02424aa
data/Gemfile CHANGED
@@ -3,9 +3,9 @@ source "https://rubygems.org"
3
3
 
4
4
  gemspec
5
5
 
6
- # pull these gems from main of chef/chef so that we're testing against what we will release
7
- gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec"
8
- gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec"
6
+ # pull these gems from chef-17 of chef/chef so that we're testing against what we will release
7
+ gem "chef-config", git: "https://github.com/chef/chef", branch: "chef-17", glob: "chef-config/chef-config.gemspec"
8
+ gem "chef-utils", git: "https://github.com/chef/chef", branch: "chef-17", glob: "chef-utils/chef-utils.gemspec"
9
9
 
10
10
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
11
11
  group :development do
@@ -16,7 +16,7 @@ group :development do
16
16
  gem "rspec-core", "~> 3.0"
17
17
  gem "rspec-expectations", "~> 3.0"
18
18
  gem "rspec-mocks", "~> 3.0"
19
- gem "rubocop-performance", "1.13.0"
19
+ gem "rubocop-performance", "1.12.0"
20
20
  gem "rubocop-rspec"
21
21
  end
22
22
 
@@ -25,57 +25,59 @@ module Ohai
25
25
  # all-lowercase, all non-alphanumeric converted to '_'
26
26
  # 128-255 are 'oem_data_[id]'
27
27
  # Everything else is 'unknown'
28
- ID_TO_DESCRIPTION = {
29
- 0 => "bios",
30
- 1 => "system",
31
- 2 => "base_board",
32
- 3 => "chassis",
33
- 4 => "processor",
34
- 5 => "memory_controller",
35
- 6 => "memory_module",
36
- 7 => "cache",
37
- 8 => "port_connector",
38
- 9 => "system_slots",
39
- 10 => "on_board_devices",
40
- 11 => "oem_strings",
41
- 12 => "system_configuration_options",
42
- 13 => "bios_language",
43
- 14 => "group_associations",
44
- 15 => "system_event_log",
45
- 16 => "physical_memory_array",
46
- 17 => "memory_device",
47
- 18 => "32_bit_memory_error",
48
- 19 => "memory_array_mapped_address",
49
- 20 => "memory_device_mapped_address",
50
- 21 => "built_in_pointing_device",
51
- 22 => "portable_battery",
52
- 23 => "system_reset",
53
- 24 => "hardware_security",
54
- 25 => "system_power_controls",
55
- 26 => "voltage_probe",
56
- 27 => "cooling_device",
57
- 28 => "temperature_probe",
58
- 29 => "electrical_current_probe",
59
- 30 => "out_of_band_remote_access",
60
- 31 => "boot_integrity_services",
61
- 32 => "system_boot",
62
- 33 => "64_bit_memory_error",
63
- 34 => "management_device",
64
- 35 => "management_device_component",
65
- 36 => "management_device_threshold_data",
66
- 37 => "memory_channel",
67
- 38 => "ipmi_device",
68
- 39 => "power_supply",
69
- 40 => "additional_information",
70
- 41 => "onboard_devices_extended_information",
71
- 42 => "management_controller_host_interfaces",
72
- 126 => "disabled_entries",
73
- 127 => "end_of_table_marker",
74
- }.freeze
28
+ unless defined?(ID_TO_DESCRIPTION)
29
+ ID_TO_DESCRIPTION = {
30
+ 0 => "bios",
31
+ 1 => "system",
32
+ 2 => "base_board",
33
+ 3 => "chassis",
34
+ 4 => "processor",
35
+ 5 => "memory_controller",
36
+ 6 => "memory_module",
37
+ 7 => "cache",
38
+ 8 => "port_connector",
39
+ 9 => "system_slots",
40
+ 10 => "on_board_devices",
41
+ 11 => "oem_strings",
42
+ 12 => "system_configuration_options",
43
+ 13 => "bios_language",
44
+ 14 => "group_associations",
45
+ 15 => "system_event_log",
46
+ 16 => "physical_memory_array",
47
+ 17 => "memory_device",
48
+ 18 => "32_bit_memory_error",
49
+ 19 => "memory_array_mapped_address",
50
+ 20 => "memory_device_mapped_address",
51
+ 21 => "built_in_pointing_device",
52
+ 22 => "portable_battery",
53
+ 23 => "system_reset",
54
+ 24 => "hardware_security",
55
+ 25 => "system_power_controls",
56
+ 26 => "voltage_probe",
57
+ 27 => "cooling_device",
58
+ 28 => "temperature_probe",
59
+ 29 => "electrical_current_probe",
60
+ 30 => "out_of_band_remote_access",
61
+ 31 => "boot_integrity_services",
62
+ 32 => "system_boot",
63
+ 33 => "64_bit_memory_error",
64
+ 34 => "management_device",
65
+ 35 => "management_device_component",
66
+ 36 => "management_device_threshold_data",
67
+ 37 => "memory_channel",
68
+ 38 => "ipmi_device",
69
+ 39 => "power_supply",
70
+ 40 => "additional_information",
71
+ 41 => "onboard_devices_extended_information",
72
+ 42 => "management_controller_host_interfaces",
73
+ 126 => "disabled_entries",
74
+ 127 => "end_of_table_marker",
75
+ }.freeze
76
+ end
75
77
 
76
78
  # list of IDs to collect from config or default to a sane list that prunes
77
79
  # away some of the less useful IDs
78
- ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze
80
+ ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze unless defined?(ID_TO_CAPTURE)
79
81
 
80
82
  # the allowlisted DMI IDs. This is combination of the defaults + any additional
81
83
  # IDs defined in the :additional_dmi_ids config
@@ -116,14 +118,16 @@ module Ohai
116
118
  id
117
119
  end
118
120
 
119
- SKIPPED_CONVENIENCE_KEYS = %w{
120
- application_identifier
121
- caption
122
- creation_class_name
123
- size
124
- system_creation_class_name
125
- record_id
126
- }.freeze
121
+ unless defined?(SKIPPED_CONVENIENCE_KEYS)
122
+ SKIPPED_CONVENIENCE_KEYS = %w{
123
+ application_identifier
124
+ caption
125
+ creation_class_name
126
+ size
127
+ system_creation_class_name
128
+ record_id
129
+ }.freeze
130
+ end
127
131
 
128
132
  # create simplified convenience access keys for each record type
129
133
  # for single occurrences of one type, copy to top level all fields and values
@@ -38,22 +38,27 @@ module Ohai
38
38
  conn.get("/2016-01-01/#{uri}", { "User-Agent" => "chef-ohai/#{Ohai::VERSION}" })
39
39
  end
40
40
 
41
- def fetch_metadata(id = "")
41
+ def fetch_metadata(id = "", is_directory = true)
42
42
  response = http_get(id)
43
43
  return nil unless response.code == "200"
44
44
 
45
- if json?(response.body)
46
- data = String(response.body)
47
- parser = FFI_Yajl::Parser.new
48
- parser.parse(data)
49
- elsif response.body.include?("\n")
45
+ if !is_directory
46
+ if json?(response.body)
47
+ data = String(response.body)
48
+ parser = FFI_Yajl::Parser.new
49
+ parser.parse(data)
50
+ else
51
+ response.body
52
+ end
53
+ elsif is_directory
50
54
  temp = {}
51
55
  response.body.split("\n").each do |sub_attr|
52
- temp[sanitize_key(sub_attr)] = fetch_metadata("#{id}/#{sub_attr}")
56
+ if "#{id}/#{sub_attr}" != "/user-data"
57
+ uri = id == "" ? "#{id}#{sub_attr}/" : "#{id}#{sub_attr}"
58
+ temp[sanitize_key(sub_attr).gsub(/_$/, "")] = fetch_metadata(uri, has_trailing_slash?(uri))
59
+ end
53
60
  end
54
61
  temp
55
- else
56
- response.body
57
62
  end
58
63
  end
59
64
 
@@ -75,7 +80,7 @@ module Ohai
75
80
  #
76
81
  # @return [Boolean] is there a trailing /?
77
82
  def has_trailing_slash?(data)
78
- !!( data =~ %r{/$} )
83
+ !!(data =~ %r{/$})
79
84
  end
80
85
 
81
86
  def sanitize_key(key)
@@ -23,10 +23,12 @@ require "socket" unless defined?(Socket)
23
23
  module Ohai
24
24
  module Mixin
25
25
  module NetworkHelper
26
- FAMILIES = {
27
- "inet" => "default",
28
- "inet6" => "default_inet6",
29
- }.freeze
26
+ unless defined?(FAMILIES)
27
+ FAMILIES = {
28
+ "inet" => "default",
29
+ "inet6" => "default_inet6",
30
+ }.freeze
31
+ end
30
32
 
31
33
  def hex_to_dec_netmask(netmask)
32
34
  # example 'ffff0000' -> '255.255.0.0'
@@ -22,16 +22,18 @@ Ohai.plugin(:Rpm) do
22
22
  provides "rpm"
23
23
  optional "true"
24
24
 
25
- MACROS_MARKER = /========================/.freeze
25
+ MACROS_MARKER = /========================/.freeze unless defined?(MACROS_MARKER)
26
26
 
27
- DO_NOT_SPLIT = %w{
28
- build_arch
29
- build_os
30
- install_arch
31
- install_os
32
- archcolor
33
- optflags
34
- }.freeze
27
+ unless defined?(DO_NOT_SPLIT)
28
+ DO_NOT_SPLIT = %w{
29
+ build_arch
30
+ build_os
31
+ install_arch
32
+ install_os
33
+ archcolor
34
+ optflags
35
+ }.freeze
36
+ end
35
37
 
36
38
  collect_data(:aix, :darwin, :dragonflybsd, :freebsd, :linux, :netbsd, :openbsd, :solaris2) do
37
39
  rpm_path = which("rpm")
@@ -21,8 +21,8 @@ module Ohai
21
21
  require "ipaddress" unless defined?(IPAddress)
22
22
 
23
23
  # Corresponding to RFC 4192 + RFC 4193
24
- IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10")
25
- IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7")
24
+ IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10") unless defined?(IPV6_LINK_LOCAL_UNICAST_BLOCK)
25
+ IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7") unless defined?(IPV6_PRIVATE_ADDRESS_BLOCK)
26
26
 
27
27
  def private_address?(addr)
28
28
  ip = IPAddress(addr)
data/lib/ohai/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ohai
21
21
  OHAI_ROOT = File.expand_path(__dir__)
22
- VERSION = "17.9.1"
22
+ VERSION = "17.9.4"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.9.1
4
+ version: 17.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-27 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config