inspec-core 4.7.3 → 4.7.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bundles/inspec-supermarket/api.rb +2 -1
- data/lib/bundles/inspec-supermarket/cli.rb +6 -6
- data/lib/bundles/inspec-supermarket/target.rb +1 -0
- data/lib/fetchers/git.rb +3 -1
- data/lib/fetchers/mock.rb +1 -0
- data/lib/fetchers/url.rb +6 -3
- data/lib/inspec/backend.rb +1 -0
- data/lib/inspec/base_cli.rb +4 -1
- data/lib/inspec/cli.rb +5 -4
- data/lib/inspec/config.rb +9 -1
- data/lib/inspec/control_eval_context.rb +1 -0
- data/lib/inspec/dependencies/cache.rb +1 -0
- data/lib/inspec/dependencies/dependency_set.rb +2 -0
- data/lib/inspec/dependencies/lockfile.rb +1 -0
- data/lib/inspec/dependencies/requirement.rb +8 -7
- data/lib/inspec/dependencies/resolver.rb +3 -3
- data/lib/inspec/describe.rb +1 -0
- data/lib/inspec/dsl.rb +1 -1
- data/lib/inspec/dsl_shared.rb +1 -1
- data/lib/inspec/env_printer.rb +4 -4
- data/lib/inspec/fetcher.rb +4 -2
- data/lib/inspec/file_provider.rb +18 -8
- data/lib/inspec/formatters/base.rb +5 -0
- data/lib/inspec/impact.rb +2 -0
- data/lib/inspec/input_registry.rb +14 -13
- data/lib/inspec/metadata.rb +6 -2
- data/lib/inspec/method_source.rb +1 -1
- data/lib/inspec/objects/control.rb +4 -1
- data/lib/inspec/objects/describe.rb +3 -1
- data/lib/inspec/objects/input.rb +6 -5
- data/lib/inspec/objects/list.rb +2 -0
- data/lib/inspec/objects/test.rb +3 -2
- data/lib/inspec/plugin/v1/plugin_types/resource.rb +7 -0
- data/lib/inspec/plugin/v1/plugins.rb +4 -3
- data/lib/inspec/plugin/v1/registry.rb +3 -2
- data/lib/inspec/plugin/v2.rb +1 -0
- data/lib/inspec/plugin/v2/activator.rb +2 -0
- data/lib/inspec/plugin/v2/config_file.rb +4 -1
- data/lib/inspec/plugin/v2/filter.rb +1 -0
- data/lib/inspec/plugin/v2/installer.rb +9 -7
- data/lib/inspec/plugin/v2/loader.rb +2 -0
- data/lib/inspec/plugin/v2/plugin_base.rb +1 -0
- data/lib/inspec/plugin/v2/plugin_types/cli.rb +2 -2
- data/lib/inspec/plugin/v2/registry.rb +3 -1
- data/lib/inspec/profile.rb +13 -6
- data/lib/inspec/profile_context.rb +4 -2
- data/lib/inspec/reporters/cli.rb +14 -10
- data/lib/inspec/reporters/json.rb +1 -0
- data/lib/inspec/reporters/json_automate.rb +3 -0
- data/lib/inspec/reporters/json_min.rb +2 -0
- data/lib/inspec/resource.rb +2 -0
- data/lib/inspec/resources/aide_conf.rb +4 -3
- data/lib/inspec/resources/apache_conf.rb +1 -1
- data/lib/inspec/resources/apt.rb +2 -0
- data/lib/inspec/resources/auditd.rb +19 -18
- data/lib/inspec/resources/bridge.rb +5 -2
- data/lib/inspec/resources/chocolatey_package.rb +2 -0
- data/lib/inspec/resources/command.rb +1 -1
- data/lib/inspec/resources/crontab.rb +9 -8
- data/lib/inspec/resources/csv.rb +1 -1
- data/lib/inspec/resources/dh_params.rb +6 -0
- data/lib/inspec/resources/docker.rb +37 -34
- data/lib/inspec/resources/docker_container.rb +1 -0
- data/lib/inspec/resources/docker_image.rb +1 -0
- data/lib/inspec/resources/docker_plugin.rb +1 -0
- data/lib/inspec/resources/docker_service.rb +1 -0
- data/lib/inspec/resources/elasticsearch.rb +24 -24
- data/lib/inspec/resources/etc_fstab.rb +8 -7
- data/lib/inspec/resources/etc_group.rb +4 -0
- data/lib/inspec/resources/etc_hosts.rb +4 -4
- data/lib/inspec/resources/etc_hosts_allow_deny.rb +5 -3
- data/lib/inspec/resources/file.rb +4 -1
- data/lib/inspec/resources/filesystem.rb +5 -3
- data/lib/inspec/resources/firewalld.rb +7 -4
- data/lib/inspec/resources/groups.rb +6 -4
- data/lib/inspec/resources/grub_conf.rb +3 -0
- data/lib/inspec/resources/host.rb +5 -3
- data/lib/inspec/resources/http.rb +6 -4
- data/lib/inspec/resources/iis_app.rb +1 -0
- data/lib/inspec/resources/iis_app_pool.rb +1 -1
- data/lib/inspec/resources/iis_site.rb +4 -3
- data/lib/inspec/resources/interface.rb +10 -7
- data/lib/inspec/resources/json.rb +1 -1
- data/lib/inspec/resources/kernel_module.rb +1 -1
- data/lib/inspec/resources/kernel_parameter.rb +2 -1
- data/lib/inspec/resources/key_rsa.rb +5 -0
- data/lib/inspec/resources/mount.rb +3 -1
- data/lib/inspec/resources/mysql_conf.rb +3 -1
- data/lib/inspec/resources/mysql_session.rb +2 -0
- data/lib/inspec/resources/nginx.rb +1 -0
- data/lib/inspec/resources/nginx_conf.rb +10 -6
- data/lib/inspec/resources/ntp_conf.rb +1 -0
- data/lib/inspec/resources/oneget.rb +1 -1
- data/lib/inspec/resources/oracledb_session.rb +4 -2
- data/lib/inspec/resources/os_env.rb +1 -0
- data/lib/inspec/resources/package.rb +10 -6
- data/lib/inspec/resources/packages.rb +7 -5
- data/lib/inspec/resources/passwd.rb +7 -7
- data/lib/inspec/resources/pip.rb +2 -0
- data/lib/inspec/resources/port.rb +22 -8
- data/lib/inspec/resources/postgres.rb +2 -1
- data/lib/inspec/resources/postgres_conf.rb +2 -0
- data/lib/inspec/resources/postgres_hba_conf.rb +6 -6
- data/lib/inspec/resources/postgres_ident_conf.rb +3 -3
- data/lib/inspec/resources/processes.rb +16 -15
- data/lib/inspec/resources/rabbitmq_config.rb +2 -0
- data/lib/inspec/resources/registry_key.rb +8 -3
- data/lib/inspec/resources/security_identifier.rb +3 -1
- data/lib/inspec/resources/security_policy.rb +2 -1
- data/lib/inspec/resources/service.rb +13 -1
- data/lib/inspec/resources/shadow.rb +1 -0
- data/lib/inspec/resources/ssh_config.rb +2 -0
- data/lib/inspec/resources/ssl.rb +12 -11
- data/lib/inspec/resources/users.rb +29 -19
- data/lib/inspec/resources/virtualization.rb +10 -0
- data/lib/inspec/resources/windows_feature.rb +1 -1
- data/lib/inspec/resources/windows_hotfix.rb +2 -0
- data/lib/inspec/resources/windows_task.rb +4 -0
- data/lib/inspec/resources/wmi.rb +2 -1
- data/lib/inspec/resources/x509_certificate.rb +8 -0
- data/lib/inspec/resources/xinetd_conf.rb +10 -9
- data/lib/inspec/resources/yum.rb +15 -11
- data/lib/inspec/resources/zfs_dataset.rb +4 -2
- data/lib/inspec/resources/zfs_pool.rb +2 -1
- data/lib/inspec/rule.rb +11 -1
- data/lib/inspec/runner.rb +9 -6
- data/lib/inspec/runner_rspec.rb +10 -8
- data/lib/inspec/schema.rb +1 -0
- data/lib/inspec/secrets.rb +1 -0
- data/lib/inspec/secrets/yaml.rb +1 -0
- data/lib/inspec/shell.rb +20 -19
- data/lib/inspec/shell_detector.rb +1 -1
- data/lib/inspec/source_reader.rb +2 -0
- data/lib/inspec/ui.rb +1 -0
- data/lib/inspec/utils/deprecation/config_file.rb +8 -4
- data/lib/inspec/utils/erlang_parser.rb +2 -0
- data/lib/inspec/utils/file_reader.rb +1 -1
- data/lib/inspec/utils/filter.rb +16 -3
- data/lib/inspec/utils/find_files.rb +2 -2
- data/lib/inspec/utils/object_traversal.rb +1 -0
- data/lib/inspec/utils/parser.rb +2 -0
- data/lib/inspec/utils/simpleconfig.rb +4 -1
- data/lib/inspec/utils/telemetry/global_methods.rb +1 -0
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +4 -1
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +12 -11
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +15 -11
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +4 -2
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +13 -12
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +3 -0
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +1 -1
- data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +2 -2
- data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +1 -0
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +6 -5
- data/lib/plugins/shared/core_plugin_test_helper.rb +1 -0
- data/lib/source_readers/flat.rb +1 -0
- data/lib/source_readers/inspec.rb +1 -0
- metadata +2 -2
@@ -49,13 +49,13 @@ module Inspec::Resources
|
|
49
49
|
end
|
50
50
|
|
51
51
|
filter = FilterTable.create
|
52
|
-
filter.register_column(:users,
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
filter.register_column(:users, field: "user")
|
53
|
+
.register_column(:passwords, field: "password")
|
54
|
+
.register_column(:uids, field: "uid")
|
55
|
+
.register_column(:gids, field: "gid")
|
56
|
+
.register_column(:descs, field: "desc")
|
57
|
+
.register_column(:homes, field: "home")
|
58
|
+
.register_column(:shells, field: "shell")
|
59
59
|
|
60
60
|
# rebuild the passwd line from raw content
|
61
61
|
filter.register_custom_property(:content) do |t, _|
|
data/lib/inspec/resources/pip.rb
CHANGED
@@ -88,6 +88,7 @@ module Inspec::Resources
|
|
88
88
|
# @return [Hash] of windows_paths
|
89
89
|
def windows_paths
|
90
90
|
return @__windows_paths if @__windows_paths
|
91
|
+
|
91
92
|
cmd = inspec.command(
|
92
93
|
'New-Object -Type PSObject |
|
93
94
|
Add-Member -MemberType NoteProperty -Name Pip -Value (Invoke-Command -ScriptBlock {where.exe pip}) -PassThru |
|
@@ -115,6 +116,7 @@ module Inspec::Resources
|
|
115
116
|
# calculate path on windows
|
116
117
|
if defined?(windows_paths["Python"]) && pipcmd.nil?
|
117
118
|
return nil if windows_paths["Pip"].nil?
|
119
|
+
|
118
120
|
pipdir = windows_paths["Python"].split('\\')
|
119
121
|
# remove python.exe
|
120
122
|
pipdir.pop
|
@@ -37,12 +37,12 @@ module Inspec::Resources
|
|
37
37
|
end
|
38
38
|
|
39
39
|
filter = FilterTable.create
|
40
|
-
filter.register_column(:ports,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
filter.register_column(:ports, field: "port", style: :simple)
|
41
|
+
.register_column(:addresses, field: "address", style: :simple)
|
42
|
+
.register_column(:protocols, field: "protocol", style: :simple)
|
43
|
+
.register_column(:processes, field: "process", style: :simple)
|
44
|
+
.register_column(:pids, field: "pid", style: :simple)
|
45
|
+
.register_custom_matcher(:listening?) { |x| !x.entries.empty? }
|
46
46
|
filter.install_filter_methods_on_resource(self, :info)
|
47
47
|
|
48
48
|
def to_s
|
@@ -76,9 +76,10 @@ module Inspec::Resources
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def info
|
79
|
-
return @cache
|
79
|
+
return @cache unless @cache.nil?
|
80
80
|
# abort if os detection has not worked
|
81
81
|
return @cache = [] if @port_manager.nil?
|
82
|
+
|
82
83
|
# query ports
|
83
84
|
cache = @port_manager.info || []
|
84
85
|
cache.select! { |x| x["port"] == @port } unless @port.nil?
|
@@ -141,6 +142,7 @@ module Inspec::Resources
|
|
141
142
|
# also UDP ports have nothing in the State column
|
142
143
|
cmd = inspec.command('netstat -anbo | Select-String -CaseSensitive -pattern "^\s+UDP|\s+LISTENING\s+\d+$" -context 0,1')
|
143
144
|
return nil if cmd.exit_status != 0
|
145
|
+
|
144
146
|
lines = cmd.stdout.scan(/^>\s*(tcp\S*|udp\S*)\s+(\S+):(\d+)\s+(\S+)\s+(\S*)\s+(\d+)\s+(.+)/i)
|
145
147
|
lines.map do |line|
|
146
148
|
pid = line[5].to_i
|
@@ -170,7 +172,7 @@ module Inspec::Resources
|
|
170
172
|
ports = []
|
171
173
|
|
172
174
|
# check that lsof is available, otherwise fail
|
173
|
-
raise "Please ensure `lsof` is available on the machine."
|
175
|
+
raise "Please ensure `lsof` is available on the machine." unless inspec.command(@lsof.to_s).exist?
|
174
176
|
|
175
177
|
# -F p=pid, c=command, P=protocol name, t=type, n=internet addresses
|
176
178
|
# see 'OUTPUT FOR OTHER PROGRAMS' in LSOF(8)
|
@@ -270,6 +272,7 @@ module Inspec::Resources
|
|
270
272
|
|
271
273
|
def ports_via_lsof
|
272
274
|
return nil unless inspec.command("lsof").exist?
|
275
|
+
|
273
276
|
LsofPorts.new(inspec).info
|
274
277
|
end
|
275
278
|
|
@@ -286,6 +289,7 @@ module Inspec::Resources
|
|
286
289
|
|
287
290
|
# only push protocols we are interested in
|
288
291
|
next unless %w{tcp tcp6 udp udp6}.include?(port_info["protocol"])
|
292
|
+
|
289
293
|
ports.push(port_info)
|
290
294
|
end
|
291
295
|
|
@@ -313,6 +317,7 @@ module Inspec::Resources
|
|
313
317
|
cmd = inspec.command("rmsock #{parsed[1]} tcpcb")
|
314
318
|
parsed_pid = /^The socket (\S+) is being held by proccess (\d+) \((\S+)\)/.match(cmd.stdout)
|
315
319
|
return {} if parsed_pid.nil?
|
320
|
+
|
316
321
|
process = parsed_pid[3]
|
317
322
|
pid = parsed_pid[2]
|
318
323
|
pid = pid.to_i if pid =~ /^\d+$/
|
@@ -415,6 +420,7 @@ module Inspec::Resources
|
|
415
420
|
|
416
421
|
# only push protocols we are interested in
|
417
422
|
next unless %w{tcp tcp6 udp udp6}.include?(port_info["protocol"])
|
423
|
+
|
418
424
|
ports.push(port_info)
|
419
425
|
end
|
420
426
|
ports
|
@@ -554,6 +560,7 @@ module Inspec::Resources
|
|
554
560
|
# fe80::a00:27ff:fe32:ed09%enp0s3:9200
|
555
561
|
parsed_net_address = parsed[:local_addr].match(/(\S+):(\*|\d+)$/)
|
556
562
|
return nil if parsed_net_address.nil?
|
563
|
+
|
557
564
|
host = parsed_net_address[1]
|
558
565
|
port = parsed_net_address[2]
|
559
566
|
return nil if host.nil? && port.nil?
|
@@ -631,6 +638,7 @@ module Inspec::Resources
|
|
631
638
|
|
632
639
|
# push data, if not headerfile
|
633
640
|
next unless %w{tcp tcp6 udp udp6}.include?(port_info["protocol"])
|
641
|
+
|
634
642
|
ports.push(port_info)
|
635
643
|
end
|
636
644
|
ports
|
@@ -646,6 +654,7 @@ module Inspec::Resources
|
|
646
654
|
port = ip_addr.port
|
647
655
|
when "tcp6", "udp6"
|
648
656
|
return [] if net_addr == "*:*" # abort for now
|
657
|
+
|
649
658
|
# replace * with 0:0:0:0:0:0:0:0
|
650
659
|
net_addr = net_addr.gsub(/^\*:/, "0:0:0:0:0:0:0:0:") if net_addr =~ /^*:(\d+)$/
|
651
660
|
# extract port
|
@@ -738,14 +747,17 @@ module Inspec::Resources
|
|
738
747
|
## Can't use 'netstat -an -f inet -f inet6' as the latter -f option overrides the former one and return only inet ports
|
739
748
|
cmd1 = inspec.command("netstat -an -f inet")
|
740
749
|
return nil if cmd1.exit_status.to_i != 0
|
750
|
+
|
741
751
|
cmd2 = inspec.command("netstat -an -f inet6")
|
742
752
|
return nil if cmd2.exit_status.to_i != 0
|
753
|
+
|
743
754
|
cmd = cmd1.stdout + cmd2.stdout
|
744
755
|
ports = []
|
745
756
|
# parse all lines
|
746
757
|
cmd.each_line do |line|
|
747
758
|
port_info = parse_netstat_line(line)
|
748
759
|
next unless %w{tcp tcp6 udp udp6}.include?(port_info["protocol"])
|
760
|
+
|
749
761
|
ports.push(port_info)
|
750
762
|
end
|
751
763
|
# select all ports, where we `listen`
|
@@ -758,6 +770,7 @@ module Inspec::Resources
|
|
758
770
|
parsed = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)?/.match(line)
|
759
771
|
|
760
772
|
return {} if parsed.nil? || line.match(/^proto/i) || line.match(/^active/i)
|
773
|
+
|
761
774
|
protocol = parsed[1].downcase
|
762
775
|
state = parsed[6].nil? ? " " : parsed[6].downcase
|
763
776
|
local_addr = parsed[4]
|
@@ -765,6 +778,7 @@ module Inspec::Resources
|
|
765
778
|
# extract host and port information
|
766
779
|
host, port = parse_net_address(local_addr, protocol)
|
767
780
|
return {} if host.nil?
|
781
|
+
|
768
782
|
# map data
|
769
783
|
{
|
770
784
|
"port" => port,
|
@@ -38,7 +38,7 @@ module Inspec::Resources
|
|
38
38
|
# installed as well as multiple "clusters" to be configured.
|
39
39
|
#
|
40
40
|
@version = version_from_psql || version_from_dir("/etc/postgresql")
|
41
|
-
|
41
|
+
unless @version.to_s.empty?
|
42
42
|
@cluster = cluster_from_dir("/etc/postgresql/#{@version}")
|
43
43
|
@conf_dir = "/etc/postgresql/#{@version}/#{@cluster}"
|
44
44
|
@data_dir = "/var/lib/postgresql/#{@version}/#{@cluster}"
|
@@ -83,6 +83,7 @@ module Inspec::Resources
|
|
83
83
|
|
84
84
|
def version_from_psql
|
85
85
|
return unless inspec.command("psql").exist?
|
86
|
+
|
86
87
|
inspec.command("psql --version | awk '{ print $NF }' | awk -F. '{ print $1\".\"$2 }'").stdout.strip
|
87
88
|
end
|
88
89
|
|
@@ -27,6 +27,7 @@ module Inspec::Resources
|
|
27
27
|
if @conf_path.nil?
|
28
28
|
return skip_resource "PostgreSQL conf path is not set"
|
29
29
|
end
|
30
|
+
|
30
31
|
@conf_dir = File.expand_path(File.dirname(@conf_path))
|
31
32
|
@files_contents = {}
|
32
33
|
@content = nil
|
@@ -57,6 +58,7 @@ module Inspec::Resources
|
|
57
58
|
return nil if param.nil?
|
58
59
|
# extract first value if we have only one value in array
|
59
60
|
return param[0] if param.length == 1
|
61
|
+
|
60
62
|
param
|
61
63
|
end
|
62
64
|
|
@@ -26,12 +26,12 @@ module Inspec::Resources
|
|
26
26
|
end
|
27
27
|
|
28
28
|
filter = FilterTable.create
|
29
|
-
filter.register_column(:type,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
filter.register_column(:type, field: "type")
|
30
|
+
.register_column(:database, field: "database")
|
31
|
+
.register_column(:user, field: "user")
|
32
|
+
.register_column(:address, field: "address")
|
33
|
+
.register_column(:auth_method, field: "auth_method")
|
34
|
+
.register_column(:auth_params, field: "auth_params")
|
35
35
|
|
36
36
|
filter.install_filter_methods_on_resource(self, :params)
|
37
37
|
|
@@ -25,9 +25,9 @@ module Inspec::Resources
|
|
25
25
|
end
|
26
26
|
|
27
27
|
filter = FilterTable.create
|
28
|
-
filter.register_column(:map_name,
|
29
|
-
|
30
|
-
|
28
|
+
filter.register_column(:map_name, field: "map_name")
|
29
|
+
.register_column(:system_username, field: "system_username")
|
30
|
+
.register_column(:pg_username, field: "pg_username")
|
31
31
|
|
32
32
|
filter.install_filter_methods_on_resource(self, :params)
|
33
33
|
|
@@ -61,19 +61,19 @@ module Inspec::Resources
|
|
61
61
|
end
|
62
62
|
|
63
63
|
filter = FilterTable.create
|
64
|
-
filter.register_column(:labels,
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
64
|
+
filter.register_column(:labels, field: "label")
|
65
|
+
.register_column(:pids, field: "pid")
|
66
|
+
.register_column(:cpus, field: "cpu")
|
67
|
+
.register_column(:mem, field: "mem")
|
68
|
+
.register_column(:vsz, field: "vsz")
|
69
|
+
.register_column(:rss, field: "rss")
|
70
|
+
.register_column(:tty, field: "tty")
|
71
|
+
.register_column(:states, field: "stat")
|
72
|
+
.register_column(:start, field: "start")
|
73
|
+
.register_column(:time, field: "time")
|
74
|
+
.register_column(:users, field: "user")
|
75
|
+
.register_column(:commands, field: "command")
|
76
|
+
.install_filter_methods_on_resource(self, :filtered_processes)
|
77
77
|
|
78
78
|
private
|
79
79
|
|
@@ -193,7 +193,7 @@ module Inspec::Resources
|
|
193
193
|
|
194
194
|
# build a hash of process data that we'll turn into a struct for FilterTable
|
195
195
|
process_data = {}
|
196
|
-
|
196
|
+
%i{label pid cpu mem vsz rss tty stat start time user command}.each do |param|
|
197
197
|
# not all operating systems support all fields, so skip the field if we don't have it
|
198
198
|
process_data[param] = line[field_map[param]] if field_map.key?(param)
|
199
199
|
end
|
@@ -202,8 +202,9 @@ module Inspec::Resources
|
|
202
202
|
process_data[:pid] = process_data[:pid].to_i if process_data.key?(:pid)
|
203
203
|
|
204
204
|
# some ps variants (*cough* busybox) display vsz and rss as human readable MB or GB
|
205
|
-
|
205
|
+
%i{vsz rss}.each do |param|
|
206
206
|
next unless process_data.key?(param)
|
207
|
+
|
207
208
|
process_data[param] = convert_to_kilobytes(process_data[param])
|
208
209
|
end
|
209
210
|
|
@@ -36,12 +36,14 @@ module Inspec::Resources
|
|
36
36
|
|
37
37
|
def read_content
|
38
38
|
return @content if defined?(@content)
|
39
|
+
|
39
40
|
@content = read_file_content(@conf_path, allow_empty: true)
|
40
41
|
end
|
41
42
|
|
42
43
|
def read_params
|
43
44
|
return @params if defined?(@params)
|
44
45
|
return @params = {} if read_content.nil?
|
46
|
+
|
45
47
|
@params = ErlangConfigFile.parse(read_content)
|
46
48
|
rescue Parslet::ParseFailed
|
47
49
|
raise "Cannot parse RabbitMQ config: \"#{read_content}\""
|
@@ -71,7 +71,7 @@ module Inspec::Resources
|
|
71
71
|
@options[:path] = reg_key
|
72
72
|
end
|
73
73
|
|
74
|
-
return skip_resource "The `registry_key` resource is not supported on your OS yet."
|
74
|
+
return skip_resource "The `registry_key` resource is not supported on your OS yet." unless inspec.os.windows?
|
75
75
|
end
|
76
76
|
|
77
77
|
def exists?
|
@@ -133,24 +133,28 @@ module Inspec::Resources
|
|
133
133
|
|
134
134
|
def registry_property_exists(regkey, property)
|
135
135
|
return false if regkey.nil? || property.nil?
|
136
|
+
|
136
137
|
# always ensure the key is lower case
|
137
138
|
!regkey[prep_prop(property)].nil?
|
138
139
|
end
|
139
140
|
|
140
141
|
def registry_property_value(regkey, property)
|
141
|
-
return nil
|
142
|
+
return nil unless registry_property_exists(regkey, property)
|
143
|
+
|
142
144
|
# always ensure the key is lower case
|
143
145
|
regkey[prep_prop(property)]["value"]
|
144
146
|
end
|
145
147
|
|
146
148
|
def registry_property_type(regkey, property)
|
147
|
-
return nil
|
149
|
+
return nil unless registry_property_exists(regkey, property)
|
150
|
+
|
148
151
|
# always ensure the key is lower case
|
149
152
|
regkey[prep_prop(property)]["type"]
|
150
153
|
end
|
151
154
|
|
152
155
|
def registry_key(path)
|
153
156
|
return @registry_cache if defined?(@registry_cache)
|
157
|
+
|
154
158
|
# load registry key and all properties
|
155
159
|
script = <<-EOH
|
156
160
|
Function InSpec-GetRegistryKey($path) {
|
@@ -199,6 +203,7 @@ module Inspec::Resources
|
|
199
203
|
|
200
204
|
def children_keys(path, filter = "")
|
201
205
|
return @children_cache if defined?(@children_cache)
|
206
|
+
|
202
207
|
filter = filter.source if filter.is_a? ::Regexp
|
203
208
|
script = <<-EOH
|
204
209
|
Function InSpec-FindChildsRegistryKeys($path, $filter) {
|
@@ -15,10 +15,11 @@ module Inspec::Resources
|
|
15
15
|
EXAMPLE
|
16
16
|
|
17
17
|
def initialize(opts = {})
|
18
|
-
supported_opt_keys =
|
18
|
+
supported_opt_keys = %i{user group unspecified}
|
19
19
|
raise ArgumentError, "Invalid security_identifier param '#{opts}'. Please pass a hash with these supported keys: #{supported_opt_keys}" unless opts.respond_to?(:keys)
|
20
20
|
raise ArgumentError, "Unsupported security_identifier options '#{opts.keys - supported_opt_keys}'. Supported keys: #[supported_opt_keys]" unless (opts.keys - supported_opt_keys).empty?
|
21
21
|
raise ArgumentError, "Specifying more than one of :user :group or :unspecified for security_identifier is not supported" unless opts.keys && (opts.keys & supported_opt_keys).length == 1
|
22
|
+
|
22
23
|
if opts[:user]
|
23
24
|
@type = :user
|
24
25
|
@name = opts[:user]
|
@@ -32,6 +33,7 @@ module Inspec::Resources
|
|
32
33
|
@name = opts[:unspecified]
|
33
34
|
end
|
34
35
|
raise ArgumentError, "Specify one of :user :group or :unspecified for security_identifier" unless @name
|
36
|
+
|
35
37
|
@sids = nil
|
36
38
|
end
|
37
39
|
|
@@ -104,6 +104,7 @@ module Inspec::Resources
|
|
104
104
|
|
105
105
|
# return an empty array if configuration does not include rights configuration
|
106
106
|
return [] if res.nil? && MS_PRIVILEGES_RIGHTS.include?(name.to_s)
|
107
|
+
|
107
108
|
res
|
108
109
|
end
|
109
110
|
|
@@ -153,7 +154,7 @@ module Inspec::Resources
|
|
153
154
|
elsif val =~ /[,]{0,1}\*\S/
|
154
155
|
if @translate_sid
|
155
156
|
val.split(",").map do |v|
|
156
|
-
object_name = inspec.command("(New-Object System.Security.Principal.SecurityIdentifier(\"#{v.sub(
|
157
|
+
object_name = inspec.command("(New-Object System.Security.Principal.SecurityIdentifier(\"#{v.sub("*S", "S")}\")).Translate( [System.Security.Principal.NTAccount]).Value").stdout.to_s.strip
|
157
158
|
object_name.empty? || object_name.nil? ? v.sub("*S", "S") : object_name
|
158
159
|
end
|
159
160
|
else
|
@@ -52,7 +52,7 @@ module Inspec::Resources
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def to_s
|
55
|
-
"#{owner} runlevels #{keys.join(
|
55
|
+
"#{owner} runlevels #{keys.join(", ")}"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -177,59 +177,69 @@ module Inspec::Resources
|
|
177
177
|
|
178
178
|
def info
|
179
179
|
return nil if @service_mgmt.nil?
|
180
|
+
|
180
181
|
@cache ||= @service_mgmt.info(@service_name)
|
181
182
|
end
|
182
183
|
|
183
184
|
# verifies if the service is enabled
|
184
185
|
def enabled?(_level = nil)
|
185
186
|
return false if info.nil?
|
187
|
+
|
186
188
|
info[:enabled]
|
187
189
|
end
|
188
190
|
|
189
191
|
def params
|
190
192
|
return {} if info.nil?
|
193
|
+
|
191
194
|
Hashie::Mash.new(info[:params] || {})
|
192
195
|
end
|
193
196
|
|
194
197
|
# verifies the service is registered
|
195
198
|
def installed?(_name = nil, _version = nil)
|
196
199
|
return false if info.nil?
|
200
|
+
|
197
201
|
info[:installed]
|
198
202
|
end
|
199
203
|
|
200
204
|
# verifies the service is currently running
|
201
205
|
def running?(_under = nil)
|
202
206
|
return false if info.nil?
|
207
|
+
|
203
208
|
info[:running]
|
204
209
|
end
|
205
210
|
|
206
211
|
# get all runlevels that are available and their configuration
|
207
212
|
def runlevels(*args)
|
208
213
|
return Runlevels.new(self) if info.nil? || info[:runlevels].nil?
|
214
|
+
|
209
215
|
Runlevels.from_hash(self, info[:runlevels], args)
|
210
216
|
end
|
211
217
|
|
212
218
|
# returns the service type from info
|
213
219
|
def type
|
214
220
|
return nil if info.nil?
|
221
|
+
|
215
222
|
info[:type]
|
216
223
|
end
|
217
224
|
|
218
225
|
# returns the service name from info
|
219
226
|
def name
|
220
227
|
return @service_name if info.nil?
|
228
|
+
|
221
229
|
info[:name]
|
222
230
|
end
|
223
231
|
|
224
232
|
# returns the service description from info
|
225
233
|
def description
|
226
234
|
return nil if info.nil?
|
235
|
+
|
227
236
|
info[:description]
|
228
237
|
end
|
229
238
|
|
230
239
|
# returns the service start up mode from info
|
231
240
|
def startmode
|
232
241
|
return nil if info.nil?
|
242
|
+
|
233
243
|
info[:startmode]
|
234
244
|
end
|
235
245
|
|
@@ -324,6 +334,7 @@ module Inspec::Resources
|
|
324
334
|
def status?
|
325
335
|
status_cmd = inspec.command("lssrc -s #{@name}")
|
326
336
|
return nil if status_cmd.exit_status.to_i != 0
|
337
|
+
|
327
338
|
status_cmd.stdout.split(/\n/).last.chomp =~ /active$/ ? true : false
|
328
339
|
end
|
329
340
|
|
@@ -463,6 +474,7 @@ module Inspec::Resources
|
|
463
474
|
# search for the service
|
464
475
|
srv = /(^.*#{service_name}$)/.match(cmd.stdout)
|
465
476
|
return nil if srv.nil? || srv[0].nil?
|
477
|
+
|
466
478
|
enabled = true
|
467
479
|
|
468
480
|
# check if the service is running
|