inspec 1.25.1 → 1.26.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
  SHA1:
3
- metadata.gz: 2369b96cee8091a5a6217e02655d0093ecca8a33
4
- data.tar.gz: 59d26c6a3fb7df21eaa354716c1c1e5e97340038
3
+ metadata.gz: fecbcfd7ae1d3b85d799bc71dc2eabe989f16136
4
+ data.tar.gz: 20bd1251717cd160dbd5b4b8884ca2d916838f3b
5
5
  SHA512:
6
- metadata.gz: d1ee1b6272be4d4e246318f20aa67a78afc9ed7a0e740ed1dae503110700a0e091aebb32b9c75c6fe3802ae539a99491b415fb1b1179517047223c814d6085cd
7
- data.tar.gz: 9998bcdc5ec747c15fc2b43cea4ec91b59bf1d158c7a2bf4025865ec90b844c8048a0fa3d8ad01bf6501a3965384e39b906d5200f979a2c5cb6269abdc159523
6
+ metadata.gz: 3553ac4c21f7f73f70fcaed794292b013f7106a7b226ffb5500c1c9c6451d4355d10aa0526d28d32db926e6a281f5a1f48cf7bcb68255b893853020debfa8a42
7
+ data.tar.gz: 743f7fce23d0d50eb6d3df716c7f44d9ca1f8824fdc47df6940d77308a720146caf07eb1f6c3a47616cc230561e832b32aa89206d97ace6cea43a7e69abd5f13
data/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Change Log
2
2
 
