inspec 4.6.9 → 4.7.3

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: 2f5b73cc4ec9d1e11867bb9e7d0cc7eeb1007ef4b10f56485d817bd56811d662
4
- data.tar.gz: 12b23768ff808f509c88b7ce0558a73e04a328d8d9a6e37da6b6ac74208e891e
3
+ metadata.gz: 92f16a5a5997ab82b670f6aad951d3cfdce80bbe74e6454c7495fca62621267c
4
+ data.tar.gz: 2e8a866d55ad0ac9710725e4f19667b2a53df7c6b7ddaf814a5a117a2e5314f2
5
5
  SHA512:
6
- metadata.gz: 39a2cdcd01416f61101a2436ce3a01bc754cd3212010d348a094b14b1ac8a7b07e9dbc4b2da1795c5b75ea628e760c4cf5ddb84a446531531bdad78f3d24f183
7
- data.tar.gz: 25b1c69962503c6567ec46f8122edddc614bdfa16b475b6a64ad4c488e7e115830aeb59a215826cfb6b9ac1b67b9b9a6c6c1de395c7d0dce3689bc4ae88121b9
6
+ metadata.gz: 3394cc65c1f7b4901ebd99172e082b6e241c44a8cadb2b23eafd87411ab091073d2bcedb811f796272c4828422dca67adae1162814912bbebd408e93377472b9
7
+ data.tar.gz: 1fb91443861897468c24a5a83d4135387c869f8fb8e8f16c7c8307a5971452101fce2a0e5fa21357c68a32a9c614c7c19448e3c1a55d83662676878d8ca47755
data/Gemfile CHANGED
@@ -19,7 +19,7 @@ group :omnibus do
19
19
  end
20
20
 
21
21
  group :test do
22
- gem "chefstyle", "~> 0.6"
22
+ gem "chefstyle", "0.13.0"
23
23
  gem "coveralls", require: false
24
24
  gem "minitest", "~> 5.5"
25
25
  gem "rake", ">= 10"
data/README.md CHANGED
@@ -31,15 +31,18 @@ Chef InSpec makes it easy to run your tests wherever you need. More options are
31
31
  # run test locally
32
32
  inspec exec test.rb
33
33
 
34
- # run test on remote host on SSH
34
+ # run test on remote host via SSH
35
35
  inspec exec test.rb -t ssh://user@hostname -i /path/to/key
36
36
 
37
37
  # run test on remote host using SSH agent private key authentication. Requires Chef InSpec 1.7.1
38
38
  inspec exec test.rb -t ssh://user@hostname
39
39
 
40
- # run test on remote windows host on WinRM
40
+ # run test on remote windows host via WinRM
41
41
  inspec exec test.rb -t winrm://Administrator@windowshost --password 'your-password'
42
42
 
43
+ # run test on remote windows host via WinRM as a domain user
44
+ inspec exec test.rb -t winrm://windowshost --user 'UserName@domain' --password 'your-password'
45
+
43
46
  # run test on docker container
44
47
  inspec exec test.rb -t docker://container_id
