inspec-core 4.37.30 → 4.38.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c945fbd0ce14959ea0286c4bfc5928d547bd7c48dd80828a955585493383476
4
- data.tar.gz: c9f3f58a8b68ec6039ef432421150690870ffce295691ad2e9f1b72e31b4802b
3
+ metadata.gz: da7b208efcb020501f9a283e5e512d3862cd4c3e7c19f2012e143af2721fd893
4
+ data.tar.gz: f534843ff5445086f3d40802fff3fe19c8ed787660dde2ce17816e8dc1225cac
5
5
  SHA512:
6
- metadata.gz: b75d54fae752d292467fe333a8081c739ae24c2570256b26a6c104893e29a234182018e00d555a31e02cd19f189c7561489b1c2c13b03c4eacca04562b3a3343
7
- data.tar.gz: bc67f78180eb7516f28dfae3fc0bcf8a0bb523b05ff3e5aa32df156279797d9d6f3801c00ff347159fc7cdf399d1c6a00cd29a4a506611c53c044eaac5a938dc
6
+ metadata.gz: efd72de313d408802e8484dba99e6291bcd1a571fe028642736fccfcb3d02b78bb700d88a0441d6b2525285891707a738b8315c8dc315edc50e288eb000940e3
7
+ data.tar.gz: 12d51bdaea741376370ea5e64abf645d9734a2edf4328118b8931c11d6032446830f0f7f495eed987e7fcc27518472e21f523d93bd1c1578468b97d9028d11c3
@@ -71,6 +71,8 @@ require "inspec/resources/key_rsa"
71
71
  require "inspec/resources/ksh"
72
72
  require "inspec/resources/limits_conf"
73
73
  require "inspec/resources/login_defs"
74
+ require "inspec/resources/mongodb"
75
+ require "inspec/resources/mongodb_conf"
74
76
  require "inspec/resources/mount"
75
77
  require "inspec/resources/mssql_session"
76
78
  require "inspec/resources/mysql"
@@ -0,0 +1,65 @@
1
+ module Inspec::Resources
2
+ class Mongodb < Inspec.resource(1)
3
+ name "mongodb"
4
+ supports platform: "unix"
5
+ supports platform: "windows"
6
+
7
+ desc "The 'mongodb' resource is a helper for the 'mongodb_conf' & 'mongodb_session' resources. Please use those instead."
8
+
9
+ attr_reader :conf_path
10
+
11
+ def initialize
12
+ case inspec.os[:family]
13
+ when "debian", "fedora", "redhat", "linux", "suse"
14
+ init_linux
15
+ when "darwin"
16
+ init_macos
17
+ when "windows"
18
+ init_windows
19
+ end
20
+ end
21
+
22
+ def to_s
23
+ "MongoDB"
24
+ end
25
+
26
+ private
27
+
28
+ def init_linux
29
+ @conf_path = "/etc/mongod.conf"
30
+ end
31
+
32
+ def init_macos
33
+ @conf_path = "/usr/local/etc/mongod.conf"
34
+ end
35
+
36
+ def init_windows
37
+ dir = "C:\\Program Files\\MongoDB\\Server"
38
+ @version = version_from_dir(dir)
39
+ unless @version.to_s.empty?
40
+ @conf_path = "#{dir}\\#{@version}\\bin\\mongod.cfg"
41
+ end
42
+ end
43
+
44
+ def version_from_dir(dir)
45
+ dirs = inspec.command("Get-ChildItem -Path \"#{dir}\" -Name").stdout
46
+ entries = dirs.lines.count
47
+ case entries
48
+ when 0
49
+ warn "Could not determine version of installed MongoDB by inspecting #{dir}"
50
+ nil
51
+ when 1
52
+ dir_to_version(dirs)
53
+ else
54
+ warn "Multiple versions of MongoDB installed or incorrect base dir #{dir}"
55
+ first = dir_to_version(dirs.lines.first)
56
+ warn "Using the first version found: #{first}"
57
+ first
58
+ end
59
+ end
60
+
61
+ def dir_to_version(dir)
62
+ dir.chomp.split("/").last
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,39 @@
1
+ require "inspec/resources/json"
2
+ require "inspec/resources/mongodb"
3
+
4
+ module Inspec::Resources
5
+ class MongodbConf < JsonConfig
6
+ name "mongodb_conf"
7
+ supports platform: "unix"
8
+ supports platform: "windows"
9
+ desc "Use the mongodb_conf InSpec audit resource to test the contents of the configuration file for MongoDB, typically located at `/etc/mongod.conf` or `C:\\Program Files\\MongoDB\\Server\\<version>\\bin\\mongod.cfg`, depending on the platform."
10
+ example <<~EXAMPLE
11
+ describe mongodb_conf do
12
+ its(["storage", "dbPath"]) { should eq "/var/lib/mongodb" }
13
+ its(["net", "port"]) { should eq 27017 }
14
+ end
15
+ EXAMPLE
16
+
17
+ def initialize(conf_path = nil)
18
+ @conf_path = conf_path || inspec.mongodb.conf_path
19
+
20
+ if @conf_path.nil?
21
+ return skip_resource "MongoDB conf path is not set."
22
+ end
23
+
24
+ super(@conf_path)
25
+ end
26
+
27
+ private
28
+
29
+ def parse(content)
30
+ YAML.load(content)
31
+ rescue => e
32
+ raise Inspec::Exceptions::ResourceFailed, "Unable to parse `mongod.conf` or `mongod.cfg` file: #{e.message}"
33
+ end
34
+
35
+ def resource_base_name
36
+ "MongoDB Configuration"
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "4.37.30".freeze
2
+ VERSION = "4.38.3".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.37.30
4
+ version: 4.38.3
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-16 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry
@@ -554,6 +554,8 @@ files:
554
554
  - lib/inspec/resources/limits_conf.rb
555
555
  - lib/inspec/resources/linux_kernel_parameter.rb
556
556
  - lib/inspec/resources/login_defs.rb
557
+ - lib/inspec/resources/mongodb.rb
558
+ - lib/inspec/resources/mongodb_conf.rb
557
559
  - lib/inspec/resources/mount.rb
558
560
  - lib/inspec/resources/mssql_session.rb
559
561
  - lib/inspec/resources/mysql.rb