inspec-core 4.22.1 → 4.22.8
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/plugin/v2/plugin_types/reporter.rb +11 -5
- data/lib/inspec/reporters/base.rb +11 -5
- data/lib/inspec/resources/mount.rb +1 -1
- data/lib/inspec/resources/mysql_session.rb +26 -7
- data/lib/inspec/resources/postgres_session.rb +1 -1
- data/lib/inspec/resources/service.rb +1 -1
- data/lib/inspec/resources/users.rb +1 -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: b909b05a8f7510d2833aee0e464f0ed9cec64409fe5825fc05078c67b01e4a43
|
4
|
+
data.tar.gz: ee56167e3ab21f7eed5fd938e5728c3f48a7621fe71d1f3294cb4f2991298a79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 116d85fb0ef947cda4beb31c825cb02e134e2c9130338e062cc4e82d2d58a59e6f7fbdc8df4908759c0d508692efc00dac40550d0ce6ae9da72e904336f1fed6
|
7
|
+
data.tar.gz: e6208c479f04da18199aec2b1c8dc4c8e101bb08609b32fb9d026f485f69d7e848d62a68a6087171fa38a3486f44777d0ad56c64fe2743195b4cc1abb58f8ad9
|
@@ -31,17 +31,14 @@ module Inspec::Plugin::V2::PluginType
|
|
31
31
|
runtime_config = Inspec::Config.cached.respond_to?(:final_options) ? Inspec::Config.cached.final_options : {}
|
32
32
|
|
33
33
|
message_truncation = runtime_config[:reporter_message_truncation] || "ALL"
|
34
|
-
trunc = message_truncation == "ALL" ? -1 : message_truncation.to_i
|
34
|
+
@trunc = message_truncation == "ALL" ? -1 : message_truncation.to_i
|
35
35
|
include_backtrace = runtime_config[:reporter_backtrace_inclusion].nil? ? true : runtime_config[:reporter_backtrace_inclusion]
|
36
36
|
|
37
37
|
@run_data[:profiles]&.each do |p|
|
38
38
|
p[:controls].each do |c|
|
39
39
|
c[:results]&.map! do |r|
|
40
40
|
r.delete(:backtrace) unless include_backtrace
|
41
|
-
|
42
|
-
r[:message] = r[:message][0...trunc] + "[Truncated to #{trunc} characters]"
|
43
|
-
end
|
44
|
-
r
|
41
|
+
process_message_truncation(r)
|
45
42
|
end
|
46
43
|
end
|
47
44
|
end
|
@@ -64,5 +61,14 @@ module Inspec::Plugin::V2::PluginType
|
|
64
61
|
def self.run_data_schema_constraints
|
65
62
|
raise NotImplementedError, "#{self.class} must implement a `run_data_schema_constraints` class method to declare its compatibiltity with the RunData API."
|
66
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def process_message_truncation(result)
|
68
|
+
if result.key?(:message) && result[:message] != "" && @trunc > -1 && result[:message].length > @trunc
|
69
|
+
result[:message] = result[:message][0...@trunc] + "[Truncated to #{@trunc} characters]"
|
70
|
+
end
|
71
|
+
result
|
72
|
+
end
|
67
73
|
end
|
68
74
|
end
|
@@ -14,17 +14,14 @@ module Inspec::Reporters
|
|
14
14
|
runtime_config = Inspec::Config.cached.respond_to?(:final_options) ? Inspec::Config.cached.final_options : {}
|
15
15
|
|
16
16
|
message_truncation = runtime_config[:reporter_message_truncation] || "ALL"
|
17
|
-
trunc = message_truncation == "ALL" ? -1 : message_truncation.to_i
|
17
|
+
@trunc = message_truncation == "ALL" ? -1 : message_truncation.to_i
|
18
18
|
include_backtrace = runtime_config[:reporter_backtrace_inclusion].nil? ? true : runtime_config[:reporter_backtrace_inclusion]
|
19
19
|
|
20
20
|
@run_data[:profiles]&.each do |p|
|
21
21
|
p[:controls].each do |c|
|
22
22
|
c[:results]&.map! do |r|
|
23
23
|
r.delete(:backtrace) unless include_backtrace
|
24
|
-
|
25
|
-
r[:message] = r[:message][0...trunc] + "[Truncated to #{trunc} characters]"
|
26
|
-
end
|
27
|
-
r
|
24
|
+
process_message_truncation(r)
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
@@ -43,5 +40,14 @@ module Inspec::Reporters
|
|
43
40
|
def render
|
44
41
|
raise NotImplementedError, "#{self.class} must implement a `#render` method to format its output."
|
45
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def process_message_truncation(result)
|
47
|
+
if result.key?(:message) && result[:message] != "" && @trunc > -1 && result[:message].length > @trunc
|
48
|
+
result[:message] = result[:message][0...@trunc] + "[Truncated to #{@trunc} characters]"
|
49
|
+
end
|
50
|
+
result
|
51
|
+
end
|
46
52
|
end
|
47
53
|
end
|
@@ -4,6 +4,23 @@ require "inspec/resources/command"
|
|
4
4
|
require "shellwords"
|
5
5
|
|
6
6
|
module Inspec::Resources
|
7
|
+
class Lines
|
8
|
+
attr_reader :output
|
9
|
+
|
10
|
+
def initialize(raw, desc)
|
11
|
+
@output = raw
|
12
|
+
@desc = desc
|
13
|
+
end
|
14
|
+
|
15
|
+
def lines
|
16
|
+
output.split("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
@desc
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
7
24
|
class MysqlSession < Inspec.resource(1)
|
8
25
|
name "mysql_session"
|
9
26
|
supports platform: "unix"
|
@@ -28,15 +45,17 @@ module Inspec::Resources
|
|
28
45
|
|
29
46
|
def query(q, db = "")
|
30
47
|
mysql_cmd = create_mysql_cmd(q, db)
|
31
|
-
cmd =
|
48
|
+
cmd = if !@pass.nil?
|
49
|
+
inspec.command(mysql_cmd, redact_regex: /(mysql -u\w+ -p).+(\s-(h|S).*)/)
|
50
|
+
else
|
51
|
+
inspec.command(mysql_cmd)
|
52
|
+
end
|
32
53
|
out = cmd.stdout + "\n" + cmd.stderr
|
33
|
-
if out =~ /Can't connect to .* MySQL server/ || out.downcase =~ /^error
|
34
|
-
|
35
|
-
|
54
|
+
if cmd.exit_status != 0 || out =~ /Can't connect to .* MySQL server/ || out.downcase =~ /^error:.*/
|
55
|
+
Lines.new(out, "MySQL query with errors: #{q}")
|
56
|
+
else
|
57
|
+
Lines.new(cmd.stdout.strip, "MySQL query: #{q}")
|
36
58
|
end
|
37
|
-
|
38
|
-
# return the raw command output
|
39
|
-
cmd
|
40
59
|
end
|
41
60
|
|
42
61
|
def to_s
|
@@ -47,7 +47,7 @@ module Inspec::Resources
|
|
47
47
|
|
48
48
|
def query(query, db = [])
|
49
49
|
psql_cmd = create_psql_cmd(query, db)
|
50
|
-
cmd = inspec.command(psql_cmd)
|
50
|
+
cmd = inspec.command(psql_cmd, redact_regex: /(PGPASSWORD=').+(' psql .*)/)
|
51
51
|
out = cmd.stdout + "\n" + cmd.stderr
|
52
52
|
if cmd.exit_status != 0 || out =~ /could not connect to .*/ || out.downcase =~ /^error:.*/
|
53
53
|
Lines.new(out, "PostgreSQL query with errors: #{query}")
|
@@ -141,7 +141,7 @@ module Inspec::Resources
|
|
141
141
|
elsif version > 0
|
142
142
|
SysV.new(inspec, service_ctl || "/usr/sbin/service")
|
143
143
|
end
|
144
|
-
when "redhat", "fedora", "centos", "oracle", "cloudlinux"
|
144
|
+
when "redhat", "fedora", "centos", "oracle", "cloudlinux", "scientific"
|
145
145
|
version = os[:release].to_i
|
146
146
|
|
147
147
|
systemd = ((platform != "fedora" && version >= 7) ||
|
@@ -20,7 +20,7 @@ module Inspec::Resources
|
|
20
20
|
WindowsUser.new(inspec)
|
21
21
|
elsif ["darwin"].include?(os[:family])
|
22
22
|
DarwinUser.new(inspec)
|
23
|
-
elsif ["
|
23
|
+
elsif ["bsd"].include?(os[:family])
|
24
24
|
FreeBSDUser.new(inspec)
|
25
25
|
elsif ["aix"].include?(os[:family])
|
26
26
|
AixUser.new(inspec)
|
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.22.
|
4
|
+
version: 4.22.8
|
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: 2020-
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-telemetry
|