inspec-core 5.22.65 → 5.22.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a7f8456410caebef0bb3dfdad7df4d9aac0e72d33effef12d1581c919be2e54
4
- data.tar.gz: ca21ae25ee3c9d43e1820d45663b6232e0be0dd3c336305acf15628c1cc68c37
3
+ metadata.gz: 1561e49537c4bd8b615a78d099d922a0915c71429fcdfb4ca6197105712ca3aa
4
+ data.tar.gz: d756477c4172ff54a6a69f6905c0f0034b484f9ca38b45fda8a7d6efa7c5f748
5
5
  SHA512:
6
- metadata.gz: 0f822677d07b5c1d2c8b70f23ad6cf94f303686200cc9b68683fc54af2d0e362ae257278bdcb510febeefff2e1f163aadc42a019dbe39089444665d80c29da28
7
- data.tar.gz: 6800aef92c54e66bc4fcf2fe604326c8caaae4514bbf2a11aa913d3a2f18a9f8d6775427d81fdc1bf1c59f25a588f36b94c59af4ab69f155634b47eaf3944015
6
+ metadata.gz: 93849cdca52ac4bc4bec15aebd4933e623229f4c10378fb2d85316c6496d45cc9ebe7ed2e1c1aa4f1a296779237cb06b204f5d61af8f7d1a7b2642c9a9e4720a
7
+ data.tar.gz: 54988d5e27e76412c03eca453f7887414a536ee16607fbf2c1ecd7e502136f555700bba9c88e59967ab6857fa198c4138b517090183f31b72e88f54a46926669
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem "inspec-bin", path: "./inspec-bin"
12
12
  # ffi version v1.17.0 is breaking verify pipeline as it requires
13
13
  # rubygems version to be upgraded to >= 3.3.22 Ref:https://buildkite.com/chef/inspec-inspec-main-verify-private/builds/812#018fe177-2ccb-45ed-a25e-213c8a6453df/698-707
14
14
 
15
- gem "ffi", ">= 1.15.5", "< 1.18.0"
15
+ gem "ffi", ">= 1.15.5", "< 1.17.0"
16
16
 
17
17
  # We have a build issue 2023-11-13 with unf_ext 0.0.9 so we are pinning to 0.0.8.2
18
18
  # See https://github.com/knu/ruby-unf_ext/issues/74 https://buildkite.com/chef/inspec-inspec-inspec-5-omnibus-release/builds/22
@@ -37,7 +37,8 @@ group :test do
37
37
  gem "minitest-sprint", "~> 1.0"
38
38
  gem "minitest", "5.15.0"
39
39
  gem "mocha"
40
- gem "nokogiri"
40
+ # Pinning this version as it breaking for ruby 3.1.0
41
+ gem "nokogiri", "< 1.17.2"
41
42
  gem "pry-byebug"
42
43
  gem "pry"
43
44
  gem "rake"
@@ -61,6 +62,11 @@ end
61
62
  # Remove this pin when upgrading to Ruby 3.2 or higher.
62
63
  gem "zeitwerk", "~> 2.6.0", "< 2.7"
63
64
 
65
+ # Pinning dry-core,dry-core,dry-types to < 1.1.0 as it is breaking the build because 1.1.0 is incompatible with the current version, ruby 3.0.x on CI
66
+ gem "dry-types", "<= 1.7.2" if RUBY_VERSION < "3.1.0"
67
+ gem "dry-core", "> 1.0.0", "< 1.1.0" if RUBY_VERSION < "3.1.0"
68
+ gem "dry-inflector", "<= 1.1.0" if RUBY_VERSION < "3.1.0"
69
+
64
70
  # Pinning securerandom to < 0.4.0 as it is breaking the build because 0.4.0 is incompatible with the current version, ruby 3.0.x on CI
65
71
  # Remove this pin when upgrading to Ruby 3.1 or higher on CI.
66
72
  gem "securerandom", "< 0.4.0" if RUBY_VERSION < "3.1.0"
data/inspec-core.gemspec CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "rspec-its", "~> 1.2"
37
37
  spec.add_dependency "pry", "~> 0.13"
38
38
  spec.add_dependency "hashie", ">= 3.4", "< 6.0"
39
- spec.add_dependency "mixlib-log", "~> 3.0"
39
+ spec.add_dependency "mixlib-log", "~> 3.0", "< 3.2"
40
40
  spec.add_dependency "sslshake", "~> 1.2"
41
41
  spec.add_dependency "parallel", "~> 1.9"
42
42
  spec.add_dependency "faraday", ">= 1", "< 3"
@@ -200,8 +200,60 @@ module Inspec::Resources
200
200
  # implements generic unix groups via /etc/group
201
201
  class UnixGroup < GroupInfo
202
202
  def groups
203
+ get_group_info
204
+ end
205
+
206
+ private
207
+
208
+ def get_group_info
209
+ # First, try to fetch group info using getent
210
+ group_info = fetch_group_info_using_getent
211
+
212
+ return group_info unless group_info.empty?
213
+
214
+ # If getent fails, fallback to reading group info from /etc/group using inspec.etc_group.entries
215
+ Inspec::Log.debug("Falling back to reading group info from /etc/group as getent is unavailable or failed.")
203
216
  inspec.etc_group.entries