45
48
  ```
@@ -295,19 +295,19 @@ module Inspec
295
295
  def validate_reporters!(reporters)
296
296
  return if reporters.nil?
297
297
  # TODO: move this into a reporter plugin type system
298
- valid_types = [
299
- "automate",
300
- "cli",
301
- "documentation",
302
- "html",
303
- "json",
304
- "json-automate",
305
- "json-min",
306
- "json-rspec",
307
- "junit",
308
- "progress",
309
- "yaml",
310
- ]
298
+ valid_types = %w{
299
+ automate
300
+ cli
301
+ documentation
302
+ html
303
+ json
304
+ json-automate
305
+ json-min
306
+ json-rspec
307
+ junit
308
+ progress
309
+ yaml
310
+ }
311
311
 
312
312
  reporters.each do |reporter_name, reporter_config|
313
313
  raise NotImplementedError, "'#{reporter_name}' is not a valid reporter type." unless valid_types.include?(reporter_name)
@@ -461,9 +461,9 @@ module Inspec::Plugin::V2
461
461
 
462
462
  # Combine the Sets, so the resolver has one composite place to look
463
463
  Gem::Resolver.compose_sets(
464
- installed_plugins_gem_set, # The gems that are in the plugin gem path directory tree
464
+ installed_plugins_gem_set, # The gems that are in the plugin gem path directory tree
465
465
  InstalledVendorSet.new,
466
- *extra_request_sets, # Anything else our caller wanted to include
466
+ *extra_request_sets # Anything else our caller wanted to include
467
467
  )
468
468
  end
469
469
 
@@ -14,7 +14,7 @@ module Inspec::Plugin::V2
14
14
  :loaded, # true, false False could mean not attempted or failed
15
15
  :load_exception, # Exception class if it failed to load
16
16
  :name, # String name
17
- :version, # three-digit version. Core / bundled plugins use InSpec version here.
17
+ :version # three-digit version. Core / bundled plugins use InSpec version here.
18
18
  ) do
19
19
  def initialize(*)
20
20
  super
@@ -127,7 +127,7 @@ module Inspec
127
127
  cli_input_files: options[:runner_conf][:input_file], # From CLI --input-file
128
128
  profile_metadata: metadata,
129
129
  # TODO: deprecation checks here
130
- runner_api: options[:runner_conf][:attributes], # This is the route the audit_cookbook and kitchen-inspec take
130
+ runner_api: options[:runner_conf][:attributes] # This is the route the audit_cookbook and kitchen-inspec take
131
131
  )
132
132
 
133
133
  @runner_context =
@@ -56,6 +56,7 @@ require "inspec/resources/iis_app_pool"
56
56
  require "inspec/resources/iis_site"
57
57
  require "inspec/resources/inetd_conf"
58
58
  require "inspec/resources/interface"
59
+ require "inspec/resources/ip6tables"
59
60
  require "inspec/resources/iptables"
60
61
  require "inspec/resources/kernel_module"
61
62
  require "inspec/resources/kernel_parameter"
@@ -102,7 +102,7 @@ module Inspec::Resources
102
102
  components: parse_repo[4].chomp.split(" "),
103
103
  active: active,
104
104
  }
105
- next unless ["deb", "deb-src"].include? repo[:type]
105
+ next unless %w{deb deb-src}.include? repo[:type]
106
106
 
107
107
  lines.push(repo)
108
108
  end
@@ -0,0 +1,79 @@
1
+ require "inspec/resources/command"
2
+
3
+ # Usage:
4
+ # describe ip6tables do
5
+ # it { should have_rule('-P INPUT ACCEPT') }
6
+ # end
7
+ #
8
+ # The following serverspec sytax is not implemented:
9
+ # describe ip6tables do
10
+ # it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
11
+ # end
12
+ # Please use the new sytax:
13
+ # describe ip6tables(table:'mangle', chain: 'input') do
14
+ # it { should have_rule('-P INPUT ACCEPT') }
15
+ # end
16
+ #
17
+ # Note: Docker containers normally do not have ip6tables installed
18
+ #
19
+ # @see http://ipset.netfilter.org/ip6tables.man.html
20
+ # @see http://ipset.netfilter.org/ip6tables.man.html
21
+ module Inspec::Resources
22
+ class Ip6Tables < Inspec.resource(1)
23
+ name "ip6tables"
24
+ supports platform: "linux"
25
+ desc "Use the ip6tables InSpec audit resource to test rules that are defined in ip6tables, which maintains tables of IP packet filtering rules. There may be more than one table. Each table contains one (or more) chains (both built-in and custom). A chain is a list of rules that match packets. When the rule matches, the rule defines what target to assign to the packet."
26
+ example <<~EXAMPLE
27
+ describe ip6tables do
28
+ it { should have_rule('-P INPUT ACCEPT') }
29
+ end
30
+ EXAMPLE
31
+
32
+ def initialize(params = {})
33
+ @table = params[:table]
34
+ @chain = params[:chain]
35
+
36
+ # we're done if we are on linux
37
+ return if inspec.os.linux?
38
+
39
+ # ensures, all calls are aborted for non-supported os
40
+ @ip6tables_cache = []
41
+ skip_resource "The `ip6tables` resource is not supported on your OS yet."
42
+ end
43
+
44
+ def has_rule?(rule = nil, _table = nil, _chain = nil)
45
+ # checks if the rule is part of the ruleset
46
+ # for now, we expect an exact match
47
+ retrieve_rules.any? { |line| line.casecmp(rule) == 0 }
48
+ end
49
+
50
+ def retrieve_rules
51
+ return @ip6tables_cache if defined?(@ip6tables_cache)
52
+
53
+ # construct ip6tables command to read all rules
54
+ bin = find_ip6tables_or_error
55
+ table_cmd = "-t #{@table}" if @table
56
+ ip6tables_cmd = format("%s %s -S %s", bin, table_cmd, @chain).strip
57
+
58
+ cmd = inspec.command(ip6tables_cmd)
59
+ return [] if cmd.exit_status.to_i != 0
60
+
61
+ # split rules, returns array or rules
62
+ @ip6tables_cache = cmd.stdout.split("\n").map(&:strip)
63
+ end
64
+
65
+ def to_s
66
+ format("Ip6tables %s %s", @table && "table: #{@table}", @chain && "chain: #{@chain}").strip
67
+ end
68
+
69
+ private
70
+
71
+ def find_ip6tables_or_error
72
+ %w{/usr/sbin/ip6tables /sbin/ip6tables ip6tables}.each do |cmd|
73
+ return cmd if inspec.command(cmd).exist?
74
+ end
75
+
76
+ raise Inspec::Exceptions::ResourceFailed, "Could not find `ip6tables`"
77
+ end
78
+ end
79
+ end
@@ -127,10 +127,14 @@ module Inspec::Resources
127
127
  Systemd.new(inspec, service_ctl)
128
128
  end
129
129
  elsif %w{debian}.include?(platform)
130
- version = os[:release].to_i
130
+ if os[:release] == "buster/sid"
131
+ version = 10
132
+ else
133
+ version = os[:release].to_i
134
+ end
131
135
  if version > 7
132
136
  Systemd.new(inspec, service_ctl)
133
- else
137
+ elsif version > 0
134
138
  SysV.new(inspec, service_ctl || "/usr/sbin/service")
135
139
  end
136
140
  elsif %w{redhat fedora centos oracle cloudlinux}.include?(platform)
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "4.6.9".freeze
2
+ VERSION = "4.7.3".freeze
3
3
  end
@@ -147,7 +147,7 @@ RSpec::Matchers.define :be_resolvable do
147
147
  end
148
148
  end
149
149
 
150
- # matcher for iptables
150
+ # matcher for iptables and ip6tables
151
151
  RSpec::Matchers.define :have_rule do |rule|
152
152
  match do |tables|
153
153
  tables.has_rule?(rule)
@@ -233,10 +233,10 @@ class PluginManagerCliSearch < Minitest::Test
233
233
  result = run_inspec_process("plugin search --include-test-fixture inspec-")
234
234
  assert_equal 0, result.exit_status, "Search should exit 0"
235
235
  assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the test gem"
236
- [
237
- "inspec-core",
238
- "inspec-multi-server",
239
- ].each do |plugin_name|
236
+ %w{
237
+ inspec-core
238
+ inspec-multi-server
239
+ }.each do |plugin_name|
240
240
  refute_includes result.stdout, plugin_name, "Search result should not contain excluded gems"
241
241
  end
242
242
  end
@@ -555,11 +555,11 @@ class PluginManagerCliInstall < Minitest::Test
555
555
  # are the names of real rubygems. They are not InSpec/Train plugins, though,
556
556
  # and installing them would be a jam-up.
557
557
  # This is configured in 'etc/plugin-filter.json'.
558
- [
559
- "inspec-core",
560
- "inspec-multi-server",
561
- "train-tax-calculator",
562
- ].each do |plugin_name|
558
+ %w{
559
+ inspec-core
560
+ inspec-multi-server
561
+ train-tax-calculator
562
+ }.each do |plugin_name|
563
563
  install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_name}")
564
564
  assert_empty install_result.stderr
565
565
  assert_equal 2, install_result.exit_status, "Exit status should be 2"
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: 4.6.9
4
+ version: 4.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-01 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -546,6 +546,7 @@ files:
546
546
  - lib/inspec/resources/inetd_conf.rb
547
547
  - lib/inspec/resources/ini.rb
548
548
  - lib/inspec/resources/interface.rb
549
+ - lib/inspec/resources/ip6tables.rb
549
550
  - lib/inspec/resources/iptables.rb
550
551
  - lib/inspec/resources/json.rb
551
552
  - lib/inspec/resources/kernel_module.rb