inspec-core 5.24.5 → 5.24.7
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/lib/inspec/resources/mssql_session.rb +13 -1
- data/lib/inspec/utils/profile_ast_helpers.rb +38 -10
- data/lib/inspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d51433ba0116888c84236e9e10a00eed659241c97bc52bc28adab5d166747b1
|
|
4
|
+
data.tar.gz: fbcdb575d6d6e318080fe33c9480d97a886e18795f8d9d70b631744998985039
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd38bce6f7c2f0f53effda98239dc918e002c1f06266f32905fe464c22c4bcbc2c09a475c4b3e7eb9b902a50252b9f4c83978e1e857fb0bd0f78fb1e8ced781a
|
|
7
|
+
data.tar.gz: b9ae97157012e01b7522afc285b307b4042178900c25ba7f9e72898d4aa1670d97906ba8e8b50bab0cf04645d809a6bad2229d567eb658b1a2f327b359b0014a
|
|
@@ -30,9 +30,15 @@ module Inspec::Resources
|
|
|
30
30
|
its('value') { should_not be_empty }
|
|
31
31
|
its('value') { should cmp == 1 }
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
# Trust the SQL Server TLS certificate when using sqlcmd
|
|
35
|
+
sql_tls = mssql_session(user: 'myuser', password: 'mypassword', trust_server_certificate: true)
|
|
36
|
+
describe sql_tls.query(\"SELECT SERVERPROPERTY('ProductVersion') as \\\"version\\\";\").row(0).column('version') do
|
|
37
|
+
its('value') { should_not be_empty }
|
|
38
|
+
end
|
|
33
39
|
EXAMPLE
|
|
34
40
|
|
|
35
|
-
attr_reader :user, :password, :host, :port, :instance, :local_mode, :db_name
|
|
41
|
+
attr_reader :user, :password, :host, :port, :instance, :local_mode, :db_name, :trust_server_certificate
|
|
36
42
|
def initialize(opts = {})
|
|
37
43
|
@user = opts[:user]
|
|
38
44
|
@password = opts[:password] || opts[:pass]
|
|
@@ -46,6 +52,7 @@ module Inspec::Resources
|
|
|
46
52
|
end
|
|
47
53
|
@instance = opts[:instance]
|
|
48
54
|
@db_name = opts[:db_name]
|
|
55
|
+
@trust_server_certificate = !!opts[:trust_server_certificate] # rubocop:disable Style/DoubleNegation
|
|
49
56
|
|
|
50
57
|
# check if sqlcmd is available
|
|
51
58
|
raise Inspec::Exceptions::ResourceSkipped, "sqlcmd is missing" unless inspec.command("sqlcmd").exist?
|
|
@@ -57,6 +64,7 @@ module Inspec::Resources
|
|
|
57
64
|
escaped_query = q.gsub(/\\/, "\\\\").gsub(/"/, '""').gsub(/\$/, '\\$')
|
|
58
65
|
# surpress 'x rows affected' in SQLCMD with 'set nocount on;'
|
|
59
66
|
cmd_string = "sqlcmd -Q \"set nocount on; #{escaped_query}\" -W -w 1024 -s ','"
|
|
67
|
+
cmd_string += " -C" if trust_server_certificate?
|
|
60
68
|
cmd_string += " -U '#{@user}' -P '#{@password}'" unless @user.nil? || @password.nil?
|
|
61
69
|
cmd_string += " -d '#{@db_name}'" unless @db_name.nil?
|
|
62
70
|
unless local_mode?
|
|
@@ -94,6 +102,10 @@ module Inspec::Resources
|
|
|
94
102
|
!!@local_mode # rubocop:disable Style/DoubleNegation
|
|
95
103
|
end
|
|
96
104
|
|
|
105
|
+
def trust_server_certificate?
|
|
106
|
+
@trust_server_certificate
|
|
107
|
+
end
|
|
108
|
+
|
|
97
109
|
def test_connection
|
|
98
110
|
!query("select getdate()").empty?
|
|
99
111
|
end
|
|
@@ -24,6 +24,37 @@ module Inspec
|
|
|
24
24
|
@memo = memo
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def extract_node_value(node)
|
|
28
|
+
case node.class.to_s
|
|
29
|
+
when "RuboCop::AST::HashNode"
|
|
30
|
+
# Handle hash nodes
|
|
31
|
+
values = {}
|
|
32
|
+
node.children.each do |pair_node|
|
|
33
|
+
values.merge!(pair_node.key.value => extract_node_value(pair_node.value))
|
|
34
|
+
end
|
|
35
|
+
values
|
|
36
|
+
when "RuboCop::AST::ArrayNode"
|
|
37
|
+
# Handle array nodes
|
|
38
|
+
node.children.map { |element| extract_node_value(element) }
|
|
39
|
+
else
|
|
40
|
+
# Handle simple nodes (strings, numbers, symbols, booleans, nil, etc.)
|
|
41
|
+
if node.respond_to?(:type)
|
|
42
|
+
case node.type
|
|
43
|
+
when :true
|
|
44
|
+
true
|
|
45
|
+
when :false
|
|
46
|
+
false
|
|
47
|
+
when :nil
|
|
48
|
+
nil
|
|
49
|
+
else
|
|
50
|
+
node.respond_to?(:value) ? node.value : node
|
|
51
|
+
end
|
|
52
|
+
else
|
|
53
|
+
node.respond_to?(:value) ? node.value : node
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
27
58
|
def collect_input(input_children)
|
|
28
59
|
input_name = input_children.children[2].value
|
|
29
60
|
|
|
@@ -39,15 +70,9 @@ module Inspec
|
|
|
39
70
|
if VALID_INPUT_OPTIONS.include?(child_node.key.value)
|
|
40
71
|
if child_node.value.class == RuboCop::AST::Node && REQUIRED_VALUES_MAP.key?(child_node.value.type)
|
|
41
72
|
opts.merge!(child_node.key.value => REQUIRED_VALUES_MAP[child_node.value.type])
|
|
42
|
-
elsif child_node.value.class == RuboCop::AST::HashNode
|
|
43
|
-
# Here value will be a hash
|
|
44
|
-
values = {}
|
|
45
|
-
child_node.value.children.each do |grand_child_node|
|
|
46
|
-
values.merge!(grand_child_node.key.value => grand_child_node.value.value)
|
|
47
|
-
end
|
|
48
|
-
opts.merge!(child_node.key.value => values)
|
|
49
73
|
else
|
|
50
|
-
|
|
74
|
+
# Use the helper method to recursively extract values from any node type
|
|
75
|
+
opts.merge!(child_node.key.value => extract_node_value(child_node.value))
|
|
51
76
|
end
|
|
52
77
|
end
|
|
53
78
|
end
|
|
@@ -313,8 +338,11 @@ module Inspec
|
|
|
313
338
|
collectors.push InputCollectorWithinControlBlock.new(@memo)
|
|
314
339
|
collectors.push TestsCollector.new(control_data) if include_tests
|
|
315
340
|
|
|
316
|
-
|
|
317
|
-
|
|
341
|
+
# Handle empty control blocks (e.g., control "id" do end)
|
|
342
|
+
if begin_block
|
|
343
|
+
begin_block.each_node do |node_within_control|
|
|
344
|
+
collectors.each { |collector| collector.process(node_within_control) }
|
|
345
|
+
end
|
|
318
346
|
end
|
|
319
347
|
|
|
320
348
|
memo[:controls].push control_data
|
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: 5.24.
|
|
4
|
+
version: 5.24.7
|
|
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: 2026-
|
|
11
|
+
date: 2026-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chef-telemetry
|