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
@@ -117,7 +117,7 @@ class IisAppPool < Inspec.resource(1)
|
|
117
117
|
e32b: pool["enable32BitAppOnWin64"],
|
118
118
|
mode: pool["managedPipelineMode"],
|
119
119
|
processes: process_model["maxProcesses"],
|
120
|
-
timeout: "#{idle_timeout[
|
120
|
+
timeout: "#{idle_timeout["Hours"]}:#{idle_timeout["Minutes"]}:#{idle_timeout["Seconds"]}",
|
121
121
|
timeout_days: idle_timeout["Days"],
|
122
122
|
timeout_hours: idle_timeout["Hours"],
|
123
123
|
timeout_minutes: idle_timeout["Minutes"],
|
@@ -82,8 +82,9 @@ module Inspec::Resources
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def iis_site
|
85
|
-
return @cache
|
86
|
-
|
85
|
+
return @cache unless @cache.nil?
|
86
|
+
|
87
|
+
@cache = @site_provider.iis_site(@site_name) unless @site_provider.nil?
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -106,7 +107,7 @@ module Inspec::Resources
|
|
106
107
|
end
|
107
108
|
|
108
109
|
bindings_array = site["bindings"]["Collection"].map do |k|
|
109
|
-
"#{k[
|
110
|
+
"#{k["protocol"]} #{k["bindingInformation"]}#{k["protocol"] == "https" ? " sslFlags=#{k["sslFlags"]}" : ""}"
|
110
111
|
end
|
111
112
|
|
112
113
|
# map our values to a hash table
|
@@ -61,13 +61,13 @@ module Inspec::Resources
|
|
61
61
|
|
62
62
|
def ipv4_addresses_netmask
|
63
63
|
ipv4_cidrs.map { |i| i.split("/") }.map do |addr, netlen|
|
64
|
-
binmask = "#{
|
64
|
+
binmask = "#{"1" * netlen.to_i}#{"0" * (32 - netlen.to_i)}".to_i(2)
|
65
65
|
netmask = []
|
66
66
|
(1..4).each do |_byte|
|
67
67
|
netmask.unshift(binmask & 255)
|
68
68
|
binmask = binmask >> 8
|
69
69
|
end
|
70
|
-
"#{addr}/#{netmask.join(
|
70
|
+
"#{addr}/#{netmask.join(".")}"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -87,7 +87,8 @@ module Inspec::Resources
|
|
87
87
|
|
88
88
|
def interface_info
|
89
89
|
return @cache if defined?(@cache)
|
90
|
-
|
90
|
+
|
91
|
+
@cache = @interface_provider.interface_info(@iface) unless @interface_provider.nil?
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
@@ -142,6 +143,7 @@ module Inspec::Resources
|
|
142
143
|
[4, 6].each do |v|
|
143
144
|
cmd = inspec.command("/sbin/ip -br -#{v} address show dev #{iface}")
|
144
145
|
next unless cmd.exit_status.to_i == 0
|
146
|
+
|
145
147
|
family = v == 6 ? "inet6" : "inet"
|
146
148
|
|
147
149
|
cmd.stdout.each_line do |line|
|
@@ -171,8 +173,8 @@ module Inspec::Resources
|
|
171
173
|
end
|
172
174
|
|
173
175
|
# ensure we have an array of groups
|
174
|
-
net_adapter = [net_adapter]
|
175
|
-
addresses = [addresses]
|
176
|
+
net_adapter = [net_adapter] unless net_adapter.is_a?(Array)
|
177
|
+
addresses = [addresses] unless addresses.is_a?(Array)
|
176
178
|
|
177
179
|
# select the requested interface
|
178
180
|
adapters = net_adapter.each_with_object([]) do |adapter, adapter_collection|
|
@@ -188,6 +190,7 @@ module Inspec::Resources
|
|
188
190
|
end
|
189
191
|
|
190
192
|
return nil if adapters.empty?
|
193
|
+
|
191
194
|
warn "[Possible Error] detected multiple network interfaces with the name #{iface}" if adapters.size > 1
|
192
195
|
adapters[0]
|
193
196
|
end
|
@@ -196,8 +199,8 @@ module Inspec::Resources
|
|
196
199
|
|
197
200
|
def addresses_for_proto(all_addresses, iface, proto)
|
198
201
|
all_addresses.select { |i| i["InterfaceAlias"] == iface }
|
199
|
-
|
200
|
-
|
202
|
+
.map { |i| "#{i["#{proto}Address"]}/#{i["PrefixLength"]}" unless i["#{proto}Address"].nil? }
|
203
|
+
.compact
|
201
204
|
end
|
202
205
|
end
|
203
206
|
end
|
@@ -36,7 +36,7 @@ module Inspec::Resources
|
|
36
36
|
def initialize(modulename = nil)
|
37
37
|
@module = modulename
|
38
38
|
# this resource is only supported on Linux
|
39
|
-
return skip_resource "The `kernel_parameter` resource is not supported on your OS."
|
39
|
+
return skip_resource "The `kernel_parameter` resource is not supported on your OS." unless inspec.os.linux?
|
40
40
|
end
|
41
41
|
|
42
42
|
def loaded?
|
@@ -15,12 +15,13 @@ module Inspec::Resources
|
|
15
15
|
@parameter = parameter
|
16
16
|
|
17
17
|
# this resource is only supported on Linux
|
18
|
-
return skip_resource "The `kernel_parameter` resource is not supported on your OS."
|
18
|
+
return skip_resource "The `kernel_parameter` resource is not supported on your OS." unless inspec.os.linux?
|
19
19
|
end
|
20
20
|
|
21
21
|
def value
|
22
22
|
cmd = inspec.command("/sbin/sysctl -q -n #{@parameter}")
|
23
23
|
return nil if cmd.exit_status != 0
|
24
|
+
|
24
25
|
# remove whitespace
|
25
26
|
cmd = cmd.stdout.chomp.strip
|
26
27
|
# convert to number if possible
|
@@ -31,26 +31,31 @@ module Inspec::Resources
|
|
31
31
|
|
32
32
|
def public?
|
33
33
|
return if @key.nil?
|
34
|
+
|
34
35
|
@key.public?
|
35
36
|
end
|
36
37
|
|
37
38
|
def public_key
|
38
39
|
return if @key.nil?
|
40
|
+
|
39
41
|
@key.public_key.to_s
|
40
42
|
end
|
41
43
|
|
42
44
|
def private?
|
43
45
|
return if @key.nil?
|
46
|
+
|
44
47
|
@key.private?
|
45
48
|
end
|
46
49
|
|
47
50
|
def private_key
|
48
51
|
return if @key.nil?
|
52
|
+
|
49
53
|
@key.to_s
|
50
54
|
end
|
51
55
|
|
52
56
|
def key_length
|
53
57
|
return if @key.nil?
|
58
|
+
|
54
59
|
@key.public_key.n.num_bytes * 8
|
55
60
|
end
|
56
61
|
|
@@ -21,6 +21,7 @@ module Inspec::Resources
|
|
21
21
|
@path = path
|
22
22
|
@mount_manager = mount_manager_for_os
|
23
23
|
return skip_resource "The `mount` resource is not supported on your OS yet." if @mount_manager.nil?
|
24
|
+
|
24
25
|
@file = inspec.backend.file(@path)
|
25
26
|
end
|
26
27
|
|
@@ -31,11 +32,12 @@ module Inspec::Resources
|
|
31
32
|
def count
|
32
33
|
mounted = file.mounted
|
33
34
|
return nil if mounted.nil? || mounted.stdout.nil?
|
35
|
+
|
34
36
|
mounted.stdout.lines.count
|
35
37
|
end
|
36
38
|
|
37
39
|
def method_missing(name)
|
38
|
-
return nil
|
40
|
+
return nil unless file.mounted?
|
39
41
|
|
40
42
|
mounted = file.mounted
|
41
43
|
return nil if mounted.nil? || mounted.stdout.nil?
|
@@ -17,11 +17,12 @@ module Inspec::Resources
|
|
17
17
|
k = name.to_s
|
18
18
|
res = @params[k]
|
19
19
|
return true if res.nil? && @params.key?(k)
|
20
|
+
|
20
21
|
@params[k]
|
21
22
|
end
|
22
23
|
|
23
24
|
def to_s
|
24
|
-
"MySQL Config entry [#{@path.join(
|
25
|
+
"MySQL Config entry [#{@path.join(" ")}]"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -112,6 +113,7 @@ module Inspec::Resources
|
|
112
113
|
|
113
114
|
def abs_path(dir, f)
|
114
115
|
return f if f.start_with? "/"
|
116
|
+
|
115
117
|
File.join(dir, f)
|
116
118
|
end
|
117
119
|
|
@@ -73,12 +73,14 @@ module Inspec::Resources
|
|
73
73
|
def init_fallback
|
74
74
|
# support debian mysql administration login
|
75
75
|
return if inspec.platform.in_family?("windows")
|
76
|
+
|
76
77
|
debian = inspec.command("test -f /etc/mysql/debian.cnf && cat /etc/mysql/debian.cnf").stdout
|
77
78
|
return if debian.empty?
|
78
79
|
|
79
80
|
user = debian.match(/^\s*user\s*=\s*([^ ]*)\s*$/)
|
80
81
|
pass = debian.match(/^\s*password\s*=\s*([^ ]*)\s*$/)
|
81
82
|
return if user.nil? || pass.nil?
|
83
|
+
|
82
84
|
@user = user[1]
|
83
85
|
@pass = pass[1]
|
84
86
|
end
|
@@ -33,6 +33,7 @@ module Inspec::Resources
|
|
33
33
|
@conf_path = conf_path || "/etc/nginx/nginx.conf"
|
34
34
|
@contents = {}
|
35
35
|
return skip_resource "The `nginx_conf` resource is currently not supported on Windows." if inspec.os.windows?
|
36
|
+
|
36
37
|
read_content(@conf_path)
|
37
38
|
end
|
38
39
|
|
@@ -57,11 +58,13 @@ module Inspec::Resources
|
|
57
58
|
|
58
59
|
def read_content(path)
|
59
60
|
return @contents[path] if @contents.key?(path)
|
61
|
+
|
60
62
|
@contents[path] = read_file_content(path, allow_empty: true)
|
61
63
|
end
|
62
64
|
|
63
65
|
def parse_nginx(path)
|
64
66
|
return nil if inspec.os.windows?
|
67
|
+
|
65
68
|
content = read_content(path)
|
66
69
|
|
67
70
|
# Don't attempt to parse file if it contains only comments or is empty
|
@@ -96,10 +99,10 @@ module Inspec::Resources
|
|
96
99
|
# into the current data structure
|
97
100
|
if data.key?("include")
|
98
101
|
data.delete("include").flatten
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
.map { |x| File.expand_path(x, rel_path) }
|
103
|
+
.map { |x| find_files(x) }.flatten
|
104
|
+
.map { |path| parse_nginx(path) }
|
105
|
+
.each { |conf| merge_config!(data, conf) }
|
103
106
|
end
|
104
107
|
|
105
108
|
# Walk through the remaining hash fields to find more references
|
@@ -114,6 +117,7 @@ module Inspec::Resources
|
|
114
117
|
def merge_config!(data, conf)
|
115
118
|
# Catch edge-cases
|
116
119
|
return if data.nil? || conf.nil?
|
120
|
+
|
117
121
|
# Step through all conf items and create combined return value
|
118
122
|
data.merge!(conf) do |_, v1, v2|
|
119
123
|
if v1.is_a?(Array) && v2.is_a?(Array)
|
@@ -160,7 +164,7 @@ module Inspec::Resources
|
|
160
164
|
|
161
165
|
filter = FilterTable.create
|
162
166
|
filter.register_column(:servers, field: "server")
|
163
|
-
|
167
|
+
.install_filter_methods_on_resource(self, :server_table)
|
164
168
|
|
165
169
|
def locations
|
166
170
|
servers.map(&:locations).flatten
|
@@ -187,7 +191,7 @@ module Inspec::Resources
|
|
187
191
|
|
188
192
|
filter = FilterTable.create
|
189
193
|
filter.register_column(:locations, field: "location")
|
190
|
-
|
194
|
+
.install_filter_methods_on_resource(self, :location_table)
|
191
195
|
|
192
196
|
def to_s
|
193
197
|
server = ""
|
@@ -23,7 +23,7 @@ module Inspec::Resources
|
|
23
23
|
@package_name = package_name
|
24
24
|
|
25
25
|
# verify that this resource is only supported on Windows
|
26
|
-
return skip_resource "The `oneget` resource is not supported on your OS."
|
26
|
+
return skip_resource "The `oneget` resource is not supported on your OS." unless inspec.os.windows?
|
27
27
|
end
|
28
28
|
|
29
29
|
def info
|
@@ -36,6 +36,7 @@ module Inspec::Resources
|
|
36
36
|
|
37
37
|
# connection as sysdba stuff
|
38
38
|
return skip_resource "Option 'as_os_user' not available in Windows" if inspec.os.windows? && opts[:as_os_user]
|
39
|
+
|
39
40
|
@su_user = opts[:as_os_user]
|
40
41
|
@db_role = opts[:as_db_role]
|
41
42
|
|
@@ -93,7 +94,7 @@ module Inspec::Resources
|
|
93
94
|
|
94
95
|
def verify_query(query)
|
95
96
|
# ensure we have a ; at the end
|
96
|
-
query + ";"
|
97
|
+
query + ";" unless query.strip.end_with?(";")
|
97
98
|
query
|
98
99
|
end
|
99
100
|
|
@@ -121,7 +122,7 @@ module Inspec::Resources
|
|
121
122
|
doc = REXML::Document.new result
|
122
123
|
table = doc.elements["table"]
|
123
124
|
hash = []
|
124
|
-
|
125
|
+
unless table.nil?
|
125
126
|
rows = table.elements.to_a
|
126
127
|
headers = rows[0].elements.to_a("th").map { |entry| entry.text.strip }
|
127
128
|
rows.delete_at(0)
|
@@ -134,6 +135,7 @@ module Inspec::Resources
|
|
134
135
|
entries = row.elements.to_a("td")
|
135
136
|
# ignore if we have empty entries, oracle is adding th rows in between
|
136
137
|
return nil if entries.empty?
|
138
|
+
|
137
139
|
headers.each_with_index do |header, index|
|
138
140
|
# we need htmlentities since we do not have nokogiri
|
139
141
|
coder = HTMLEntities.new
|
@@ -65,11 +65,12 @@ module Inspec::Resources
|
|
65
65
|
|
66
66
|
# returns the package description
|
67
67
|
def info
|
68
|
-
return @cache
|
68
|
+
return @cache unless @cache.nil?
|
69
69
|
# All `@pkgman.info` methods return `{}`. This matches that
|
70
70
|
# behavior if `@pkgman` can't be determined, thus avoiding the
|
71
71
|
# `undefined method 'info' for nil:NilClass` error
|
72
72
|
return {} if @pkgman.nil?
|
73
|
+
|
73
74
|
@pkgman.info(@package_name)
|
74
75
|
end
|
75
76
|
|
@@ -88,6 +89,7 @@ module Inspec::Resources
|
|
88
89
|
def evaluate_missing_requirements
|
89
90
|
missing_requirements_string = @pkgman.missing_requirements.uniq.join(", ")
|
90
91
|
return if missing_requirements_string.empty?
|
92
|
+
|
91
93
|
raise Inspec::Exceptions::ResourceSkipped, "The following requirements are not met for this resource: #{missing_requirements_string}"
|
92
94
|
end
|
93
95
|
end
|
@@ -154,6 +156,7 @@ module Inspec::Resources
|
|
154
156
|
# CentOS does not return an error code if the package is not installed,
|
155
157
|
# therefore we need to check for emptyness
|
156
158
|
return {} if cmd.exit_status.to_i != 0 || cmd.stdout.chomp.empty?
|
159
|
+
|
157
160
|
params = SimpleConfig.new(
|
158
161
|
cmd.stdout.chomp,
|
159
162
|
assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
|
@@ -214,8 +217,8 @@ module Inspec::Resources
|
|
214
217
|
}
|
215
218
|
rescue JSON::ParserError => e
|
216
219
|
raise Inspec::Exceptions::ResourceFailed,
|
217
|
-
|
218
|
-
|
220
|
+
"Failed to parse JSON from `brew` command. " \
|
221
|
+
"Error: #{e}"
|
219
222
|
end
|
220
223
|
end
|
221
224
|
|
@@ -244,6 +247,7 @@ module Inspec::Resources
|
|
244
247
|
def info(package_name)
|
245
248
|
cmd = inspec.command("swlist -l product | grep #{package_name}")
|
246
249
|
return {} if cmd.exit_status.to_i != 0
|
250
|
+
|
247
251
|
pkg = cmd.stdout.strip.split(" ")
|
248
252
|
{
|
249
253
|
name: pkg[0],
|
@@ -303,8 +307,8 @@ module Inspec::Resources
|
|
303
307
|
package = JSON.parse(cmd.stdout)
|
304
308
|
rescue JSON::ParserError => e
|
305
309
|
raise Inspec::Exceptions::ResourceFailed,
|
306
|
-
|
307
|
-
|
310
|
+
"Failed to parse JSON from PowerShell. " \
|
311
|
+
"Error: #{e}"
|
308
312
|
end
|
309
313
|
|
310
314
|
# What if we match multiple packages? just pick the first one for now.
|
@@ -381,7 +385,7 @@ module Inspec::Resources
|
|
381
385
|
name: params["Name"],
|
382
386
|
installed: true,
|
383
387
|
# 0.5.11-0.175.3.1.0.5.0
|
384
|
-
version: "#{params[
|
388
|
+
version: "#{params["Version"]}-#{params["Branch"]}",
|
385
389
|
type: "pkg",
|
386
390
|
}
|
387
391
|
end
|
@@ -42,11 +42,11 @@ module Inspec::Resources
|
|
42
42
|
end
|
43
43
|
|
44
44
|
filter = FilterTable.create
|
45
|
-
filter.register_column(:statuses,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
filter.register_column(:statuses, field: "status", style: :simple)
|
46
|
+
.register_column(:names, field: "name")
|
47
|
+
.register_column(:versions, field: "version")
|
48
|
+
.register_column(:architectures, field: "architecture")
|
49
|
+
.install_filter_methods_on_resource(self, :filtered_packages)
|
50
50
|
|
51
51
|
private
|
52
52
|
|
@@ -82,6 +82,7 @@ module Inspec::Resources
|
|
82
82
|
cmd = inspec.command(command)
|
83
83
|
all = cmd.stdout.split("\n")
|
84
84
|
return [] if all.nil?
|
85
|
+
|
85
86
|
all.map do |m|
|
86
87
|
a = m.split(/ {2,}/)
|
87
88
|
a[0] = "installed" if a[0] =~ /^.i/
|
@@ -99,6 +100,7 @@ module Inspec::Resources
|
|
99
100
|
cmd = inspec.command(command)
|
100
101
|
all = cmd.stdout.split("\n")
|
101
102
|
return [] if all.nil?
|
103
|
+
|
102
104
|
all.map do |m|
|
103
105
|
a = m.split(" ")
|
104
106
|
a.unshift("installed")
|