3
- ## [v1.25.1](https://github.com/chef/inspec/tree/v1.25.1) (2017-05-19)
3
+ ## [v1.26.0](https://github.com/chef/inspec/tree/v1.26.0) (2017-05-30)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.25.1...v1.26.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Improvements to Habitat plan [\#1820](https://github.com/chef/inspec/pull/1820) ([smith](https://github.com/smith))
9
+
10
+ **Fixed bugs:**
11
+
12
+ - bugfix: adjust localhost+sudo test output to train update [\#1873](https://github.com/chef/inspec/pull/1873) ([arlimus](https://github.com/arlimus))
13
+ - bugfix: do not send nil to command on unsupported OS [\#1865](https://github.com/chef/inspec/pull/1865) ([arlimus](https://github.com/arlimus))
14
+ - bugfix: non-url servers with compliance login [\#1861](https://github.com/chef/inspec/pull/1861) ([arlimus](https://github.com/arlimus))
15
+ - Habitat Profiles: redirect stderr to stdout [\#1826](https://github.com/chef/inspec/pull/1826) ([adamleff](https://github.com/adamleff))
16
+
17
+ **Closed issues:**
18
+
19
+ - Using Automate - `compliance\_profile\_name': undefined method `\[\]' for nil:NilClass \(NoMethodError\) seeing 1.25.1 Inspec [\#1848](https://github.com/chef/inspec/issues/1848)
20
+ - Missing filesystem size check for InSpec [\#1843](https://github.com/chef/inspec/issues/1843)
21
+
22
+ ## [v1.25.1](https://github.com/chef/inspec/tree/v1.25.1) (2017-05-20)
4
23
  [Full Changelog](https://github.com/chef/inspec/compare/v1.25.0...v1.25.1)
5
24
 
6
25
  **Implemented enhancements:**
@@ -70,28 +89,15 @@
70
89
  - provide `inspec.version` information [\#1719](https://github.com/chef/inspec/pull/1719) ([arlimus](https://github.com/arlimus))
71
90
  - provide the `inspec` keyword [\#1718](https://github.com/chef/inspec/pull/1718) ([arlimus](https://github.com/arlimus))
72
91
  - print and prettyprint the inspec backend class [\#1717](https://github.com/chef/inspec/pull/1717) ([arlimus](https://github.com/arlimus))
73
- - inspec control.to\_ruby to use newlines instead of `\n` [\#1705](https://github.com/chef/inspec/pull/1705) ([arlimus](https://github.com/arlimus))
74
92
 
75
93
  **Fixed bugs:**
76
94
 
77
95
  - pretty-print multiline control descriptions [\#1711](https://github.com/chef/inspec/pull/1711) ([arlimus](https://github.com/arlimus))
78
96
  - bugfix: unindent description misbehaviors [\#1707](https://github.com/chef/inspec/pull/1707) ([arlimus](https://github.com/arlimus))
79
- - handle json parse errors in docker resource [\#1706](https://github.com/chef/inspec/pull/1706) ([chris-rock](https://github.com/chris-rock))
80
97
 
81
98
  ## [v1.21.0](https://github.com/chef/inspec/tree/v1.21.0) (2017-04-24)
82
99
  [Full Changelog](https://github.com/chef/inspec/compare/v1.20.0...v1.21.0)
83
100
 
84
- **Implemented enhancements:**
85
-
86
- - fetch user groups while building user object [\#1681](https://github.com/chef/inspec/pull/1681) ([Happycoil](https://github.com/Happycoil))
87
- - update sslshake to v1.2 [\#1680](https://github.com/chef/inspec/pull/1680) ([arlimus](https://github.com/arlimus))
88
-
89
- **Fixed bugs:**
90
-
91
- - Web references in inspec shell help are wrong [\#1667](https://github.com/chef/inspec/issues/1667)
92
- - bugfix: solve warn on uninitialized [\#1694](https://github.com/chef/inspec/pull/1694) ([arlimus](https://github.com/arlimus))
93
- - fix web reference url [\#1669](https://github.com/chef/inspec/pull/1669) ([chris-rock](https://github.com/chris-rock))
94
-
95
101
 
96
102
 
97
103
  \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -4,7 +4,7 @@ title: About the interface Resource
4
4
 
5
5
  # interface
6
6
 
7
- Use the `interface` InSpec audit resource to test basic network adapter properties, such as name, status, state, address, and link speed (in MB/sec).
7
+ Use the `interface` InSpec audit resource to test basic network adapter properties, such as name, status, and link speed (in MB/sec).
8
8
 
9
9
  * On Linux platforms, `/sys/class/net/#{iface}` is used as source
10
10
  * On the Windows platform, the `Get-NetAdapter` cmdlet is used as source
@@ -13,7 +13,7 @@ Use the `interface` InSpec audit resource to test basic network adapter properti
13
13
 
14
14
  An `interface` resource block declares network interface properties to be tested:
15
15
 
16
- describe interface do
16
+ describe interface('eth0') do
17
17
  it { should be_up }
18
18
  its('speed') { should eq 1000 }
19
19
  its('name') { should eq eth0 }
data/inspec.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.required_ruby_version = '>= 2.1'
28
28
 
29
- spec.add_dependency 'train', '>=0.22.0', '<1.0'
29
+ spec.add_dependency 'train', '>=0.24.0', '<1.0'
30
30
  spec.add_dependency 'thor', '~> 0.19'
31
31
  spec.add_dependency 'json', '>= 1.8', '< 3.0'
32
32
  spec.add_dependency 'rainbow', '~> 2'
@@ -10,8 +10,7 @@ module Compliance
10
10
  class HTTP
11
11
  # generic get requires
12
12
  def self.get(url, headers = nil, insecure)
13
- url = "https://#{url}" if URI.parse(url).scheme.nil?
14
- uri = URI.parse(url)
13
+ uri = _parse_url(url)
15
14
  req = Net::HTTP::Get.new(uri.path)
16
15
  if !headers.nil?
17
16
  headers.each do |key, value|
@@ -24,7 +23,7 @@ module Compliance
24
23
  # generic post request
25
24
  def self.post(url, token, insecure, basic_auth = false)
26
25
  # form request
27
- uri = URI.parse(url)
26
+ uri = _parse_url(url)
28
27
  req = Net::HTTP::Post.new(uri.path)
29
28
  if basic_auth
30
29
  req.basic_auth token, ''
@@ -38,7 +37,7 @@ module Compliance
38
37
 
39
38
  # post a file
40
39
  def self.post_file(url, headers, file_path, insecure)
41
- uri = URI.parse(url)
40
+ uri = _parse_url(url)
42
41
  raise "Unable to parse URL: #{url}" if uri.nil? || uri.host.nil?
43
42
  http = Net::HTTP.new(uri.host, uri.port)
44
43
 
@@ -81,5 +80,10 @@ module Compliance
81
80
  puts 'If the server uses a self-signed certificate, please re-run the login command with the --insecure option.'
82
81
  exit 1
83
82
  end
83
+
84
+ def self._parse_url(url)
85
+ url = "https://#{url}" if URI.parse(url).scheme.nil?
86
+ URI.parse(url)
87
+ end
84
88
  end
85
89
  end
@@ -87,6 +87,12 @@ EOF
87
87
  else
88
88
  %r{^#{@config['server']}/owners/(?<owner>[^/]+)/compliance/(?<id>[^/]+)/tar$}
89
89
  end.match(@target)
90
+
91
+ raise 'Unable to determine compliance profile name. This can be caused by ' \
92
+ 'an incorrect server in your configuration. Try to login to compliance ' \
93
+ 'via the `inspec compliance login` or `inspec compliance login_automate` ' \
94
+ 'commands.' if m.nil?
95
+
90
96
  "#{m[:owner]}/#{m[:id]}"
91
97
  end
92
98
  end
@@ -332,6 +332,12 @@ do_install() {
332
332
  <<-EOL
333
333
  #!/bin/sh
334
334
 
335
+ # redirect stderr to stdout
336
+ # ultimately, we'd like to log this somewhere useful, but due to
337
+ # https://github.com/habitat-sh/habitat/issues/2395, we need to
338
+ # avoid doing that for now.
339
+ exec 2>&1
340
+
335
341
  # InSpec will try to create a .cache directory in the user's home directory
336
342
  # so this needs to be someplace writeable by the hab user
337
343
  export HOME={{pkg.svc_var_path}}
@@ -339,23 +345,21 @@ export HOME={{pkg.svc_var_path}}
339
345
  PROFILE_IDENT="{{pkg.origin}}/{{pkg.name}}"
340
346
  RESULTS_DIR="{{pkg.svc_var_path}}/inspec_results"
341
347
  RESULTS_FILE="${RESULTS_DIR}/{{pkg.name}}.json"
342
- ERROR_FILE="{{pkg.svc_var_path}}/inspec.err"
343
348
 
344
349
  # Create a directory for inspec formatter output
345
350
  mkdir -p {{pkg.svc_var_path}}/inspec_results
346
351
 
347
352
  while true; do
348
353
  echo "Executing InSpec for ${PROFILE_IDENT}"
349
- inspec exec {{pkg.path}}/dist --format=json > ${RESULTS_FILE} 2>${ERROR_FILE}
354
+ inspec exec {{pkg.path}}/dist --format=json > ${RESULTS_FILE}
350
355
 
351
356
  if [ $? -eq 0 ]; then
352
357
  echo "InSpec run completed successfully."
353
- elsif [ -s ${ERROR_FILE} ]
354
- echo "InSpec run did NOT complete successfully. Error:"
355
- cat ${ERROR_FILE}
356
358
  else
357
- echo "InSpec run completed successfully, but there were control failures."
358
- echo "Check the output at ${RESULTS_FILE} for details."
359
+ echo "InSpec run did not complete successfully. If you do not see any errors above,"
360
+ echo "control failures were detected. Check the InSpec results here for details:"
361
+ echo ${RESULTS_FILE}
362
+ echo "Otherwise, troubleshoot any errors shown above."
359
363
  fi
360
364
 
361
365
  source {{pkg.svc_config_path}}/settings.sh
data/lib/inspec/cli.rb CHANGED
@@ -155,13 +155,6 @@ class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
155
155
  configure_logger(opts)
156
156
  o = opts.dup
157
157
 
158
- # print error if user passed --sudo but with no --target
159
- if opts[:sudo] && opts[:target].nil?
160
- Inspec::Log.error('--sudo is only valid when running against a remote host using --target')
161
- Inspec::Log.error('To run InSpec locally with elevated privileges, run `sudo inspec exec ...`')
162
- exit 1
163
- end
164
-
165
158
  # run tests
166
159
  run_tests(targets, o)
167
160
  rescue StandardError => e
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '1.25.1'.freeze
7
+ VERSION = '1.26.0'.freeze
8
8
  end
data/lib/resources/gem.rb CHANGED
@@ -39,16 +39,16 @@ module Inspec::Resources
39
39
  return @info if defined?(@info)
40
40
 
41
41
  cmd = inspec.command("#{@gem_binary} list --local -a -q \^#{@package_name}\$")
42
- @info = {
43
- installed: cmd.exit_status.zero?,
44
- type: 'gem',
45
- }
46
- return @info unless @info[:installed]
42
+ return {} unless cmd.exit_status.zero?
47
43
 
48
44
  # extract package name and version
49
45
  # parses data like winrm (1.3.4, 1.3.3)
50
46
  params = /^\s*([^\(]*?)\s*\((.*?)\)\s*$/.match(cmd.stdout.chomp)
51
- return {} if params.nil?
47
+ @info = {
48
+ installed: !params.nil?,
49
+ type: 'gem',
50
+ }
51
+ return @info unless @info[:installed]
52
52
 
53
53
  versions = params[2].split(',')
54
54
  @info[:name] = params[1]
@@ -24,15 +24,16 @@ module Inspec::Resources
24
24
  end
25
25
  "
26
26
 
27
- # rubocop:disable ParameterLists
28
- def initialize(url, method: 'GET', params: nil, auth: {}, headers: {}, data: nil, ssl_verify: true)
27
+ def initialize(url, opts = {})
29
28
  @url = url
30
- @method = method
31
- @params = params
32
- @auth = auth
33
- @headers = headers
34
- @data = data
35
- @ssl_verify = ssl_verify
29
+ @method = opts.fetch(:method, 'GET')
30
+ @params = opts.fetch(:params, nil)
31
+ @auth = opts.fetch(:auth, {})
32
+ @headers = opts.fetch(:headers, {})
33
+ @data = opts.fetch(:data, nil)
34
+ @open_timeout = opts.fetch(:open_timeout, 60)
35
+ @read_timeout = opts.fetch(:read_timeout, 60)
36
+ @ssl_verify = opts.fetch(:ssl_verify, true)
36
37
  end
37
38
 
38
39
  def status
@@ -60,8 +61,8 @@ module Inspec::Resources
60
61
  conn.basic_auth @auth[:user], @auth[:pass] unless @auth.empty?
61
62
 
62
63
  # set default timeout
63
- conn.options.timeout = 5 # open/read timeout in seconds
64
- conn.options.open_timeout = 3 # connection open timeout in seconds
64
+ conn.options.timeout = @read_timeout # open/read timeout in seconds
65
+ conn.options.open_timeout = @open_timeout # connection open timeout in seconds
65
66
 
66
67
  @response = conn.send(@method.downcase) do |req|
67
68
  req.body = @data
@@ -7,7 +7,7 @@ require 'utils/convert'
7
7
  module Inspec::Resources
8
8
  class NetworkInterface < Inspec.resource(1)
9
9
  name 'interface'
10
- desc 'Use the interface InSpec audit resource to test basic network adapter properties, such as name, status, state, address, and link speed (in MB/sec).'
10
+ desc 'Use the interface InSpec audit resource to test basic network adapter properties, such as name, status, and link speed (in MB/sec).'
11
11
  example "
12
12
  describe interface('eth0') do
13
13
  it { should exist }
@@ -71,6 +71,7 @@ module Inspec::Resources
71
71
 
72
72
  to_read = [@conf_path]
73
73
  until to_read.empty?
74
+ base_dir = File.dirname(to_read[0])
74
75
  raw_conf = read_file(to_read[0])
75
76
  @content += raw_conf
76
77
 
@@ -83,19 +84,23 @@ module Inspec::Resources
83
84
  to_read = to_read.drop(1)
84
85
  # see if there is more config files to include
85
86
 
86
- to_read += include_files(params).find_all do |fp|
87
+ to_read += include_files(params, base_dir).find_all do |fp|
87
88
  not @files_contents.key? fp
88
89
  end
89
90
  end
90
91
  @content
91
92
  end
92
93
 
93
- def include_files(params)
94
- include_files = params['include'] || []
95
- include_files += params['include_if_exists'] || []
94
+ def include_files(params, base_dir)
95
+ include_files = Array(params['include']) || []
96
+ include_files += Array(params['include_if_exists']) || []
97
+ include_files.map! do |f|
98
+ Pathname.new(f).absolute? ? f : File.join(base_dir, f)
99
+ end
100
+
96
101
  dirs = Array(params['include_dir']) || []
97
102
  dirs.each do |dir|
98
- dir = File.join(@conf_dir, dir) if dir[0] != '/'
103
+ dir = File.join(base_dir, dir) if dir[0] != '/'
99
104
  include_files += find_files(dir, depth: 1, type: 'file')
100
105
  end
101
106
  include_files
@@ -20,6 +20,7 @@ module Inspec::Resources
20
20
 
21
21
  def initialize(script)
22
22
  unless inspec.os.windows?
23
+ super('')
23
24
  return skip_resource 'The `script` resource is not supported on your OS yet.'
24
25
  end
25
26
  # since WinRM 2.0 and the default use of powershell for local execution in
@@ -32,6 +32,8 @@ module Inspec::Resources
32
32
  @list = all_cmds.find_all do |hm|
33
33
  hm[:command] =~ grep
34
34
  end
35
+
36
+ return skip_resource 'The `processes` resource is not supported on your OS yet.' if inspec.os.windows?
35
37
  end
36
38
 
37
39
  def to_s
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: 1.25.1
4
+ version: 1.26.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: 2017-05-20 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.22.0
19
+ version: 0.24.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '1.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.22.0
29
+ version: 0.24.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '1.0'
@@ -305,7 +305,6 @@ files:
305
305
  - docs/migration.md
306
306
  - docs/plugin_kitchen_inspec.md
307
307
  - docs/profiles.md
308
- - docs/resources.md
309
308
  - docs/resources/apache_conf.md.erb
310
309
  - docs/resources/apt.md.erb
311
310
  - docs/resources/audit_policy.md.erb
@@ -647,7 +646,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
647
646
  version: '0'
648
647
  requirements: []
649
648
  rubyforge_project:
650
- rubygems_version: 2.6.11
649
+ rubygems_version: 2.5.2
651
650
  signing_key:
652
651
  specification_version: 4
653
652
  summary: Infrastructure and compliance testing.