inspec-core 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd93e17059f4e6da1bd640c908688b009b7d851b33ac2c12227045d71a5a25a2
4
- data.tar.gz: c4edad3d720f7db313a01f7eded6763de0d0b033d34770322496b4a282894e11
3
+ metadata.gz: 190e8714166fd805239f3a7cf9bd5b830af9a7abffb671001361dd62da963e26
4
+ data.tar.gz: 4f9d5fae927f80c5b136614fb581e308d43c2d1dabaa1e36238690891c499598
5
5
  SHA512:
6
- metadata.gz: 40cc89ad2cd53ecb0662985ff9901c953b00bae85e6313ba7bdf28b68b22acc4725cb871256c22107a552f6ea074e7d02e093b0a566cdded0addd0548f4a7314
7
- data.tar.gz: 7bb582628c261148e8633bd1e3de49b0c8d7b009873e34458b2669b27af6e93a747b993a67a7acf513f7886e1c5c0d3d97b9e6b023a496d889c3a833a6e9fb90
6
+ metadata.gz: 80a02ea7b5bd63fbf69cea562a5e951afbdab37de14623861fb8b907ba9738af0c83be270e48e32b1bb797c4d4634bb03e671203b33fc49d9e42aba97d789d79
7
+ data.tar.gz: ccd6167f75157dd5ce47f0678846a5837e22cb1b023fd559aa80878b235e1efb712403a0503a1c10fc825654c5dd93f960fd5fe337a9d1cae2986617334073bc
@@ -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
- v2_loader = Inspec::Plugin::V2::Loader.new
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
@@ -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 " default: #{default.inspect}," unless default.to_s.empty?
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
- @conf_file = Inspec::Plugin::V2::ConfigFile.new
18
- read_conf_file_into_registry
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`, activate all CLI plugins, so they can
93
- # display their usage message.
94
- activate_me ||= cli_args.first == 'help'
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
- # initalize log options for plugins
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)
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '3.4.1'
7
+ VERSION = '3.5.0'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
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-29 00:00:00.000000000 Z
11
+ date: 2019-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train-core
@@ -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.6.3
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.6.3
32
+ version: 1.7.1
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: thor
35
35
  requirement: !ruby/object:Gem::Requirement