204
217
  end
218
+
219
+ # Fetches group information using the getent utility
220
+ def fetch_group_info_using_getent
221
+ # Find getent utility on the system
222
+ bin = find_getent_utility
223
+
224
+ # If getent is available, fetch group info
225
+ return [] unless bin
226
+
227
+ cmd = inspec.command("#{bin} group")
228
+ return parse_group_info(cmd) if cmd.exit_status.to_i == 0
229
+
230
+ # If getent fails, log the error and return an empty array
231
+ Inspec::Log.debug("Failed to execute #{bin} group: #{cmd.stderr}.")
232
+ []
233
+ end
234
+
235
+ # Parses group info from the command output
236
+ def parse_group_info(cmd)
237
+ cmd.stdout.strip.split("\n").map do |line|
238
+ name, password, gid, members = line.split(":")
239
+ {
240
+ "name" => name,
241
+ "password" => password,
242
+ "gid" => gid.to_i,
243
+ "members" => members,
244
+ }
245
+ end
246
+ end
247
+
248
+ # Checks if getent exists on the system
249
+ def find_getent_utility
250
+ %w{/usr/bin/getent /bin/getent getent}.each do |cmd|
251
+ return cmd if inspec.command(cmd).exist?
252
+ end
253
+ # Log debug information if getent is not found
254
+ Inspec::Log.debug("Could not find `getent` on your system.")
255
+ nil # Return nil if getent is not found
256
+ end
205
257
  end
206
258
 
207
259
  # OSX uses opendirectory for groups, so `/etc/group` may not be fully accurate
@@ -1,7 +1,7 @@
1
1
  # copyright: 2015, Vulcano Security GmbH
2
2
 
3
3
  require "shellwords" unless defined?(Shellwords)
4
-
4
+ require "cgi" unless defined?(CGI)
5
5
  module Inspec::Resources
6
6
  class Lines
7
7
  attr_reader :output, :exit_status
@@ -74,6 +74,10 @@ module Inspec::Resources
74
74
  Shellwords.escape(query)
75
75
  end
76
76
 
77
+ def encoded_password(password)
78
+ CGI.escape(password)
79
+ end
80
+
77
81
  def create_psql_cmd(query, db = [])
78
82
  dbs = db.map { |x| "#{x}" }.join(" ")
79
83
 
@@ -82,14 +86,14 @@ module Inspec::Resources
82
86
  # Socket connection only enabled for non-windows platforms
83
87
  # Windows does not support unix domain sockets
84
88
  option_port = @port.nil? ? "" : "-p #{@port}" # add explicit port if specified
85
- "psql -d postgresql://#{@user}:#{@pass}@/#{dbs}?host=#{@socket_path} #{option_port} -A -t -w -c #{escaped_query(query)}"
89
+ "psql -d postgresql://#{@user}:#{encoded_password(@pass)}@/#{dbs}?host=#{@socket_path} #{option_port} -A -t -w -c #{escaped_query(query)}"
86
90
  else
87
91
  # Host in connection string establishes tcp/ip connection
88
92
  if inspec.os.windows?
89
93
  warn "Socket based connection not supported in windows, connecting using host" if @socket_path
90
- "psql -d postgresql://#{@user}:#{@pass}@#{@host}:#{@port}/#{dbs} -A -t -w -c \"#{query}\""
94
+ "psql -d postgresql://#{@user}:#{encoded_password(@pass)}@#{@host}:#{@port}/#{dbs} -A -t -w -c \"#{query}\""
91
95
  else
92
- "psql -d postgresql://#{@user}:#{@pass}@#{@host}:#{@port}/#{dbs} -A -t -w -c #{escaped_query(query)}"
96
+ "psql -d postgresql://#{@user}:#{encoded_password(@pass)}@#{@host}:#{@port}/#{dbs} -A -t -w -c #{escaped_query(query)}"
93
97
  end
94
98
  end
95
99
  end
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "5.22.65".freeze
2
+ VERSION = "5.22.72".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.22.65
4
+ version: 5.22.72
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
11
+ date: 2025-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry
@@ -185,6 +185,9 @@ dependencies:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
187
  version: '3.0'
188
+ - - "<"
189
+ - !ruby/object:Gem::Version
190
+ version: '3.2'
188
191
  type: :runtime
189
192
  prerelease: false
190
193
  version_requirements: !ruby/object:Gem::Requirement
@@ -192,6 +195,9 @@ dependencies:
192
195
  - - "~>"
193
196
  - !ruby/object:Gem::Version
194
197
  version: '3.0'
198
+ - - "<"
199
+ - !ruby/object:Gem::Version
200
+ version: '3.2'
195
201
  - !ruby/object:Gem::Dependency
196
202
  name: sslshake
197
203
  requirement: !ruby/object:Gem::Requirement