inspec-core 4.22.1 → 4.22.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b4f096b34b4707a39ac4392118bdeadf0ab3b15b2ebea8faf8661902dbf8409
4
- data.tar.gz: 60ed138d131e605f8257a541a655757bf819c6e72b169a2c1034a1626db7c4d1
3
+ metadata.gz: b909b05a8f7510d2833aee0e464f0ed9cec64409fe5825fc05078c67b01e4a43
4
+ data.tar.gz: ee56167e3ab21f7eed5fd938e5728c3f48a7621fe71d1f3294cb4f2991298a79
5
5
  SHA512:
6
- metadata.gz: 910a8739e4f375d3d573a734f46350e3e609a72b2376d8d9e04757e06e2274da1f728b612ab11312b08f90fafd5baf68f90a179fc90edaac9366ca49701680eb
7
- data.tar.gz: 25320c374c74ee45a8ebdcfce19c7fd481a1888c7d7f3250c5a091a3e556096dd42191b570e58572ae382dea7f99661c901ae3822438c52268b76ccef286572f
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
- if r.key?(:message) && r[:message] != "" && trunc > -1
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
- if r.key?(:message) && r[:message] != "" && trunc > -1
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
@@ -61,7 +61,7 @@ module Inspec::Resources
61
61
  os = inspec.os
62
62
  if os.linux?
63
63
  LinuxMounts.new(inspec)
64
- elsif ["freebsd"].include?(os[:family])
64
+ elsif os.bsd?
65
65
  BsdMounts.new(inspec)
66
66
  end
67
67
  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 = inspec.command(mysql_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
- # skip this test if the server can't run the query
35
- warn("Can't connect to MySQL instance for SQL checks.")
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 ["freebsd"].include?(os[:family])
23
+ elsif ["bsd"].include?(os[:family])
24
24
  FreeBSDUser.new(inspec)
25
25
  elsif ["aix"].include?(os[:family])
26
26
  AixUser.new(inspec)
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "4.22.1".freeze
2
+ VERSION = "4.22.8".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: 4.22.1
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-07-20 00:00:00.000000000 Z
11
+ date: 2020-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry