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
@@ -16,7 +16,8 @@ module Inspec::Resources
|
|
16
16
|
EXAMPLE
|
17
17
|
|
18
18
|
def initialize(zfs_dataset)
|
19
|
-
return skip_resource "The `zfs_dataset` resource is not supported on your OS yet."
|
19
|
+
return skip_resource "The `zfs_dataset` resource is not supported on your OS yet." unless inspec.os.bsd?
|
20
|
+
|
20
21
|
@zfs_dataset = zfs_dataset
|
21
22
|
|
22
23
|
@params = gather
|
@@ -28,7 +29,8 @@ module Inspec::Resources
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def mounted?
|
31
|
-
return false
|
32
|
+
return false unless exists?
|
33
|
+
|
32
34
|
inspec.mount(@params["mountpoint"]).mounted?
|
33
35
|
end
|
34
36
|
|
@@ -15,7 +15,8 @@ module Inspec::Resources
|
|
15
15
|
EXAMPLE
|
16
16
|
|
17
17
|
def initialize(zfs_pool)
|
18
|
-
return skip_resource "The `zfs_pool` resource is not supported on your OS yet."
|
18
|
+
return skip_resource "The `zfs_pool` resource is not supported on your OS yet." unless inspec.os.bsd?
|
19
|
+
|
19
20
|
@zfs_pool = zfs_pool
|
20
21
|
|
21
22
|
@params = gather
|
data/lib/inspec/rule.rb
CHANGED
@@ -49,6 +49,7 @@ module Inspec
|
|
49
49
|
|
50
50
|
# evaluate the given definition
|
51
51
|
return unless block_given?
|
52
|
+
|
52
53
|
begin
|
53
54
|
instance_eval(&block)
|
54
55
|
rescue StandardError => e
|
@@ -91,6 +92,7 @@ module Inspec
|
|
91
92
|
|
92
93
|
def desc(v = nil, data = nil)
|
93
94
|
return @descriptions[:default] if v.nil?
|
95
|
+
|
94
96
|
if data.nil?
|
95
97
|
@descriptions[:default] = unindent(v)
|
96
98
|
else
|
@@ -100,11 +102,13 @@ module Inspec
|
|
100
102
|
|
101
103
|
def descriptions(description_hash = nil)
|
102
104
|
return @descriptions if description_hash.nil?
|
105
|
+
|
103
106
|
@descriptions.merge!(description_hash)
|
104
107
|
end
|
105
108
|
|
106
109
|
def ref(ref = nil, opts = {})
|
107
110
|
return @refs if ref.nil? && opts.empty?
|
111
|
+
|
108
112
|
if opts.empty? && ref.is_a?(Hash)
|
109
113
|
opts = ref
|
110
114
|
else
|
@@ -191,7 +195,7 @@ module Inspec
|
|
191
195
|
|
192
196
|
def self.set_skip_rule(rule, value, message = nil)
|
193
197
|
rule.instance_variable_set(:@__skip_rule,
|
194
|
-
|
198
|
+
{ result: value, message: message })
|
195
199
|
end
|
196
200
|
|
197
201
|
def self.merge_count(rule)
|
@@ -205,6 +209,7 @@ module Inspec
|
|
205
209
|
def self.prepare_checks(rule)
|
206
210
|
skip_check = skip_status(rule)
|
207
211
|
return checks(rule) unless skip_check[:result].eql?(true)
|
212
|
+
|
208
213
|
if skip_check[:message]
|
209
214
|
msg = "Skipped control due to only_if condition: #{skip_check[:message]}"
|
210
215
|
else
|
@@ -223,12 +228,14 @@ module Inspec
|
|
223
228
|
# TODO: register an error, this case should not happen
|
224
229
|
return
|
225
230
|
end
|
231
|
+
|
226
232
|
sp = rule_id(src)
|
227
233
|
dp = rule_id(dst)
|
228
234
|
if sp != dp
|
229
235
|
# TODO: register an error, this case should not happen
|
230
236
|
return
|
231
237
|
end
|
238
|
+
|
232
239
|
# merge all fields
|
233
240
|
dst.impact(src.impact) unless src.impact.nil?
|
234
241
|
dst.title(src.title) unless src.title.nil?
|
@@ -274,6 +281,7 @@ module Inspec
|
|
274
281
|
#
|
275
282
|
def with_dsl(block)
|
276
283
|
return nil if block.nil?
|
284
|
+
|
277
285
|
if self.class.resource_dsl
|
278
286
|
dsl = self.class.resource_dsl
|
279
287
|
proc do |*args|
|
@@ -299,6 +307,7 @@ module Inspec
|
|
299
307
|
# @return [String] input with indentation removed; '' if input is nil
|
300
308
|
def unindent(text)
|
301
309
|
return "" if text.nil?
|
310
|
+
|
302
311
|
len = text.split("\n").reject { |l| l.strip.empty? }.map { |x| x.index(/[^\s]/) }.compact.min
|
303
312
|
text.gsub(/^[[:blank:]]{#{len}}/, "").strip
|
304
313
|
end
|
@@ -306,6 +315,7 @@ module Inspec
|
|
306
315
|
# get the source location of the block
|
307
316
|
def __get_block_source_location(&block)
|
308
317
|
return {} unless block_given?
|
318
|
+
|
309
319
|
r, l = block.source_location
|
310
320
|
{ ref: r, line: l }
|
311
321
|
rescue MethodSource::SourceNotFoundError
|
data/lib/inspec/runner.rb
CHANGED
@@ -136,7 +136,7 @@ module Inspec
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def write_lockfile(profile)
|
139
|
-
return false
|
139
|
+
return false unless profile.writable?
|
140
140
|
|
141
141
|
if profile.lockfile_exists?
|
142
142
|
Inspec::Log.debug "Using existing lockfile #{profile.lockfile_path}"
|
@@ -182,16 +182,17 @@ module Inspec
|
|
182
182
|
#
|
183
183
|
def add_target(target, _opts = [])
|
184
184
|
profile = Inspec::Profile.for_target(target,
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
185
|
+
vendor_cache: @cache,
|
186
|
+
backend: @backend,
|
187
|
+
controls: @controls,
|
188
|
+
runner_conf: @conf)
|
189
189
|
raise "Could not resolve #{target} to valid input." if profile.nil?
|
190
|
+
|
190
191
|
@target_profiles << profile if supports_profile?(profile)
|
191
192
|
end
|
192
193
|
|
193
194
|
def supports_profile?(profile)
|
194
|
-
|
195
|
+
unless profile.supports_runtime?
|
195
196
|
raise "This profile requires #{Inspec::Dist::PRODUCT_NAME} version "\
|
196
197
|
"#{profile.metadata.inspec_requirement}. You are running "\
|
197
198
|
"#{Inspec::Dist::PRODUCT_NAME} v#{Inspec::VERSION}.\n"
|
@@ -211,6 +212,7 @@ module Inspec
|
|
211
212
|
new_tests = false
|
212
213
|
ctx.rules.each do |rule_id, rule|
|
213
214
|
next if block_given? && !(yield rule_id, rule)
|
215
|
+
|
214
216
|
new_tests = true
|
215
217
|
register_rule(rule)
|
216
218
|
end
|
@@ -238,6 +240,7 @@ module Inspec
|
|
238
240
|
|
239
241
|
def block_source_info(block)
|
240
242
|
return {} if block.nil? || !block.respond_to?(:source_location)
|
243
|
+
|
241
244
|
opts = {}
|
242
245
|
file_path, line = block.source_location
|
243
246
|
opts["file_path"] = file_path
|
data/lib/inspec/runner_rspec.rb
CHANGED
@@ -31,10 +31,10 @@ module Inspec
|
|
31
31
|
# @return [nil]
|
32
32
|
def add_profile(profile)
|
33
33
|
RSpec.configuration.formatters
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
.find_all { |c| c.is_a?(Inspec::Formatters::Base) }
|
35
|
+
.each do |fmt|
|
36
|
+
fmt.add_profile(profile)
|
37
|
+
end
|
38
38
|
end
|
39
39
|
|
40
40
|
# Configure the backend of the runner.
|
@@ -43,10 +43,10 @@ module Inspec
|
|
43
43
|
# @return [nil]
|
44
44
|
def backend=(backend)
|
45
45
|
RSpec.configuration.formatters
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
.find_all { |c| c.is_a?(Inspec::Formatters::Base) }
|
47
|
+
.each do |fmt|
|
48
|
+
fmt.backend = backend
|
49
|
+
end
|
50
50
|
end
|
51
51
|
|
52
52
|
# Add an example group to the list of registered tests.
|
@@ -81,6 +81,7 @@ module Inspec
|
|
81
81
|
# @return [int] exit code
|
82
82
|
def exit_code
|
83
83
|
return @rspec_exit_code if @formatter.results.empty?
|
84
|
+
|
84
85
|
stats = @formatter.results[:statistics][:controls]
|
85
86
|
skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) == "skipped"
|
86
87
|
if stats[:failed][:total] == 0 && stats[:skipped][:total] == 0 && !skipped
|
@@ -111,6 +112,7 @@ module Inspec
|
|
111
112
|
#
|
112
113
|
def set_optional_formatters
|
113
114
|
return if @conf["reporter"].nil?
|
115
|
+
|
114
116
|
if @conf["reporter"].key?("json-rspec")
|
115
117
|
# We cannot pass in a nil output path. Rspec only accepts a valid string or a IO object.
|
116
118
|
if @conf["reporter"]["json-rspec"]&.[]("file").nil?
|
data/lib/inspec/schema.rb
CHANGED
data/lib/inspec/secrets.rb
CHANGED
data/lib/inspec/secrets/yaml.rb
CHANGED
data/lib/inspec/shell.rb
CHANGED
@@ -24,7 +24,7 @@ module Inspec
|
|
24
24
|
# Delete any before_session, before_eval, and after_eval hooks so we can
|
25
25
|
# replace them with our own. Pry 0.10 used to have a single method to clear
|
26
26
|
# all hooks, but this was removed in Pry 0.11.
|
27
|
-
|
27
|
+
%i{before_session before_eval after_eval}.each do |event|
|
28
28
|
Pry.hooks.get_hooks(event).keys.map { |hook| Pry.hooks.delete_hook(event, hook) }
|
29
29
|
end
|
30
30
|
|
@@ -54,13 +54,14 @@ module Inspec
|
|
54
54
|
# test file, register all the rules it discovered.
|
55
55
|
Pry.hooks.add_hook(:after_eval, "inspec_after_eval") do
|
56
56
|
@runner.load
|
57
|
-
@runner.run_tests
|
57
|
+
@runner.run_tests unless @runner.all_rules.empty?
|
58
58
|
end
|
59
59
|
|
60
60
|
# Don't print out control class inspection when the user uses DSL methods.
|
61
61
|
# Instead produce a result of evaluating their control.
|
62
62
|
Pry.config.print = proc do |_output_, value, pry|
|
63
|
-
next
|
63
|
+
next unless @runner.all_rules.empty?
|
64
|
+
|
64
65
|
pry.pager.open do |pager|
|
65
66
|
pager.print pry.config.output_prefix
|
66
67
|
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
|
@@ -78,7 +79,7 @@ module Inspec
|
|
78
79
|
|
79
80
|
def intro
|
80
81
|
puts "Welcome to the interactive InSpec Shell"
|
81
|
-
puts "To find out how to use it, type: #{mark
|
82
|
+
puts "To find out how to use it, type: #{mark "help"}"
|
82
83
|
puts
|
83
84
|
end
|
84
85
|
|
@@ -118,18 +119,18 @@ module Inspec
|
|
118
119
|
print_matchers_help
|
119
120
|
elsif !Inspec::Resource.registry[topic].nil? # TODO: fix unnecessary logic
|
120
121
|
topic_info = Inspec::Resource.registry[topic]
|
121
|
-
info = "#{mark
|
122
|
+
info = "#{mark "Name:"} #{topic}\n\n"
|
122
123
|
unless topic_info.desc.nil?
|
123
|
-
info += "#{mark
|
124
|
+
info += "#{mark "Description:"}\n\n"
|
124
125
|
info += "#{topic_info.desc}\n\n"
|
125
126
|
end
|
126
127
|
|
127
128
|
unless topic_info.example.nil?
|
128
|
-
info += "#{mark
|
129
|
+
info += "#{mark "Example:"}\n\n"
|
129
130
|
info += "#{topic_info.example}\n\n"
|
130
131
|
end
|
131
132
|
|
132
|
-
info += "#{mark
|
133
|
+
info += "#{mark "Web Reference:"}\n\n"
|
133
134
|
info += "https://www.inspec.io/docs/reference/resources/#{topic}\n\n"
|
134
135
|
puts info
|
135
136
|
else
|
@@ -147,15 +148,15 @@ module Inspec
|
|
147
148
|
resources implement their own custom matchers, the following matchers are
|
148
149
|
common amongst all resources:
|
149
150
|
|
150
|
-
#{mark
|
151
|
+
#{mark "be"}
|
151
152
|
|
152
|
-
The #{mark
|
153
|
+
The #{mark "be"} matcher can be used to compare numeric values.
|
153
154
|
|
154
155
|
its('size') { should be >= 10 }
|
155
156
|
|
156
|
-
#{mark
|
157
|
+
#{mark "cmp"}
|
157
158
|
|
158
|
-
The #{mark
|
159
|
+
The #{mark "cmp"} matcher is like #{mark "eq"} but less restrictive. It will try
|
159
160
|
to fit the resource value to the expectation.
|
160
161
|
|
161
162
|
"Protocol" likely returns a string, but cmp will ensure it's a number before
|
@@ -174,23 +175,23 @@ module Inspec
|
|
174
175
|
its('log_format') { should cmp 'raw' }
|
175
176
|
its('log_format') { should cmp 'RAW' }
|
176
177
|
|
177
|
-
#{mark
|
178
|
+
#{mark "eq"}
|
178
179
|
|
179
|
-
The #{mark
|
180
|
+
The #{mark "eq"} matcher tests for exact equality of two values. Value type
|
180
181
|
(string, number, etc.) is important and must be the same. For a less-restrictive
|
181
|
-
comparison matcher, use the #{mark
|
182
|
+
comparison matcher, use the #{mark "cmp"} matcher.
|
182
183
|
|
183
184
|
its('RSAAuthentication') { should_not eq 'no' }
|
184
185
|
|
185
|
-
#{mark
|
186
|
+
#{mark "include"}
|
186
187
|
|
187
|
-
The #{mark
|
188
|
+
The #{mark "include"} matcher tests to see if a value is included in a list.
|
188
189
|
|
189
190
|
its('users') { should include 'my_user' }
|
190
191
|
|
191
|
-
#{mark
|
192
|
+
#{mark "match"}
|
192
193
|
|
193
|
-
The #{mark
|
194
|
+
The #{mark "match"} matcher can be used to test a string for a match using a
|
194
195
|
regular expression.
|
195
196
|
|
196
197
|
its('content') { should_not match /^MyKey:\\s+some value/ }
|
data/lib/inspec/source_reader.rb
CHANGED
@@ -6,6 +6,7 @@ module Inspec
|
|
6
6
|
class SourceReaderRegistry < PluginRegistry
|
7
7
|
def resolve(target)
|
8
8
|
return nil if target.nil?
|
9
|
+
|
9
10
|
super(target)
|
10
11
|
end
|
11
12
|
end
|
@@ -16,6 +17,7 @@ module Inspec
|
|
16
17
|
if version != 1
|
17
18
|
raise "Only source readers version 1 is supported!"
|
18
19
|
end
|
20
|
+
|
19
21
|
Inspec::Plugins::SourceReader
|
20
22
|
end
|
21
23
|
end
|
data/lib/inspec/ui.rb
CHANGED
@@ -41,6 +41,7 @@ module Inspec
|
|
41
41
|
unless File.exist?(default_path)
|
42
42
|
raise Inspec::Deprecation::MalformedConfigError, "Missing deprecation config file: #{default_path}"
|
43
43
|
end
|
44
|
+
|
44
45
|
File.open(default_path)
|
45
46
|
end
|
46
47
|
|
@@ -57,6 +58,7 @@ module Inspec
|
|
57
58
|
unless @raw_data["groups"].is_a?(Hash)
|
58
59
|
raise Inspec::Deprecation::InvalidConfigFileError, "Groups field must be a Hash"
|
59
60
|
end
|
61
|
+
|
60
62
|
@raw_data["groups"].each do |group_name, group_info|
|
61
63
|
validate_group_entry(group_name, group_info)
|
62
64
|
end
|
@@ -67,22 +69,23 @@ module Inspec
|
|
67
69
|
raise Inspec::Deprecation::InvalidConfigFileError, "Missing file_version field"
|
68
70
|
end
|
69
71
|
unless @raw_data["file_version"] == "1.0.0"
|
70
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Unrecognized file_version '#{@raw_data[
|
72
|
+
raise Inspec::Deprecation::InvalidConfigFileError, "Unrecognized file_version '#{@raw_data["file_version"]}' - supported versions: 1.0.0"
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
74
76
|
def validate_unknown_group_action
|
75
77
|
seen_action = (@raw_data["unknown_group_action"] || @unknown_group_action).to_sym
|
76
78
|
unless VALID_ACTIONS.include?(seen_action)
|
77
|
-
raise Inspec::Deprecation::UnrecognizedActionError, "Unrecognized value '#{seen_action}' for field 'unknown_group_action' - supported actions: #{VALID_ACTIONS.map(&:to_s).join(
|
79
|
+
raise Inspec::Deprecation::UnrecognizedActionError, "Unrecognized value '#{seen_action}' for field 'unknown_group_action' - supported actions: #{VALID_ACTIONS.map(&:to_s).join(", ")}"
|
78
80
|
end
|
81
|
+
|
79
82
|
@unknown_group_action = seen_action
|
80
83
|
end
|
81
84
|
|
82
85
|
def validate_group_entry(name, opts)
|
83
86
|
opts.each do |seen_field, _value|
|
84
87
|
unless VALID_GROUP_FIELDS.include?(seen_field)
|
85
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Unrecognized field for group '#{name}' - saw '#{seen_field}', supported fields: #{VALID_GROUP_FIELDS.map(&:to_s).join(
|
88
|
+
raise Inspec::Deprecation::InvalidConfigFileError, "Unrecognized field for group '#{name}' - saw '#{seen_field}', supported fields: #{VALID_GROUP_FIELDS.map(&:to_s).join(", ")}"
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
@@ -90,8 +93,9 @@ module Inspec
|
|
90
93
|
|
91
94
|
opts["action"] = (opts["action"] || :warn).to_sym
|
92
95
|
unless VALID_ACTIONS.include?(opts["action"])
|
93
|
-
raise Inspec::Deprecation::UnrecognizedActionError, "Unrecognized action for group '#{name}' - saw '#{opts[
|
96
|
+
raise Inspec::Deprecation::UnrecognizedActionError, "Unrecognized action for group '#{name}' - saw '#{opts["action"]}', supported actions: #{VALID_ACTIONS.map(&:to_s).join(", ")}"
|
94
97
|
end
|
98
|
+
|
95
99
|
entry.action = opts["action"]
|
96
100
|
|
97
101
|
entry.suffix = opts["suffix"]
|
@@ -94,6 +94,7 @@ class ErlangBitstream
|
|
94
94
|
def bit_size(size, type)
|
95
95
|
raise "Cannot specify size and type at the same time." if !type.nil? && !size.nil?
|
96
96
|
return (size || 8).to_i if type.nil?
|
97
|
+
|
97
98
|
TYPES[type] || raise("Cannot handle binary-stream type #{type}")
|
98
99
|
end
|
99
100
|
|
@@ -101,6 +102,7 @@ class ErlangBitstream
|
|
101
102
|
if i[:integer].nil? && i[:string].nil?
|
102
103
|
raise "No data provided, internal error for binary-stream processing!"
|
103
104
|
end
|
105
|
+
|
104
106
|
s = bit_size(i[:size], i[:type])
|
105
107
|
unless i[:string].nil?
|
106
108
|
str2int(i[:string].to_s, i[:type]).map { |e| add_bits(int2bits(e, 8)) }
|