inspec 1.16.1 → 1.17.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: d93468ebe9f076388557bbcebcc35028729e0e80
4
- data.tar.gz: 20c57ff7acd7e352fdbba1169118e8a6b972abcd
3
+ metadata.gz: 2c165a6b8a6e0ec2ed55a4038e82a3bac56ab80b
4
+ data.tar.gz: 1a806307865e65cbd266caf0a8f3d0abe2b58257
5
5
  SHA512:
6
- metadata.gz: fbc82e1eabcd30a6ee62cbc113cc01a33250c2133a8488761d51782057220b280a08d237ebb86aec05d7dede8c7684f508d80606d905344ec285a34f1defe2ef
7
- data.tar.gz: 94d8329e70dc5c775bea9360e826bdc5ec2c98c44dc510ad5e5849b03b7959d59bfd532b2a11e191a066701fce5dab6d49347b0d322f3c5bb52df7316316b0e2
6
+ metadata.gz: 6b0ed9d55cc66ed12aaa28a51560cd3238970f215d764c56c96a75b329a41d9a05edc6bb2bece49a353b99b011b3168c76067599309d632f7d51b558a8033baa
7
+ data.tar.gz: 991eb89677b038a066fac3162685db305f807d1dc67cef40742ec8d778cef8ab6c2cce3c94411c9c6265c46744be37d5b2d09b9edfaf2ecec939fa4885c742c6
@@ -1,22 +1,59 @@
1
1
  # Change Log
2
2
 
