inspec-core 4.37.25 → 4.37.30
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 +12 -0
- data/lib/inspec/resources/mysql_session.rb +12 -2
- data/lib/inspec/resources/postgres_session.rb +10 -1
- 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: 9c945fbd0ce14959ea0286c4bfc5928d547bd7c48dd80828a955585493383476
|
4
|
+
data.tar.gz: c9f3f58a8b68ec6039ef432421150690870ffce295691ad2e9f1b72e31b4802b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b75d54fae752d292467fe333a8081c739ae24c2570256b26a6c104893e29a234182018e00d555a31e02cd19f189c7561489b1c2c13b03c4eacca04562b3a3343
|
7
|
+
data.tar.gz: bc67f78180eb7516f28dfae3fc0bcf8a0bb523b05ff3e5aa32df156279797d9d6f3801c00ff347159fc7cdf399d1c6a00cd29a4a506611c53c044eaac5a938dc
|
data/Gemfile
CHANGED
@@ -20,11 +20,22 @@ end
|
|
20
20
|
# but our runtime dep is still 3.9+
|
21
21
|
gem "rspec", ">= 3.10"
|
22
22
|
|
23
|
+
def probably_x86?
|
24
|
+
# We don't currently build on ARM windows, so assume x86 there
|
25
|
+
return true if RUBY_PLATFORM =~ /windows|mswin|msys|mingw|cygwin/
|
26
|
+
|
27
|
+
# Otherwise rely on uname -m
|
28
|
+
`uname -m`.match?(/^(x86_64|i\d86)/)
|
29
|
+
end
|
30
|
+
|
23
31
|
group :omnibus do
|
24
32
|
gem "rb-readline"
|
25
33
|
gem "appbundler"
|
26
34
|
gem "ed25519" # ed25519 ssh key support done here as its a native gem we can't put in the gemspec
|
27
35
|
gem "bcrypt_pbkdf" # ed25519 ssh key support done here as its a native gem we can't put in the gemspec
|
36
|
+
if probably_x86?
|
37
|
+
gem "x25519" # ed25519 KEX module, not supported on ARM
|
38
|
+
end
|
28
39
|
end
|
29
40
|
|
30
41
|
group :test do
|
@@ -55,6 +66,7 @@ end
|
|
55
66
|
if Gem.ruby_version >= Gem::Version.new("2.7.0")
|
56
67
|
group :kitchen do
|
57
68
|
gem "berkshelf"
|
69
|
+
gem "chef", ">= 16.0" # Required to allow net-ssh > 6
|
58
70
|
gem "test-kitchen", ">= 2.8"
|
59
71
|
gem "kitchen-inspec", ">= 2.0"
|
60
72
|
gem "kitchen-dokken", ">= 2.11"
|
@@ -44,10 +44,14 @@ module Inspec::Resources
|
|
44
44
|
@port = port
|
45
45
|
@socket = socket
|
46
46
|
init_fallback if user.nil? || pass.nil?
|
47
|
-
|
47
|
+
raise Inspec::Exceptions::ResourceFailed, "Can't run MySQL SQL checks without authentication." if @user.nil? || @pass.nil?
|
48
|
+
|
49
|
+
test_connection
|
48
50
|
end
|
49
51
|
|
50
52
|
def query(q, db = "")
|
53
|
+
raise Inspec::Exceptions::ResourceFailed, "#{resource_exception_message}" if resource_failed?
|
54
|
+
|
51
55
|
mysql_cmd = create_mysql_cmd(q, db)
|
52
56
|
cmd = if !@pass.nil?
|
53
57
|
inspec.command(mysql_cmd, redact_regex: /(mysql -u\w+ -p).+(\s-(h|S).*)/)
|
@@ -56,7 +60,7 @@ module Inspec::Resources
|
|
56
60
|
end
|
57
61
|
out = cmd.stdout + "\n" + cmd.stderr
|
58
62
|
if cmd.exit_status != 0 || out =~ /Can't connect to .* MySQL server/ || out.downcase =~ /^error:.*/
|
59
|
-
|
63
|
+
raise Inspec::Exceptions::ResourceFailed, "MySQL query with errors: #{out}"
|
60
64
|
else
|
61
65
|
Lines.new(cmd.stdout.strip, "MySQL query: #{q}", cmd.exit_status)
|
62
66
|
end
|
@@ -68,6 +72,12 @@ module Inspec::Resources
|
|
68
72
|
|
69
73
|
private
|
70
74
|
|
75
|
+
# Querying on the database to make sure conneciton can be established. If not this will set the resource exception
|
76
|
+
# message which we raise before querying on the database using mysql_session object.
|
77
|
+
def test_connection
|
78
|
+
query("select now()")
|
79
|
+
end
|
80
|
+
|
71
81
|
def escape_string(query)
|
72
82
|
Shellwords.escape(query)
|
73
83
|
end
|
@@ -45,14 +45,19 @@ module Inspec::Resources
|
|
45
45
|
@pass = pass
|
46
46
|
@host = host || "localhost"
|
47
47
|
@port = port || 5432
|
48
|
+
raise Inspec::Exceptions::ResourceFailed, "Can't run PostgreSQL SQL checks without authentication." if @user.nil? || @pass.nil?
|
49
|
+
|
50
|
+
test_connection
|
48
51
|
end
|
49
52
|
|
50
53
|
def query(query, db = [])
|
54
|
+
raise Inspec::Exceptions::ResourceFailed, "#{resource_exception_message}" if resource_failed?
|
55
|
+
|
51
56
|
psql_cmd = create_psql_cmd(query, db)
|
52
57
|
cmd = inspec.command(psql_cmd, redact_regex: /(PGPASSWORD=').+(' psql .*)/)
|
53
58
|
out = cmd.stdout + "\n" + cmd.stderr
|
54
59
|
if cmd.exit_status != 0 || out =~ /could not connect to .*/ || out.downcase =~ /^error:.*/
|
55
|
-
|
60
|
+
raise Inspec::Exceptions::ResourceFailed, "PostgreSQL query with errors: #{out}"
|
56
61
|
else
|
57
62
|
Lines.new(cmd.stdout.strip, "PostgreSQL query: #{query}")
|
58
63
|
end
|
@@ -60,6 +65,10 @@ module Inspec::Resources
|
|
60
65
|
|
61
66
|
private
|
62
67
|
|
68
|
+
def test_connection
|
69
|
+
query("select now()")
|
70
|
+
end
|
71
|
+
|
63
72
|
def escaped_query(query)
|
64
73
|
Shellwords.escape(query)
|
65
74
|
end
|
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: 4.37.
|
4
|
+
version: 4.37.30
|
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: 2021-06-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-telemetry
|