inspec 3.4.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/inspec.gemspec +1 -1
- data/lib/inspec/cli.rb +10 -2
- data/lib/inspec/dsl.rb +5 -4
- data/lib/inspec/objects/attribute.rb +5 -1
- data/lib/inspec/plugin/v2/loader.rb +7 -9
- data/lib/inspec/plugin/v2/plugin_types/cli.rb +6 -1
- data/lib/inspec/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5793aac36f079d0b7bebd85d779db9373acf3254ca6bd0a3a292dd3cc50f8e9
|
4
|
+
data.tar.gz: c06c31588e65bf81bf3f6deab5468bfc00b12b05bae58e605810252da7868872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f4d4e85ab232e31fbc993701ba14e0d3b04ebde60ca128a4819550b95cbfada4af0b4d9ac4dd78bf393dcede4bc1c9b185087c9ddaabd27a02488995dcc75f
|
7
|
+
data.tar.gz: dad455607c78e2245e1dc0e2be47b21050cc479de74a4f826f9e03c375c5eeea456727b1dcb83f3bf10fe17403f28802bda56a694cb8465af72593c14ef62399
|
data/inspec.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = '>= 2.3'
|
26
26
|
|
27
|
-
spec.add_dependency 'train', '~> 1.5', '
|
27
|
+
spec.add_dependency 'train', '~> 1.5', '= 1.7.1' # 1.7.2 has a regression introduced by train #394
|
28
28
|
spec.add_dependency 'thor', '~> 0.20'
|
29
29
|
spec.add_dependency 'json', '>= 1.8', '< 3.0'
|
30
30
|
spec.add_dependency 'method_source', '~> 0.8'
|
data/lib/inspec/cli.rb
CHANGED
@@ -32,6 +32,12 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|
32
32
|
class_option :interactive, type: :boolean,
|
33
33
|
desc: 'Allow or disable user interaction'
|
34
34
|
|
35
|
+
class_option :disable_core_plugins, type: :string, banner: '', # Actually a boolean, but this suppresses the creation of a --no-disable...
|
36
|
+
desc: 'Disable loading all plugins that are shipped in the lib/plugins directory of InSpec. Useful in development.'
|
37
|
+
|
38
|
+
class_option :disable_user_plugins, type: :string, banner: '',
|
39
|
+
desc: 'Disable loading all plugins that the user installed.'
|
40
|
+
|
35
41
|
desc 'json PATH', 'read all tests in PATH and generate a JSON summary'
|
36
42
|
option :output, aliases: :o, type: :string,
|
37
43
|
desc: 'Save the created profile to a path'
|
@@ -378,8 +384,10 @@ begin
|
|
378
384
|
end
|
379
385
|
end
|
380
386
|
|
381
|
-
# Load v2 plugins
|
382
|
-
|
387
|
+
# Load v2 plugins. Manually check for plugin disablement.
|
388
|
+
omit_core = ARGV.delete('--disable-core-plugins')
|
389
|
+
omit_user = ARGV.delete('--disable-user-plugins')
|
390
|
+
v2_loader = Inspec::Plugin::V2::Loader.new(omit_core_plugins: omit_core, omit_user_plugins: omit_user)
|
383
391
|
v2_loader.load_all
|
384
392
|
v2_loader.exit_on_load_error
|
385
393
|
v2_loader.activate_mentioned_cli_plugins
|
data/lib/inspec/dsl.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# author: Dominik Richter
|
4
4
|
# author: Christoph Hartmann
|
5
5
|
require 'inspec/log'
|
6
|
+
require 'inspec/plugin/v2'
|
6
7
|
|
7
8
|
module Inspec::DSL
|
8
9
|
def require_controls(id, &block)
|
@@ -55,18 +56,18 @@ module Inspec::DSL
|
|
55
56
|
profile_id = opts[:profile_id]
|
56
57
|
dep_entry = dependencies.list[profile_id]
|
57
58
|
|
58
|
-
# do not load any controls if the profile is not supported
|
59
|
-
return unless dep_entry.profile.supports_platform?
|
60
|
-
|
61
59
|
if dep_entry.nil?
|
62
60
|
raise <<~EOF
|
63
|
-
Cannot load #{profile_id} since it is not listed as a dependency of #{bind_context.profile_name}.
|
61
|
+
Cannot load '#{profile_id}' since it is not listed as a dependency of #{bind_context.profile_name}.
|
64
62
|
|
65
63
|
Dependencies available from this context are:
|
66
64
|
#{dependencies.list.keys.join("\n ")}
|
67
65
|
EOF
|
68
66
|
end
|
69
67
|
|
68
|
+
# Do not load any controls if the profile is not supported
|
69
|
+
return unless dep_entry.profile.supports_platform?
|
70
|
+
|
70
71
|
context = dep_entry.profile.runner_context
|
71
72
|
# if we don't want all the rules, then just make 1 pass to get all rule_IDs
|
72
73
|
# that we want to keep from the original
|
@@ -93,7 +93,11 @@ module Inspec
|
|
93
93
|
def to_ruby
|
94
94
|
res = ["#{ruby_var_identifier} = attribute('#{@name}',{"]
|
95
95
|
res.push " title: '#{title}'," unless title.to_s.empty?
|
96
|
-
res.push "
|
96
|
+
res.push " value: #{value.inspect}," unless value.to_s.empty?
|
97
|
+
# to_ruby may generate code that is to be used by older versions of inspec.
|
98
|
+
# Anything older than 3.4 will not recognize the value: option, so
|
99
|
+
# send the default: option as well. See #3759
|
100
|
+
res.push " default: #{value.inspect}," unless value.to_s.empty?
|
97
101
|
res.push " description: '#{description}'," unless description.to_s.empty?
|
98
102
|
res.push '})'
|
99
103
|
res.join("\n")
|
@@ -14,8 +14,10 @@ module Inspec::Plugin::V2
|
|
14
14
|
def initialize(options = {})
|
15
15
|
@options = options
|
16
16
|
@registry = Inspec::Plugin::V2::Registry.instance
|
17
|
-
|
18
|
-
|
17
|
+
unless options[:omit_user_plugins]
|
18
|
+
@conf_file = Inspec::Plugin::V2::ConfigFile.new
|
19
|
+
read_conf_file_into_registry
|
20
|
+
end
|
19
21
|
|
20
22
|
# Old-style (v0, v1) co-distributed plugins were called 'bundles'
|
21
23
|
# and were located in lib/bundles
|
@@ -89,13 +91,9 @@ module Inspec::Plugin::V2
|
|
89
91
|
# all following ||= ops.
|
90
92
|
activate_me = false
|
91
93
|
|
92
|
-
# If the user invoked `inspec help`,
|
93
|
-
# display their usage message.
|
94
|
-
activate_me ||=
|
95
|
-
|
96
|
-
# Likewise, if they invoked simply `inspec`, they are confused, and need
|
97
|
-
# usage info.
|
98
|
-
activate_me ||= cli_args.empty?
|
94
|
+
# If the user invoked `inspec help`, `inspec --help`, or only `inspec`
|
95
|
+
# then activate all CLI plugins so they can display their usage message.
|
96
|
+
activate_me ||= ['help', '--help', nil].include?(cli_args.first)
|
99
97
|
|
100
98
|
# If there is anything in the CLI args with the same name, activate it.
|
101
99
|
# This is the expected usual activation for individual plugins.
|
@@ -1,8 +1,13 @@
|
|
1
1
|
require 'inspec/base_cli'
|
2
2
|
|
3
|
+
# The InSpec load order has this file being loaded before `inspec/base_cli` can
|
4
|
+
# finish being loaded. So, we must define Inspec::BaseCLI here first to avoid
|
5
|
+
# a NameError below.
|
6
|
+
class Inspec::BaseCLI < Thor; end
|
7
|
+
|
3
8
|
module Inspec::Plugin::V2::PluginType
|
4
9
|
class CliCommand < Inspec::BaseCLI
|
5
|
-
#
|
10
|
+
# initialize log options for plugins
|
6
11
|
def initialize(args, options, config)
|
7
12
|
super(args, options, config)
|
8
13
|
class_options = config.fetch(:class_options, nil)
|
data/lib/inspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01
|
11
|
+
date: 2019-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -17,9 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
|
-
- -
|
20
|
+
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.7.
|
22
|
+
version: 1.7.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +27,9 @@ dependencies:
|
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.5'
|
30
|
-
- -
|
30
|
+
- - '='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.7.
|
32
|
+
version: 1.7.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: thor
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|