inspec-core 7.0.95 → 7.0.107
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 +4 -4
- data/Gemfile +3 -0
- data/inspec-core.gemspec +1 -1
- data/lib/inspec/resources/oracledb_session.rb +63 -8
- data/lib/inspec/utils/install_context.rb +0 -2
- data/lib/inspec/utils/telemetry/base.rb +13 -5
- data/lib/inspec/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45c2a8606fc27e3246476e86b6d87ab22b5e9b0ea8f85d8381e71a5b74d1b0d0
|
|
4
|
+
data.tar.gz: af209e2f16b169913314c0aee8bd2c4ed0a05d92a187ad421ef81c6a22d3cc26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e15e616ac53c257b7f3b23744745798cb22fbaa91ff6668140bf40ecfee92da7931e31949429fe337984c8716538ff84c8ca03acbcf9303fc93d45b20a3f4df
|
|
7
|
+
data.tar.gz: 63064836ca735a8ab3dfe01ccfb4c2cdc791dbf9474e2eff83df893ad04ef79979f5850bc7536967b5b2d871d31ad4cbc0ef61aa1ca92dbcde30eeef72a00fd2
|
data/Gemfile
CHANGED
|
@@ -43,6 +43,9 @@ group :test do
|
|
|
43
43
|
gem "m"
|
|
44
44
|
gem "minitest-sprint", "~> 1.0"
|
|
45
45
|
gem "minitest"
|
|
46
|
+
# Ruby 3.4+ extracts minitest-mock to a separate gem (bundled gem)
|
|
47
|
+
# Adding unconditionally as it's compatible with all Ruby versions
|
|
48
|
+
gem "minitest-mock"
|
|
46
49
|
gem "mocha"
|
|
47
50
|
gem "nokogiri"
|
|
48
51
|
gem "pry-byebug"
|
data/inspec-core.gemspec
CHANGED
|
@@ -68,7 +68,7 @@ Source code obtained from the Chef GitHub repository is made available under Apa
|
|
|
68
68
|
# which was causing a LoadError ('cannot load such file -- ast') for users/applications using 'inspec-core'.
|
|
69
69
|
spec.add_dependency "cookstyle"
|
|
70
70
|
|
|
71
|
-
spec.add_dependency "train-core", "~> 3.
|
|
71
|
+
spec.add_dependency "train-core", "~> 3.16", ">= 3.16.1"
|
|
72
72
|
# Minimum major version 1 is required for Chef licensing telemetry
|
|
73
73
|
spec.add_dependency "chef-licensing", ">= 1.2.0"
|
|
74
74
|
end
|
|
@@ -13,14 +13,29 @@ module Inspec::Resources
|
|
|
13
13
|
supports platform: "windows"
|
|
14
14
|
desc "Use the oracledb_session InSpec resource to test commands against an Oracle database"
|
|
15
15
|
example <<~EXAMPLE
|
|
16
|
+
# Using password
|
|
16
17
|
sql = oracledb_session(user: 'my_user', pass: 'password')
|
|
17
18
|
describe sql.query(\"SELECT UPPER(VALUE) AS VALUE FROM V$PARAMETER WHERE UPPER(NAME)='AUDIT_SYS_OPERATIONS'\").row(0).column('value') do
|
|
18
19
|
its('value') { should eq 'TRUE' }
|
|
19
20
|
end
|
|
21
|
+
|
|
22
|
+
# CHEF-28019: Using TNS alias (recommended for TCPS/SSL connections)
|
|
23
|
+
sql = oracledb_session(
|
|
24
|
+
user: 'my_user',
|
|
25
|
+
password: 'password',
|
|
26
|
+
tns_alias: 'MYDB_TCPS',
|
|
27
|
+
env: {
|
|
28
|
+
'TNS_ADMIN' => '/path/to/tnsnames',
|
|
29
|
+
'LD_LIBRARY_PATH' => '/opt/oracle/instantclient'
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
describe sql.query('SELECT * FROM dual').row(0).column('dummy') do
|
|
33
|
+
its('value') { should eq 'X' }
|
|
34
|
+
end
|
|
20
35
|
EXAMPLE
|
|
21
36
|
|
|
22
37
|
attr_reader :bin, :db_role, :host, :password, :port, :service,
|
|
23
|
-
:su_user, :user
|
|
38
|
+
:su_user, :user, :tns_alias, :env_vars
|
|
24
39
|
|
|
25
40
|
def initialize(opts = {})
|
|
26
41
|
@user = opts[:user]
|
|
@@ -37,6 +52,11 @@ module Inspec::Resources
|
|
|
37
52
|
@db_role = opts[:as_db_role]
|
|
38
53
|
@sqlcl_bin = opts[:sqlcl_bin] || nil
|
|
39
54
|
@sqlplus_bin = opts[:sqlplus_bin] || "sqlplus"
|
|
55
|
+
|
|
56
|
+
# CHEF-28019: Support for TNS alias and environment variables
|
|
57
|
+
@tns_alias = opts[:tns_alias]
|
|
58
|
+
@env_vars = opts[:env] || {}
|
|
59
|
+
|
|
40
60
|
skip_resource "Option 'as_os_user' not available in Windows" if inspec.os.windows? && su_user
|
|
41
61
|
fail_resource "Can't run Oracle checks without authentication" unless su_user || (user || password)
|
|
42
62
|
end
|
|
@@ -77,8 +97,10 @@ module Inspec::Resources
|
|
|
77
97
|
end
|
|
78
98
|
|
|
79
99
|
def resource_id
|
|
80
|
-
if @
|
|
81
|
-
"#{@
|
|
100
|
+
if @tns_alias && !@tns_alias.empty?
|
|
101
|
+
"#{@tns_alias}-#{@user}" # e.g., "XEPDB1_TCPS-USER"
|
|
102
|
+
elsif @user
|
|
103
|
+
"#{@host}-#{@port}-#{@user}" # e.g., "localhost-1521-USER"
|
|
82
104
|
elsif @su_user
|
|
83
105
|
"#{@host}-#{@port}-#{@su_user}"
|
|
84
106
|
else
|
|
@@ -88,10 +110,9 @@ module Inspec::Resources
|
|
|
88
110
|
|
|
89
111
|
private
|
|
90
112
|
|
|
91
|
-
#
|
|
92
|
-
# regular user
|
|
93
|
-
#
|
|
94
|
-
# su, using a db_role
|
|
113
|
+
# CHEF-28019: Build command with support for TNS alias and environment variables
|
|
114
|
+
# Existing behavior: regular user/password, using db_role, or su with db_role
|
|
115
|
+
# Added New behavior: TNS alias connections with optional env vars
|
|
95
116
|
def command_builder(format_options, query)
|
|
96
117
|
if @db_role.nil? || @su_user.nil?
|
|
97
118
|
verified_query = verify_query(query)
|
|
@@ -116,7 +137,11 @@ module Inspec::Resources
|
|
|
116
137
|
sql_postfix = %{ <<'EOC'\n#{format_options}\n#{verified_query}\nEXIT\n'EOC'} if shell_is_csh
|
|
117
138
|
end
|
|
118
139
|
|
|
119
|
-
|
|
140
|
+
# CHEF-28019: New path for TNS alias connections
|
|
141
|
+
if @tns_alias && !@tns_alias.to_s.empty?
|
|
142
|
+
build_tns_command(format_options, verified_query, oracle_echo_str)
|
|
143
|
+
# Original paths preserved
|
|
144
|
+
elsif @db_role.nil?
|
|
120
145
|
%{#{oracle_echo_str}#{sql_prefix}#{bin} #{user}/#{password}@#{host}:#{port}/#{@service}#{sql_postfix}}
|
|
121
146
|
elsif @su_user.nil?
|
|
122
147
|
%{#{oracle_echo_str}#{sql_prefix}#{bin} #{user}/#{password}@#{host}:#{port}/#{@service} as #{@db_role}#{sql_postfix}}
|
|
@@ -153,5 +178,35 @@ module Inspec::Resources
|
|
|
153
178
|
Hashie::Mash.new([revised_row].to_h)
|
|
154
179
|
end
|
|
155
180
|
end
|
|
181
|
+
|
|
182
|
+
# CHEF-28019: Build TNS alias command with environment variables
|
|
183
|
+
def build_tns_command(format_options, verified_query, oracle_echo_str)
|
|
184
|
+
env_prefix = build_env_prefix
|
|
185
|
+
connect_string = build_connect_string
|
|
186
|
+
heredoc_content = "connect #{connect_string}\n#{format_options}\n#{verified_query}\nEXIT"
|
|
187
|
+
|
|
188
|
+
if @su_user
|
|
189
|
+
cmd = %{su - #{@su_user} -c "#{oracle_echo_str} #{env_prefix} #{@bin} -s /nolog <<'INSPECSQL'\n#{heredoc_content}\nINSPECSQL"}
|
|
190
|
+
else
|
|
191
|
+
cmd = %{#{oracle_echo_str}#{bin} -s /nolog <<'INSPECSQL'\n#{heredoc_content}\nINSPECSQL}
|
|
192
|
+
cmd = "#{env_prefix} #{cmd}" unless env_prefix.empty?
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
cmd
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# CHEF-28019: Build Oracle connect string for TNS alias
|
|
199
|
+
def build_connect_string
|
|
200
|
+
connect_str = "#{@user}/#{@password}@#{@tns_alias}"
|
|
201
|
+
connect_str += " as #{@db_role}" if @db_role && !@su_user
|
|
202
|
+
connect_str
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# CHEF-28019: Build environment variable prefix
|
|
206
|
+
def build_env_prefix
|
|
207
|
+
return "" if @env_vars.nil? || @env_vars.empty?
|
|
208
|
+
|
|
209
|
+
@env_vars.map { |k, v| "#{k}='#{v}'" }.join(" ")
|
|
210
|
+
end
|
|
156
211
|
end
|
|
157
212
|
end
|
|
@@ -48,7 +48,7 @@ module Inspec
|
|
|
48
48
|
payload = create_wrapper
|
|
49
49
|
|
|
50
50
|
train_platform = opts[:runner].backend.backend.platform
|
|
51
|
-
payload[:platform] = train_platform
|
|
51
|
+
payload[:platform] = safe_platform_field(train_platform, :name)
|
|
52
52
|
|
|
53
53
|
payload[:jobs] = [{
|
|
54
54
|
type: JOB_TYPE,
|
|
@@ -56,10 +56,10 @@ module Inspec
|
|
|
56
56
|
# Target platform info
|
|
57
57
|
environment: {
|
|
58
58
|
host: obscure(URI(opts[:runner].backend.backend.uri).host) || "unknown",
|
|
59
|
-
os: train_platform
|
|
60
|
-
version: train_platform
|
|
61
|
-
architecture: train_platform
|
|
62
|
-
id: train_platform
|
|
59
|
+
os: safe_platform_field(train_platform, :name) || "unknown",
|
|
60
|
+
version: safe_platform_field(train_platform, :release) || "unknown",
|
|
61
|
+
architecture: safe_platform_field(train_platform, :arch) || "unknown",
|
|
62
|
+
id: safe_platform_field(train_platform, :uuid),
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
runtime: Inspec::VERSION,
|
|
@@ -125,6 +125,14 @@ module Inspec
|
|
|
125
125
|
Digest::SHA2.new(256).hexdigest(cleartext)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
+
# Safely access platform fields that may not exist
|
|
129
|
+
def safe_platform_field(platform, field)
|
|
130
|
+
return nil if platform.nil?
|
|
131
|
+
return nil unless platform.respond_to?(field)
|
|
132
|
+
|
|
133
|
+
platform.send(field)
|
|
134
|
+
end
|
|
135
|
+
|
|
128
136
|
def note_per_run_features(opts)
|
|
129
137
|
note_all_invoked_features
|
|
130
138
|
note_gem_dependency_usage(opts)
|
data/lib/inspec/version.rb
CHANGED
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: 7.0.
|
|
4
|
+
version: 7.0.107
|
|
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:
|
|
11
|
+
date: 2026-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chef-telemetry
|
|
@@ -438,20 +438,20 @@ dependencies:
|
|
|
438
438
|
requirements:
|
|
439
439
|
- - "~>"
|
|
440
440
|
- !ruby/object:Gem::Version
|
|
441
|
-
version: '3.
|
|
441
|
+
version: '3.16'
|
|
442
442
|
- - ">="
|
|
443
443
|
- !ruby/object:Gem::Version
|
|
444
|
-
version: 3.
|
|
444
|
+
version: 3.16.1
|
|
445
445
|
type: :runtime
|
|
446
446
|
prerelease: false
|
|
447
447
|
version_requirements: !ruby/object:Gem::Requirement
|
|
448
448
|
requirements:
|
|
449
449
|
- - "~>"
|
|
450
450
|
- !ruby/object:Gem::Version
|
|
451
|
-
version: '3.
|
|
451
|
+
version: '3.16'
|
|
452
452
|
- - ">="
|
|
453
453
|
- !ruby/object:Gem::Version
|
|
454
|
-
version: 3.
|
|
454
|
+
version: 3.16.1
|
|
455
455
|
- !ruby/object:Gem::Dependency
|
|
456
456
|
name: chef-licensing
|
|
457
457
|
requirement: !ruby/object:Gem::Requirement
|