inspec-core 4.3.2 → 4.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -21
- data/etc/deprecations.json +10 -0
- data/etc/plugin_filters.json +8 -0
- data/lib/bundles/inspec-compliance/api.rb +1 -1
- data/lib/bundles/inspec-compliance/configuration.rb +1 -1
- data/lib/bundles/inspec-compliance/http.rb +1 -1
- data/lib/bundles/inspec-compliance/support.rb +1 -1
- data/lib/bundles/inspec-compliance/target.rb +1 -1
- data/lib/bundles/inspec-supermarket.rb +3 -7
- data/lib/bundles/inspec-supermarket/api.rb +10 -13
- data/lib/bundles/inspec-supermarket/cli.rb +12 -15
- data/lib/bundles/inspec-supermarket/target.rb +7 -11
- data/lib/fetchers/git.rb +14 -15
- data/lib/fetchers/local.rb +6 -10
- data/lib/fetchers/mock.rb +3 -5
- data/lib/fetchers/url.rb +42 -44
- data/lib/inspec.rb +23 -24
- data/lib/inspec/archive/tar.rb +2 -6
- data/lib/inspec/archive/zip.rb +3 -7
- data/lib/inspec/backend.rb +8 -9
- data/lib/inspec/base_cli.rb +64 -65
- data/lib/inspec/cached_fetcher.rb +2 -3
- data/lib/inspec/cli.rb +136 -97
- data/lib/inspec/config.rb +71 -61
- data/lib/inspec/control_eval_context.rb +22 -18
- data/lib/inspec/dependencies/cache.rb +2 -3
- data/lib/inspec/dependencies/dependency_set.rb +2 -3
- data/lib/inspec/dependencies/lockfile.rb +8 -9
- data/lib/inspec/dependencies/requirement.rb +7 -8
- data/lib/inspec/dependencies/resolver.rb +5 -7
- data/lib/inspec/describe.rb +2 -6
- data/lib/inspec/dist.rb +20 -0
- data/lib/inspec/dsl.rb +4 -7
- data/lib/inspec/dsl_shared.rb +1 -2
- data/lib/inspec/env_printer.rb +11 -12
- data/lib/inspec/errors.rb +0 -4
- data/lib/inspec/exceptions.rb +0 -1
- data/lib/inspec/expect.rb +5 -8
- data/lib/inspec/fetcher.rb +7 -10
- data/lib/inspec/file_provider.rb +24 -24
- data/lib/inspec/formatters.rb +3 -3
- data/lib/inspec/formatters/base.rb +8 -8
- data/lib/inspec/globals.rb +2 -2
- data/lib/inspec/impact.rb +5 -7
- data/lib/inspec/input_registry.rb +84 -33
- data/lib/inspec/library_eval_context.rb +3 -6
- data/lib/inspec/log.rb +1 -5
- data/lib/inspec/metadata.rb +17 -16
- data/lib/inspec/method_source.rb +5 -9
- data/lib/inspec/objects.rb +10 -12
- data/lib/inspec/objects/control.rb +7 -9
- data/lib/inspec/objects/describe.rb +9 -11
- data/lib/inspec/objects/each_loop.rb +1 -3
- data/lib/inspec/objects/input.rb +24 -26
- data/lib/inspec/objects/list.rb +4 -6
- data/lib/inspec/objects/or_test.rb +2 -4
- data/lib/inspec/objects/ruby_helper.rb +3 -5
- data/lib/inspec/objects/tag.rb +0 -2
- data/lib/inspec/objects/test.rb +9 -11
- data/lib/inspec/objects/value.rb +3 -5
- data/lib/inspec/plugin/v1.rb +2 -2
- data/lib/inspec/plugin/v1/plugin_types/cli.rb +1 -5
- data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +2 -5
- data/lib/inspec/plugin/v1/plugin_types/resource.rb +4 -6
- data/lib/inspec/plugin/v1/plugin_types/secret.rb +1 -5
- data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +1 -5
- data/lib/inspec/plugin/v1/plugins.rb +15 -19
- data/lib/inspec/plugin/v1/registry.rb +0 -4
- data/lib/inspec/plugin/v2.rb +8 -8
- data/lib/inspec/plugin/v2/activator.rb +1 -1
- data/lib/inspec/plugin/v2/config_file.rb +6 -6
- data/lib/inspec/plugin/v2/filter.rb +13 -13
- data/lib/inspec/plugin/v2/installer.rb +36 -24
- data/lib/inspec/plugin/v2/loader.rb +28 -28
- data/lib/inspec/plugin/v2/plugin_base.rb +15 -2
- data/lib/inspec/plugin/v2/plugin_types/cli.rb +5 -5
- data/lib/inspec/plugin/v2/plugin_types/input.rb +34 -0
- data/lib/inspec/plugin/v2/plugin_types/mock.rb +1 -1
- data/lib/inspec/plugin/v2/registry.rb +7 -7
- data/lib/inspec/polyfill.rb +0 -3
- data/lib/inspec/profile.rb +55 -63
- data/lib/inspec/profile_context.rb +27 -30
- data/lib/inspec/profile_vendor.rb +6 -9
- data/lib/inspec/reporters.rb +24 -24
- data/lib/inspec/reporters/automate.rb +17 -19
- data/lib/inspec/reporters/base.rb +1 -1
- data/lib/inspec/reporters/cli.rb +88 -91
- data/lib/inspec/reporters/json.rb +2 -4
- data/lib/inspec/reporters/json_automate.rb +1 -3
- data/lib/inspec/reporters/json_min.rb +1 -3
- data/lib/inspec/reporters/junit.rb +26 -28
- data/lib/inspec/reporters/yaml.rb +1 -3
- data/lib/inspec/require_loader.rb +0 -4
- data/lib/inspec/resource.rb +4 -125
- data/lib/inspec/resources.rb +121 -0
- data/lib/{resources → inspec/resources}/aide_conf.rb +24 -25
- data/lib/{resources → inspec/resources}/apache.rb +13 -14
- data/lib/{resources → inspec/resources}/apache_conf.rb +16 -17
- data/lib/{resources → inspec/resources}/apt.rb +17 -17
- data/lib/{resources → inspec/resources}/audit_policy.rb +7 -6
- data/lib/{resources → inspec/resources}/auditd.rb +62 -64
- data/lib/{resources → inspec/resources}/auditd_conf.rb +7 -8
- data/lib/{resources → inspec/resources}/bash.rb +6 -8
- data/lib/{resources → inspec/resources}/bond.rb +15 -14
- data/lib/{resources → inspec/resources}/bridge.rb +8 -8
- data/lib/{resources → inspec/resources}/chocolatey_package.rb +10 -8
- data/lib/{resources → inspec/resources}/command.rb +11 -10
- data/lib/{resources → inspec/resources}/cpan.rb +12 -12
- data/lib/{resources → inspec/resources}/cran.rb +9 -9
- data/lib/{resources → inspec/resources}/crontab.rb +47 -48
- data/lib/{resources → inspec/resources}/csv.rb +5 -5
- data/lib/{resources → inspec/resources}/dh_params.rb +5 -7
- data/lib/{resources → inspec/resources}/directory.rb +5 -7
- data/lib/{resources → inspec/resources}/docker.rb +63 -63
- data/lib/{resources → inspec/resources}/docker_container.rb +6 -6
- data/lib/{resources → inspec/resources}/docker_image.rb +9 -9
- data/lib/{resources → inspec/resources}/docker_object.rb +8 -13
- data/lib/{resources → inspec/resources}/docker_plugin.rb +6 -6
- data/lib/{resources → inspec/resources}/docker_service.rb +7 -7
- data/lib/{resources → inspec/resources}/elasticsearch.rb +40 -42
- data/lib/{resources → inspec/resources}/etc_fstab.rb +23 -24
- data/lib/{resources → inspec/resources}/etc_group.rb +26 -27
- data/lib/{resources → inspec/resources}/etc_hosts.rb +11 -13
- data/lib/{resources → inspec/resources}/etc_hosts_allow_deny.rb +25 -27
- data/lib/{resources → inspec/resources}/file.rb +80 -79
- data/lib/{resources → inspec/resources}/filesystem.rb +20 -15
- data/lib/{resources → inspec/resources}/firewalld.rb +26 -26
- data/lib/{resources → inspec/resources}/gem.rb +12 -12
- data/lib/{resources → inspec/resources}/groups.rb +28 -27
- data/lib/{resources → inspec/resources}/grub_conf.rb +46 -48
- data/lib/{resources → inspec/resources}/host.rb +31 -29
- data/lib/{resources → inspec/resources}/http.rb +24 -24
- data/lib/{resources → inspec/resources}/iis_app.rb +6 -7
- data/lib/{resources → inspec/resources}/iis_app_pool.rb +21 -19
- data/lib/{resources → inspec/resources}/iis_site.rb +17 -15
- data/lib/{resources → inspec/resources}/inetd_conf.rb +9 -10
- data/lib/{resources → inspec/resources}/ini.rb +7 -8
- data/lib/{resources → inspec/resources}/interface.rb +30 -30
- data/lib/{resources → inspec/resources}/iptables.rb +8 -8
- data/lib/{resources → inspec/resources}/json.rb +8 -10
- data/lib/{resources → inspec/resources}/kernel_module.rb +15 -15
- data/lib/{resources → inspec/resources}/kernel_parameter.rb +8 -8
- data/lib/{resources → inspec/resources}/key_rsa.rb +8 -10
- data/lib/{resources → inspec/resources}/ksh.rb +6 -8
- data/lib/{resources → inspec/resources}/limits_conf.rb +8 -9
- data/lib/{resources/login_def.rb → inspec/resources/login_defs.rb} +9 -10
- data/lib/{resources → inspec/resources}/mount.rb +6 -8
- data/lib/{resources → inspec/resources}/mssql_session.rb +16 -18
- data/lib/inspec/resources/mysql.rb +81 -0
- data/lib/{resources → inspec/resources}/mysql_conf.rb +13 -14
- data/lib/{resources → inspec/resources}/mysql_session.rb +16 -16
- data/lib/{resources → inspec/resources}/nginx.rb +16 -17
- data/lib/{resources → inspec/resources}/nginx_conf.rb +26 -27
- data/lib/{resources → inspec/resources}/npm.rb +9 -10
- data/lib/{resources → inspec/resources}/ntp_conf.rb +9 -10
- data/lib/{resources → inspec/resources}/oneget.rb +8 -8
- data/lib/{resources → inspec/resources}/oracledb_session.rb +33 -34
- data/lib/{resources → inspec/resources}/os.rb +6 -8
- data/lib/{resources → inspec/resources}/os_env.rb +11 -12
- data/lib/{resources → inspec/resources}/package.rb +66 -65
- data/lib/{resources → inspec/resources}/packages.rb +13 -13
- data/lib/{resources → inspec/resources}/parse_config.rb +8 -8
- data/lib/{resources → inspec/resources}/passwd.rb +18 -19
- data/lib/{resources → inspec/resources}/pip.rb +19 -19
- data/lib/{resources → inspec/resources}/platform.rb +9 -11
- data/lib/{resources → inspec/resources}/port.rb +134 -136
- data/lib/{resources → inspec/resources}/postgres.rb +40 -32
- data/lib/{resources → inspec/resources}/postgres_conf.rb +17 -17
- data/lib/{resources → inspec/resources}/postgres_hba_conf.rb +21 -23
- data/lib/{resources → inspec/resources}/postgres_ident_conf.rb +12 -14
- data/lib/{resources → inspec/resources}/postgres_session.rb +8 -9
- data/lib/{resources → inspec/resources}/powershell.rb +17 -13
- data/lib/{resources → inspec/resources}/processes.rb +29 -29
- data/lib/{resources/rabbitmq_conf.rb → inspec/resources/rabbitmq_config.rb} +10 -11
- data/lib/{resources → inspec/resources}/registry_key.rb +14 -14
- data/lib/inspec/resources/script.rb +1 -0
- data/lib/{resources → inspec/resources}/security_identifier.rb +11 -10
- data/lib/{resources → inspec/resources}/security_policy.rb +59 -58
- data/lib/{resources → inspec/resources}/service.rb +74 -75
- data/lib/{resources → inspec/resources}/shadow.rb +44 -45
- data/lib/{resources/ssh_conf.rb → inspec/resources/ssh_config.rb} +16 -17
- data/lib/{resources → inspec/resources}/ssl.rb +28 -29
- data/lib/inspec/resources/sys_info.rb +30 -0
- data/lib/{resources → inspec/resources}/toml.rb +5 -7
- data/lib/{resources → inspec/resources}/users.rb +65 -65
- data/lib/{resources → inspec/resources}/vbscript.rb +8 -9
- data/lib/{resources → inspec/resources}/virtualization.rb +60 -62
- data/lib/{resources → inspec/resources}/windows_feature.rb +9 -9
- data/lib/{resources → inspec/resources}/windows_hotfix.rb +5 -5
- data/lib/{resources → inspec/resources}/windows_task.rb +16 -15
- data/lib/{resources → inspec/resources}/wmi.rb +7 -8
- data/lib/{resources → inspec/resources}/x509_certificate.rb +9 -11
- data/lib/{resources/xinetd.rb → inspec/resources/xinetd_conf.rb} +27 -29
- data/lib/{resources → inspec/resources}/xml.rb +7 -7
- data/lib/{resources → inspec/resources}/yaml.rb +5 -6
- data/lib/{resources → inspec/resources}/yum.rb +10 -10
- data/lib/{resources → inspec/resources}/zfs_dataset.rb +6 -6
- data/lib/{resources → inspec/resources}/zfs_pool.rb +4 -4
- data/lib/inspec/rspec_extensions.rb +24 -8
- data/lib/inspec/rule.rb +14 -15
- data/lib/inspec/runner.rb +28 -28
- data/lib/inspec/runner_mock.rb +1 -5
- data/lib/inspec/runner_rspec.rb +18 -20
- data/lib/inspec/runtime_profile.rb +2 -5
- data/lib/inspec/schema.rb +142 -143
- data/lib/inspec/secrets.rb +3 -7
- data/lib/inspec/secrets/yaml.rb +3 -5
- data/lib/inspec/shell.rb +11 -15
- data/lib/inspec/shell_detector.rb +6 -7
- data/lib/inspec/source_reader.rb +4 -8
- data/lib/inspec/ui.rb +33 -39
- data/lib/inspec/ui_table_helper.rb +12 -0
- data/lib/{utils → inspec/utils}/command_wrapper.rb +4 -8
- data/lib/{utils → inspec/utils}/convert.rb +0 -4
- data/lib/{utils → inspec/utils}/database_helpers.rb +4 -8
- data/lib/inspec/utils/deprecation.rb +6 -0
- data/lib/{utils → inspec/utils}/deprecation/config_file.rb +19 -19
- data/lib/{utils → inspec/utils}/deprecation/deprecator.rb +12 -12
- data/lib/{utils → inspec/utils}/deprecation/errors.rb +1 -1
- data/lib/{utils → inspec/utils}/deprecation/global_method.rb +2 -2
- data/lib/{utils → inspec/utils}/enumerable_delegation.rb +0 -2
- data/lib/{utils → inspec/utils}/erlang_parser.rb +61 -65
- data/lib/{utils → inspec/utils}/file_reader.rb +1 -2
- data/lib/{utils → inspec/utils}/filter.rb +30 -33
- data/lib/{utils → inspec/utils}/filter_array.rb +0 -2
- data/lib/{utils → inspec/utils}/find_files.rb +9 -12
- data/lib/{utils → inspec/utils}/hash.rb +1 -5
- data/lib/inspec/utils/json_log.rb +15 -0
- data/lib/inspec/utils/latest_version.rb +13 -0
- data/lib/{utils → inspec/utils}/modulator.rb +0 -3
- data/lib/{utils → inspec/utils}/nginx_parser.rb +31 -35
- data/lib/{utils → inspec/utils}/object_traversal.rb +0 -3
- data/lib/{utils → inspec/utils}/parser.rb +45 -45
- data/lib/{utils → inspec/utils}/pkey_reader.rb +4 -2
- data/lib/{utils → inspec/utils}/simpleconfig.rb +8 -10
- data/lib/{utils → inspec/utils}/spdx.rb +1 -4
- data/lib/{utils → inspec/utils}/spdx.txt +0 -0
- data/lib/inspec/utils/telemetry.rb +3 -3
- data/lib/inspec/utils/telemetry/collector.rb +30 -9
- data/lib/inspec/utils/telemetry/data_series.rb +3 -1
- data/lib/inspec/utils/telemetry/global_methods.rb +1 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +22 -25
- data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +1 -1
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +52 -45
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +18 -16
- data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +1 -1
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +73 -73
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +66 -62
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +59 -57
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +11 -11
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +20 -22
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +2 -4
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +30 -27
- data/lib/plugins/inspec-habitat/Berksfile +2 -2
- data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +1 -1
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +15 -13
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +64 -63
- data/lib/plugins/inspec-habitat/templates/habitat/hooks/run.erb +3 -3
- data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +11 -11
- data/lib/plugins/inspec-init/lib/inspec-init.rb +1 -1
- data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +6 -8
- data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +72 -74
- data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +9 -11
- data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +4 -4
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -1
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/inspec-plugin-template.gemspec +0 -2
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -2
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -2
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -2
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -2
- data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +6 -7
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +1 -2
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +72 -70
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +1 -1
- data/lib/plugins/shared/core_plugin_test_helper.rb +43 -38
- data/lib/source_readers/flat.rb +6 -10
- data/lib/source_readers/inspec.rb +8 -12
- metadata +139 -140
- data/lib/resources/mysql.rb +0 -82
- data/lib/resources/sys_info.rb +0 -28
- data/lib/utils/deprecation.rb +0 -6
- data/lib/utils/json_log.rb +0 -18
- data/lib/utils/latest_version.rb +0 -22
data/lib/inspec/runner_mock.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
1
|
module Inspec
|
6
2
|
class RunnerMock
|
7
3
|
attr_reader :tests, :profiles
|
@@ -35,7 +31,7 @@ module Inspec
|
|
35
31
|
end
|
36
32
|
|
37
33
|
def run(_with = nil)
|
38
|
-
puts
|
34
|
+
puts "uhm.... nothing or something... dunno, ask your admin"
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
data/lib/inspec/runner_rspec.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require
|
6
|
-
require 'rspec/its'
|
7
|
-
require 'inspec/formatters'
|
1
|
+
require "rspec/core"
|
2
|
+
require "rspec/its"
|
3
|
+
require "inspec/formatters"
|
4
|
+
require "matchers/matchers"
|
5
|
+
require "inspec/rspec_extensions"
|
8
6
|
|
9
7
|
# There be dragons!! Or borgs, or something...
|
10
8
|
# This file and all its contents cannot be unit-tested. both test-suits
|
@@ -84,13 +82,13 @@ module Inspec
|
|
84
82
|
def exit_code
|
85
83
|
return @rspec_exit_code if @formatter.results.empty?
|
86
84
|
stats = @formatter.results[:statistics][:controls]
|
87
|
-
skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) ==
|
85
|
+
skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) == "skipped"
|
88
86
|
if stats[:failed][:total] == 0 && stats[:skipped][:total] == 0 && !skipped
|
89
87
|
0
|
90
88
|
elsif stats[:failed][:total] > 0
|
91
|
-
@conf[
|
89
|
+
@conf["distinct_exit"] ? 100 : 1
|
92
90
|
elsif stats[:skipped][:total] > 0 || skipped
|
93
|
-
@conf[
|
91
|
+
@conf["distinct_exit"] ? 101 : 0
|
94
92
|
else
|
95
93
|
@rspec_exit_code
|
96
94
|
end
|
@@ -112,26 +110,26 @@ module Inspec
|
|
112
110
|
#
|
113
111
|
#
|
114
112
|
def set_optional_formatters
|
115
|
-
return if @conf[
|
116
|
-
if @conf[
|
113
|
+
return if @conf["reporter"].nil?
|
114
|
+
if @conf["reporter"].key?("json-rspec")
|
117
115
|
# We cannot pass in a nil output path. Rspec only accepts a valid string or a IO object.
|
118
|
-
if @conf[
|
116
|
+
if @conf["reporter"]["json-rspec"]&.[]("file").nil?
|
119
117
|
RSpec.configuration.add_formatter(Inspec::Formatters::RspecJson)
|
120
118
|
else
|
121
|
-
RSpec.configuration.add_formatter(Inspec::Formatters::RspecJson, @conf[
|
119
|
+
RSpec.configuration.add_formatter(Inspec::Formatters::RspecJson, @conf["reporter"]["json-rspec"]["file"])
|
122
120
|
end
|
123
|
-
@conf[
|
121
|
+
@conf["reporter"].delete("json-rspec")
|
124
122
|
end
|
125
123
|
|
126
|
-
formats = @conf[
|
124
|
+
formats = @conf["reporter"].select { |k, _v| %w{documentation progress html}.include?(k) }
|
127
125
|
formats.each do |k, v|
|
128
126
|
# We cannot pass in a nil output path. Rspec only accepts a valid string or a IO object.
|
129
|
-
if v&.[](
|
127
|
+
if v&.[]("file").nil?
|
130
128
|
RSpec.configuration.add_formatter(k.to_sym)
|
131
129
|
else
|
132
|
-
RSpec.configuration.add_formatter(k.to_sym, v[
|
130
|
+
RSpec.configuration.add_formatter(k.to_sym, v["file"])
|
133
131
|
end
|
134
|
-
@conf[
|
132
|
+
@conf["reporter"].delete(k)
|
135
133
|
end
|
136
134
|
end
|
137
135
|
|
@@ -143,7 +141,7 @@ module Inspec
|
|
143
141
|
@formatter = RSpec.configuration.add_formatter(Inspec::Formatters::Base)
|
144
142
|
RSpec.configuration.add_formatter(Inspec::Formatters::ShowProgress, $stderr) if @conf[:show_progress]
|
145
143
|
set_optional_formatters
|
146
|
-
RSpec.configuration.color = @conf[
|
144
|
+
RSpec.configuration.color = @conf["color"]
|
147
145
|
end
|
148
146
|
|
149
147
|
# Make sure that all RSpec example groups use the provided ID.
|
@@ -1,7 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# Copyright 2017 Chef Software
|
3
|
-
# author: Dominik Richter
|
4
|
-
# author: Christoph Hartmann
|
5
2
|
|
6
3
|
module Inspec
|
7
4
|
class RuntimeProfile
|
@@ -10,7 +7,7 @@ module Inspec
|
|
10
7
|
def initialize(profile)
|
11
8
|
@src = profile.source_reader
|
12
9
|
@files = @src.data_files.keys.map do |k|
|
13
|
-
k.sub(
|
10
|
+
k.sub("files" + File::SEPARATOR, "")
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
@@ -19,7 +16,7 @@ module Inspec
|
|
19
16
|
# @param name [String] the name of the file
|
20
17
|
# @return [String] contents of the file of RuntimeError if missing
|
21
18
|
def file(name)
|
22
|
-
@src.data_files[File.join(
|
19
|
+
@src.data_files[File.join("files", name)] ||
|
23
20
|
raise("Cannot find file #{name} in profile.")
|
24
21
|
end
|
25
22
|
end
|
data/lib/inspec/schema.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
|
-
|
2
|
-
require 'json'
|
1
|
+
require "json"
|
3
2
|
|
4
3
|
module Inspec
|
5
4
|
class Schema
|
6
5
|
STATISTICS = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
"type" => "object",
|
7
|
+
"additionalProperties" => false,
|
8
|
+
"properties" => {
|
9
|
+
"duration" => { "type" => "number" },
|
10
|
+
"controls" => {
|
11
|
+
"type" => "object",
|
12
|
+
"optional" => true,
|
13
|
+
"properties" => {
|
14
|
+
"total" => { "type" => "number" },
|
15
|
+
"passed" => {
|
16
|
+
"type" => "object",
|
17
|
+
"properties" => {
|
18
|
+
"total" => { "type" => "number" },
|
20
19
|
},
|
21
20
|
},
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
"skipped" => {
|
22
|
+
"type" => "object",
|
23
|
+
"properties" => {
|
24
|
+
"total" => { "type" => "number" },
|
26
25
|
},
|
27
26
|
},
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
"failed" => {
|
28
|
+
"type" => "object",
|
29
|
+
"properties" => {
|
30
|
+
"total" => { "type" => "number" },
|
32
31
|
},
|
33
32
|
},
|
34
33
|
},
|
@@ -37,184 +36,184 @@ module Inspec
|
|
37
36
|
}.freeze
|
38
37
|
|
39
38
|
PLATFORM = {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
"type" => "object",
|
40
|
+
"additionalProperties" => false,
|
41
|
+
"properties" => {
|
42
|
+
"name" => { "type" => "string" },
|
43
|
+
"release" => { "type" => "string" },
|
44
|
+
"target_id" => { "type" => "string", "optional" => true },
|
46
45
|
},
|
47
46
|
}.freeze
|
48
47
|
|
49
48
|
# Tags are open right, with simple key-value associations and not restrictions
|
50
|
-
TAGS = {
|
49
|
+
TAGS = { "type" => "object" }.freeze
|
51
50
|
|
52
51
|
RESULT = {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
"type" => "object",
|
53
|
+
"additionalProperties" => false,
|
54
|
+
"properties" => {
|
55
|
+
"status" => { "type" => "string" },
|
56
|
+
"code_desc" => { "type" => "string" },
|
57
|
+
"run_time" => { "type" => "number" },
|
58
|
+
"start_time" => { "type" => "string" },
|
59
|
+
"skip_message" => { "type" => "string", "optional" => true },
|
60
|
+
"resource" => { "type" => "string", "optional" => true },
|
61
|
+
"message" => { "type" => "string", "optional" => true },
|
62
|
+
"exception" => { "type" => "string", "optional" => true },
|
63
|
+
"backtrace" => { "type" => "object", "optional" => true },
|
65
64
|
},
|
66
65
|
}.freeze
|
67
66
|
|
68
67
|
REF = {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
"type" => "object",
|
69
|
+
"additionalProperties" => false,
|
70
|
+
"properties" => {
|
71
|
+
"ref" => { "type" => "string" },
|
73
72
|
# TODO: One of these needs to be deprecated
|
74
|
-
|
75
|
-
|
73
|
+
"uri" => { "type" => "string", "optional" => true },
|
74
|
+
"url" => { "type" => "string", "optional" => true },
|
76
75
|
},
|
77
76
|
}.freeze
|
78
|
-
REFS = {
|
77
|
+
REFS = { "type" => "array", "items" => REF }.freeze
|
79
78
|
|
80
79
|
CONTROL = {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
80
|
+
"type" => "object",
|
81
|
+
"additionalProperties" => false,
|
82
|
+
"properties" => {
|
83
|
+
"id" => { "type" => "string" },
|
84
|
+
"title" => { "type" => %w{string null} },
|
85
|
+
"desc" => { "type" => %w{string null} },
|
86
|
+
"descriptions" => { "type" => %w{array} },
|
87
|
+
"impact" => { "type" => "number" },
|
88
|
+
"refs" => REFS,
|
89
|
+
"tags" => TAGS,
|
90
|
+
"code" => { "type" => "string" },
|
91
|
+
"source_location" => {
|
92
|
+
"type" => "object",
|
93
|
+
"properties" => {
|
94
|
+
"ref" => { "type" => "string" },
|
95
|
+
"line" => { "type" => "number" },
|
97
96
|
},
|
98
97
|
},
|
99
|
-
|
98
|
+
"results" => { "type" => "array", "items" => RESULT },
|
100
99
|
},
|
101
100
|
}.freeze
|
102
101
|
|
103
102
|
SUPPORTS = {
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
"type" => "object",
|
104
|
+
"additionalProperties" => false,
|
105
|
+
"properties" => {
|
106
|
+
"platform-family" => { "type" => "string", "optional" => true },
|
107
|
+
"platform-name" => { "type" => "string", "optional" => true },
|
108
|
+
"platform" => { "type" => "string", "optional" => true },
|
110
109
|
# os-* supports are being deprecated
|
111
|
-
|
112
|
-
|
110
|
+
"os-family" => { "type" => "string", "optional" => true },
|
111
|
+
"os-name" => { "type" => "string", "optional" => true },
|
113
112
|
},
|
114
113
|
}.freeze
|
115
114
|
|
116
115
|
CONTROL_GROUP = {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
116
|
+
"type" => "object",
|
117
|
+
"additionalProperties" => false,
|
118
|
+
"properties" => {
|
119
|
+
"id" => { "type" => "string" },
|
120
|
+
"title" => { "type" => "string", "optional" => true },
|
121
|
+
"controls" => { "type" => "array", "items" => { "type" => "string" } },
|
123
122
|
},
|
124
123
|
}.freeze
|
125
124
|
|
126
125
|
PROFILE = {
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
126
|
+
"type" => "object",
|
127
|
+
"additionalProperties" => false,
|
128
|
+
"properties" => {
|
129
|
+
"name" => { "type" => "string" },
|
130
|
+
"version" => { "type" => "string", "optional" => true },
|
131
|
+
"sha256" => { "type" => "string", "optional" => false },
|
132
|
+
|
133
|
+
"title" => { "type" => "string", "optional" => true },
|
134
|
+
"maintainer" => { "type" => "string", "optional" => true },
|
135
|
+
"copyright" => { "type" => "string", "optional" => true },
|
136
|
+
"copyright_email" => { "type" => "string", "optional" => true },
|
137
|
+
"license" => { "type" => "string", "optional" => true },
|
138
|
+
"summary" => { "type" => "string", "optional" => true },
|
139
|
+
"status" => { "type" => "string", "optional" => false },
|
140
|
+
"skip_message" => { "type" => "string", "optional" => true },
|
141
|
+
|
142
|
+
"supports" => {
|
143
|
+
"type" => "array",
|
144
|
+
"items" => SUPPORTS,
|
145
|
+
"optional" => true,
|
147
146
|
},
|
148
|
-
|
149
|
-
|
150
|
-
|
147
|
+
"controls" => {
|
148
|
+
"type" => "array",
|
149
|
+
"items" => CONTROL,
|
151
150
|
},
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
"groups" => {
|
152
|
+
"type" => "array",
|
153
|
+
"items" => CONTROL_GROUP,
|
155
154
|
},
|
156
|
-
|
157
|
-
|
155
|
+
"attributes" => { # TODO: rename to inputs, refs #3802
|
156
|
+
"type" => "array",
|
158
157
|
# TODO: more detailed specification needed
|
159
158
|
},
|
160
159
|
},
|
161
160
|
}.freeze
|
162
161
|
|
163
162
|
EXEC_JSON = {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
163
|
+
"type" => "object",
|
164
|
+
"additionalProperties" => false,
|
165
|
+
"properties" => {
|
166
|
+
"platform" => PLATFORM,
|
167
|
+
"profiles" => {
|
168
|
+
"type" => "array",
|
169
|
+
"items" => PROFILE,
|
171
170
|
},
|
172
|
-
|
173
|
-
|
171
|
+
"statistics" => STATISTICS,
|
172
|
+
"version" => { "type" => "string" },
|
174
173
|
},
|
175
174
|
}.freeze
|
176
175
|
|
177
176
|
MIN_CONTROL = {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
177
|
+
"type" => "object",
|
178
|
+
"additionalProperties" => false,
|
179
|
+
"properties" => {
|
180
|
+
"id" => { "type" => "string" },
|
181
|
+
"profile_id" => { "type" => %w{string null} },
|
182
|
+
"profile_sha256" => { "type" => "string" },
|
183
|
+
"status" => { "type" => "string" },
|
184
|
+
"code_desc" => { "type" => "string" },
|
185
|
+
"skip_message" => { "type" => "string", "optional" => true },
|
186
|
+
"resource" => { "type" => "string", "optional" => true },
|
187
|
+
"message" => { "type" => "string", "optional" => true },
|
188
|
+
"exception" => { "type" => "string", "optional" => true },
|
189
|
+
"backtrace" => { "type" => "object", "optional" => true },
|
191
190
|
},
|
192
191
|
}.freeze
|
193
192
|
|
194
193
|
EXEC_JSONMIN = {
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
194
|
+
"type" => "object",
|
195
|
+
"additionalProperties" => false,
|
196
|
+
"properties" => {
|
197
|
+
"statistics" => STATISTICS,
|
198
|
+
"version" => { "type" => "string" },
|
199
|
+
"controls" => {
|
200
|
+
"type" => "array",
|
201
|
+
"items" => MIN_CONTROL,
|
203
202
|
},
|
204
203
|
},
|
205
204
|
}.freeze
|
206
205
|
|
207
206
|
# using a proc here so we can lazy load it when we need
|
208
207
|
PLATFORMS = lambda do
|
209
|
-
require
|
210
|
-
Train.create(
|
208
|
+
require "train"
|
209
|
+
Train.create("mock").connection
|
211
210
|
Train::Platforms.export
|
212
211
|
end
|
213
212
|
|
214
213
|
LIST = {
|
215
|
-
|
216
|
-
|
217
|
-
|
214
|
+
"exec-json" => EXEC_JSON,
|
215
|
+
"exec-jsonmin" => EXEC_JSONMIN,
|
216
|
+
"platforms" => PLATFORMS,
|
218
217
|
}.freeze
|
219
218
|
|
220
219
|
def self.names
|