3
- ## [1.16.1](https://github.com/chef/inspec/tree/v1.16.1) (2017-03-06)
3
+ ## [1.17.0](https://github.com/chef/inspec/tree/v1.17.0) (2017-03-21)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.16.1...v1.17.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Need better error message for improper inspec.yml formatting [\#1549](https://github.com/chef/inspec/issues/1549)
9
+
10
+ **Fixed bugs:**
11
+
12
+ - cannot load such file -- nokogiri [\#1562](https://github.com/chef/inspec/issues/1562)
13
+ - Failure to parse tcp6 URI [\#1521](https://github.com/chef/inspec/issues/1521)
14
+ - json resource array index access not working [\#1560](https://github.com/chef/inspec/issues/1560)
15
+
16
+ **Closed issues:**
17
+
18
+ - Crontab regex matching [\#1526](https://github.com/chef/inspec/issues/1526)
19
+
20
+ **Merged pull requests:**
21
+
22
+ - Fix omnibus configuration [\#1579](https://github.com/chef/inspec/pull/1579) ([adamleff](https://github.com/adamleff))
23
+ - moving the nokogiri reference into the gemspec file [\#1576](https://github.com/chef/inspec/pull/1576) ([jkerry](https://github.com/jkerry))
24
+ - Hide Event Feature on Homepage [\#1563](https://github.com/chef/inspec/pull/1563) ([hannah-radish](https://github.com/hannah-radish))
25
+ - Fix ObjectTraverser when accessing array values [\#1561](https://github.com/chef/inspec/pull/1561) ([adamleff](https://github.com/adamleff))
26
+ - Add additional example for matching crontab commands [\#1559](https://github.com/chef/inspec/pull/1559) ([adamleff](https://github.com/adamleff))
27
+ - Update file.md with example how to test symlinked files [\#1555](https://github.com/chef/inspec/pull/1555) ([nvtkaszpir](https://github.com/nvtkaszpir))
28
+ - Provide better error message when inspec.yml is invalid [\#1552](https://github.com/chef/inspec/pull/1552) ([adamleff](https://github.com/adamleff))
29
+ - try to use sysv fallback if is not producing proper output [\#1550](https://github.com/chef/inspec/pull/1550) ([chris-rock](https://github.com/chris-rock))
30
+ - update readme for install scripts [\#1548](https://github.com/chef/inspec/pull/1548) ([chris-rock](https://github.com/chris-rock))
31
+ - Fixing port check with v4 IPs in a v6 netstat line [\#1547](https://github.com/chef/inspec/pull/1547) ([adamleff](https://github.com/adamleff))
32
+ - Fixing a typo [\#1536](https://github.com/chef/inspec/pull/1536) ([tescalada](https://github.com/tescalada))
33
+ - windows\_task docs: Correct syntax error and misspelled word [\#1525](https://github.com/chef/inspec/pull/1525) ([spiffytech](https://github.com/spiffytech))
34
+
35
+ ## [v1.16.1](https://github.com/chef/inspec/tree/v1.16.1) (2017-03-06)
4
36
  [Full Changelog](https://github.com/chef/inspec/compare/v1.16.0...v1.16.1)
5
37
 
6
38
  **Fixed bugs:**
7
39
 
8
- - "inspec version" waits for connection timeout inside firewall [\#1537](https://github.com/chef/inspec/pull/1537) ([makotots](https://github.com/makotots))
40
+ - "inspec version" waits for connection timeout inside firewall [\#1537](https://github.com/chef/inspec/issues/1537)
9
41
 
10
42
  **Merged pull requests:**
11
43
 
12
- - Avoid connection timeout of "inspec version" [\#1538](https://github.com/chef/inspec/pull/1538) ([makotots](https://github.com/makotots))
44
+ - releasing 1.16.1 with a bug fix and omnibus fix [\#1540](https://github.com/chef/inspec/pull/1540) ([adamleff](https://github.com/adamleff))
13
45
  - Fix omnibus build after new JUnit formatter [\#1539](https://github.com/chef/inspec/pull/1539) ([adamleff](https://github.com/adamleff))
46
+ - Avoid connection timeout of "inspec version" [\#1538](https://github.com/chef/inspec/pull/1538) ([makotots](https://github.com/makotots))
47
+ - Write Habitat-driven InSpec output to svc\_var directory [\#1533](https://github.com/chef/inspec/pull/1533) ([adamleff](https://github.com/adamleff))
48
+ - Updating .gitignore for Habitat and direnv [\#1531](https://github.com/chef/inspec/pull/1531) ([adamleff](https://github.com/adamleff))
49
+ - Ready for review - inspec.io bug fixes, \#1440, \#1420, \#1465, \#1421, \#1437,\#1226, \#1494, \#1495 [\#1512](https://github.com/chef/inspec/pull/1512) ([hannah-radish](https://github.com/hannah-radish))
14
50
 
15
- ## [1.16.0](https://github.com/chef/inspec/tree/v1.16.0) (2017-03-02)
51
+ ## [v1.16.0](https://github.com/chef/inspec/tree/v1.16.0) (2017-03-02)
16
52
  [Full Changelog](https://github.com/chef/inspec/compare/v1.15.0...v1.16.0)
17
53
 
18
54
  **Implemented enhancements:**
19
55
 
56
+ - jUnit reports are hard to read [\#1438](https://github.com/chef/inspec/issues/1438)
20
57
  - Functional JUnit reporter [\#1454](https://github.com/chef/inspec/pull/1454) ([jkerry](https://github.com/jkerry))
21
58
 
22
59
  **Closed issues:**
@@ -25,6 +62,7 @@
25
62
 
26
63
  **Merged pull requests:**
27
64
 
65
+ - 1.16.0 [\#1530](https://github.com/chef/inspec/pull/1530) ([adamleff](https://github.com/adamleff))
28
66
  - use -- for description of inspec login\_automate [\#1527](https://github.com/chef/inspec/pull/1527) ([chris-rock](https://github.com/chris-rock))
29
67
  - fix ident in cmp matcher docs [\#1524](https://github.com/chef/inspec/pull/1524) ([chris-rock](https://github.com/chris-rock))
30
68
  - Add Rake to Habitat build Gemfile [\#1520](https://github.com/chef/inspec/pull/1520) ([adamleff](https://github.com/adamleff))
@@ -2203,4 +2241,4 @@
2203
2241
 
2204
2242
 
2205
2243
 
2206
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
2244
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
8
8
  end
9
9
 
10
10
  gem 'ffi', '>= 1.9.14'
11
- gem 'nokogiri', '~> 1.6'
12
11
 
13
12
  group :test do
14
13
  gem 'bundler', '~> 1.5'
@@ -32,17 +31,11 @@ group :integration do
32
31
  gem 'kitchen-dokken'
33
32
  end
34
33
 
35
- group :simulator do
36
- gem 'github-markup'
37
- gem 'redcarpet'
38
- gem 'docker-api'
39
- end
40
-
41
34
  group :tools do
42
35
  gem 'pry', '~> 0.10'
43
36
  gem 'rb-readline'
44
37
  gem 'license_finder'
45
- gem 'github_changelog_generator', '~> 1'
38
+ gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator"
46
39
  end
47
40
 
48
41
  # gems for Maintainers.md generation
data/README.md CHANGED
@@ -50,7 +50,15 @@ InSpec requires Ruby ( >1.9 ).
50
50
 
51
51
  ### Install as package
52
52
 
53
- The InSpec package is available for MacOS, RedHat, Ubuntu and Windows. Download the latest package at [InSpec Downloads](https://downloads.chef.io/inspec).
53
+ The InSpec package is available for MacOS, RedHat, Ubuntu and Windows. Download the latest package at [InSpec Downloads](https://downloads.chef.io/inspec) or install InSpec via script:
54
+
55
+ ```
56
+ # RedHat, Ubuntu, and macOS
57
+ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P inspec
58
+
59
+ # Windows
60
+ . { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -project inspec
61
+ ```
54
62
 
55
63
  ### Install it via rubygems.org
56
64
 
@@ -60,3 +60,9 @@ The following examples show how to use this InSpec audit resource.
60
60
  describe crontab.where({'hour' => '*', 'minute' => '*'}) do
61
61
  its('entries.length') { should cmp '0' }
62
62
  end
63
+
64
+ ### Test that the logged-in user's crontab contains a single command that matches a mattern
65
+
66
+ describe crontab.where { command =~ /a partial command string/ } do
67
+ its('entries.length') { should cmp 1 }
68
+ end
@@ -458,3 +458,25 @@ The following example shows how to use the `file` audit resource to verify if th
458
458
  describe command('pgrep ntp') do
459
459
  its('exit_status') { should eq 0 }
460
460
  end
461
+
462
+ ### Test parameters of symlinked file
463
+
464
+ If you need to test the parameters of the target file for a symlink, you can use the `link_path` method for the `file` resource.
465
+
466
+ For example, for the following symlink:
467
+
468
+ lrwxrwxrwx. 1 root root 11 03-10 17:56 /dev/virtio-ports/com.redhat.rhevm.vdsm -> ../vport2p1
469
+
470
+ ... you can write controls for both the link and the target.
471
+
472
+ describe file('/dev/virtio-ports/com.redhat.rhevm.vdsm') do
473
+ it { should be_symlink }
474
+ end
475
+
476
+ virito_port_vdsm = file('/dev/virtio-ports/com.redhat.rhevm.vdsm').link_path
477
+ describe file(virito_port_vdsm) do
478
+ it { should exist }
479
+ it { should be_character_device }
480
+ it { should be_owned_by 'ovirtagent' }
481
+ it { should be_grouped_into 'ovirtagent' }
482
+ end
@@ -23,7 +23,7 @@ A `json` resource block declares the data to be tested. Assume the following JSO
23
23
 
24
24
  This file can be queried using:
25
25
 
26
- describe json('/paht/to/name.json') do
26
+ describe json('/path/to/name.json') do
27
27
  its('name') { should eq 'hello' }
28
28
  its(['meta','creator']) { should eq 'John Doe' }
29
29
  its(['array', 1]) { should eq 'one' }
@@ -5,13 +5,13 @@ title: About the windows_task Resource
5
5
  # windows_task
6
6
 
7
7
  Use the `windows_task` Inspec audit resource to test a scheduled tasks configuration on a Windows platform.
8
- Microsoft and application vendors use scheduled tasks to perform a varity of system maintaince tasks but system administrators can schedule their own.
8
+ Microsoft and application vendors use scheduled tasks to perform a variety of system maintaince tasks but system administrators can schedule their own.
9
9
 
10
10
  ## Syntax
11
11
 
12
12
  A `windows_task` resource block declares the name of the task (as its full path) and tests its configuration:
13
13
 
14
- describe windows_task('task name uri' do
14
+ describe windows_task('task name uri') do
15
15
  its('parameter') { should eq 'value' }
16
16
  it { should be_enabled }
17
17
  end
@@ -100,4 +100,4 @@ Next Run Time: N/A
100
100
  Status: Ready
101
101
  Logon Mode: Interactive/Background
102
102
  ...
103
- ```
103
+ ```
@@ -9,10 +9,10 @@ depends:
9
9
  - name: ssl-benchmark
10
10
  resolved_source:
11
11
  url: https://github.com/dev-sec/ssl-benchmark/archive/master.tar.gz
12
- sha256: 9ad48391d4e6efff0a13d06736c5b075fb021410e0a629e087bc21e9617d957c
12
+ sha256: 74b3437714871cca4505d9fc445c805968d56bc674855112bab187a5166f5a2d
13
13
  version_constraints: ">= 0"
14
14
  - name: windows-patch-benchmark
15
15
  resolved_source:
16
16
  url: https://github.com/chris-rock/windows-patch-benchmark/archive/master.tar.gz
17
- sha256: 6bdab40a3fe9f9de4e7c87f4f3844fdcf2c5cba6f84089b68d47c72392b51fdc
17
+ sha256: eb00c95846aeb3f1cbc5106537dcbf550c910d65986d21a62f7deb69ea060dee
18
18
  version_constraints: ">= 0"
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency 'mixlib-log'
38
38
  spec.add_dependency 'sslshake', '~> 1'
39
39
  spec.add_dependency 'parallel', '~> 1.9'
40
- spec.add_dependency 'rspec_junit_formatter', '~> 0.2.3'
40
+ spec.add_dependency 'nokogiri', '~> 1.6'
41
41
  spec.add_dependency 'faraday', '>=0.9.0'
42
42
  spec.add_dependency 'toml', '~> 0.1'
43
43
  end
@@ -5,7 +5,6 @@
5
5
 
6
6
  require 'rspec/core'
7
7
  require 'rspec/core/formatters/json_formatter'
8
- require 'rspec_junit_formatter'
9
8
 
10
9
  # Vanilla RSpec JSON formatter with a slight extension to show example IDs.
11
10
  # TODO: Remove these lines when RSpec includes the ID natively
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '1.16.1'.freeze
7
+ VERSION = '1.17.0'.freeze
8
8
  end
@@ -21,6 +21,10 @@ module Inspec::Resources
21
21
  describe crontab.where({'hour' => '*', 'minute' => '*'}) do
22
22
  its('entries.length') { should cmp '0' }
23
23
  end
24
+
25
+ describe crontab.where { command =~ /a partial command string/ } do
26
+ its('entries.length') { should cmp 1 }
27
+ end
24
28
  "
25
29
 
26
30
  attr_reader :params
@@ -15,19 +15,36 @@ module Inspec::Resources
15
15
  end
16
16
  "
17
17
 
18
- # override file load and parse hash from csv
18
+ # override the parse method from JsonConfig
19
+ # Assuming a header row of name,col1,col2, it will output an array of hashes like so:
20
+ # [
21
+ # { 'name' => 'row1', 'col1' => 'value1', 'col2' => 'value2' },
22
+ # { 'name' => 'row2', 'col1' => 'value3', 'col2' => 'value4' }
23
+ # ]
19
24
  def parse(content)
20
25
  require 'csv'
26
+
21
27
  # convert empty field to nil
22
28
  CSV::Converters[:blank_to_nil] = lambda do |field|
23
29
  field && field.empty? ? nil : field
24
30
  end
31
+
25
32
  # implicit conversion of values
26
33
  csv = CSV.new(content, headers: true, converters: [:all, :blank_to_nil])
34
+
27
35
  # convert to hash
28
36
  csv.to_a.map(&:to_hash)
29
37
  end
30
38
 
39
+ # override the value method from JsonConfig
40
+ # The format of the CSV hash as created by #parse is very different
41
+ # than what the YAML, JSON, and INI resources create, so using the
42
+ # #value method from JsonConfig (which uses ObjectTraverser.extract_value)
43
+ # doesn't make sense here.
44
+ def value(key)
45
+ @params.map { |x| x[key.first.to_s] }.compact
46
+ end
47
+
31
48
  def to_s
32
49
  "Csv #{@path}"
33
50
  end
@@ -4,6 +4,7 @@
4
4
 
5
5
  require 'utils/parser'
6
6
  require 'utils/filter'
7
+ require 'ipaddr'
7
8
 
8
9
  # TODO: currently we return local ip only
9
10
  # TODO: improve handling of same port on multiple interfaces
@@ -286,10 +287,25 @@ module Inspec::Resources
286
287
  ip6 = /^(\S+):(\d+)$/.match(net_addr)
287
288
  ip6addr = ip6[1]
288
289
  ip6addr = '::' if ip6addr =~ /^:::$/
289
- # build uri
290
- ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
291
- # replace []
292
- host = ip_addr.host[1..ip_addr.host.size-2]
290
+
291
+ # v6 addresses need to end in a double-colon when using
292
+ # shorthand notation. netstat ends with a single colon.
293
+ # IPAddr will fail to properly parse an address unless it
294
+ # uses a double-colon for short-hand notation.
295
+ ip6addr += ':' if ip6addr =~ /\w:$/
296
+
297
+ # Check to see if this is a IPv4 address in a tcp6/udp6 line.
298
+ # If so, don't put brackets around the IP or URI won't know how
299
+ # to properly handle it.
300
+ # example: tcp6 0 0 127.0.0.1:8005 :::* LISTEN
301
+ if IPAddr.new(ip6addr).ipv4?
302
+ ip_addr = URI("addr://#{ip6addr}:#{ip6[2]}")
303
+ host = ip_addr.host
304
+ else
305
+ ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
306
+ # strip []
307
+ host = ip_addr.host[1..ip_addr.host.size-2]
308
+ end
293
309
  else
294
310
  ip_addr = URI('addr://'+net_addr)
295
311
  host = ip_addr.host
@@ -336,7 +336,7 @@ module Inspec::Resources
336
336
  status = inspec.command("#{service_ctl} status #{service_name}")
337
337
 
338
338
  # fallback for systemv services, those are not handled via `initctl`
339
- return SysV.new(inspec).info(service_name) if status.exit_status.to_i != 0
339
+ return SysV.new(inspec).info(service_name) if status.exit_status.to_i != 0 || status.stdout == ''
340
340
 
341
341
  # @see: http://upstart.ubuntu.com/cookbook/#job-states
342
342
  # grep for running to indicate the service is there
@@ -30,18 +30,25 @@ module SourceReaders
30
30
  # @param [FileProvider] target An instance of a FileProvider object that can list files and read them
31
31
  # @param [String] metadata_source eg. inspec.yml or metadata.rb
32
32
  def initialize(target, metadata_source)
33
- @target = target
34
- @metadata = Inspec::Metadata.from_ref(
35
- metadata_source,
36
- @target.read(metadata_source),
37
- nil)
38
-
39
- @tests = load_tests
33
+ @target = target
34
+ @metadata = load_metadata(metadata_source)
35
+ @tests = load_tests
40
36
  @libraries = load_libs
41
37
  end
42
38
 
43
39
  private
44
40
 
41
+ def load_metadata(metadata_source)
42
+ Inspec::Metadata.from_ref(
43
+ metadata_source,
44
+ @target.read(metadata_source),
45
+ nil)
46
+ rescue Psych::SyntaxError => e
47
+ raise "Unable to parse inspec.yml: line #{e.line}, #{e.problem} #{e.context}"
48
+ rescue => e
49
+ raise "Unable to parse #{metadata_source}: #{e.class} -- #{e.message}"
50
+ end
51
+
45
52
  def load_tests
46
53
  tests = @target.files.find_all do |path|
47
54
  path.start_with?('controls') && path.end_with?('.rb')
@@ -6,11 +6,12 @@ module ObjectTraverser
6
6
  key = keys.shift
7
7
  return nil if key.nil? || value.nil?
8
8
 
9
- # if value is an array, iterate over each child
10
9
  if value.is_a?(Array)
11
- value = value.map { |i|
12
- extract_value([key], i)
13
- }
10
+ value = if key.is_a?(Fixnum)
11
+ value[key]
12
+ elsif value.respond_to?(key.to_sym)
13
+ value.send(key.to_sym)
14
+ end
14
15
  else
15
16
  value = value[key.to_s].nil? ? nil : value[key.to_s]
16
17
  end
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.16.1
4
+ version: 1.17.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-03-06 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -205,19 +205,19 @@ dependencies:
205
205
  - !ruby/object:Gem::Version
206
206
  version: '1.9'
207
207
  - !ruby/object:Gem::Dependency
208
- name: rspec_junit_formatter
208
+ name: nokogiri
209
209
  requirement: !ruby/object:Gem::Requirement
210
210
  requirements:
211
211
  - - "~>"
212
212
  - !ruby/object:Gem::Version
213
- version: 0.2.3
213
+ version: '1.6'
214
214
  type: :runtime
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
217
217
  requirements:
218
218
  - - "~>"
219
219
  - !ruby/object:Gem::Version
220
- version: 0.2.3
220
+ version: '1.6'
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: faraday
223
223
  requirement: !ruby/object:Gem::Requirement
@@ -386,9 +386,9 @@ files:
386
386
  - examples/meta-profile/controls/example.rb
387
387
  - examples/meta-profile/inspec.lock
388
388
  - examples/meta-profile/inspec.yml
389
- - examples/meta-profile/vendor/6bdab40a3fe9f9de4e7c87f4f3844fdcf2c5cba6f84089b68d47c72392b51fdc.tar.gz
390
- - examples/meta-profile/vendor/9ad48391d4e6efff0a13d06736c5b075fb021410e0a629e087bc21e9617d957c.tar.gz
389
+ - examples/meta-profile/vendor/74b3437714871cca4505d9fc445c805968d56bc674855112bab187a5166f5a2d.tar.gz
391
390
  - examples/meta-profile/vendor/e25d521fb1093b4c23b31a7dc8f41b5540236f4a433960b151bc427523662ab6.tar.gz
391
+ - examples/meta-profile/vendor/eb00c95846aeb3f1cbc5106537dcbf550c910d65986d21a62f7deb69ea060dee.tar.gz
392
392
  - examples/profile-attribute.yml
393
393
  - examples/profile-attribute/README.md
394
394
  - examples/profile-attribute/controls/example.rb