inspec 0.19.0 → 0.19.1

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: 3f8721f5a1366ca4d03be5b1cbfe3b8f61ba315f
4
- data.tar.gz: 68a9c4ce7b72cde464e322d449ce8775f0afa6a8
3
+ metadata.gz: a7bd506ba6b5577bc33e6a4421be6891fe2bc664
4
+ data.tar.gz: dcfde04ac7bc6c6119112d719c2a56a00f324043
5
5
  SHA512:
6
- metadata.gz: 595a34ad34f066fffe31f2ee6799d5692010521949d6dbe57c3d306f391922e7c4ea295f6504156d94b8b835553930623757a2a97e10ce706ae1340ccc40006f
7
- data.tar.gz: d117f5aecbcdce653511e263b1b5c9ae394a354ae38bc5fdb93aa73850d9328d6e7934b3acdb5568e689d0163795134a15aef2e167212920baf6306d6d5e4e24
6
+ metadata.gz: dca0da99fe77fa5df70d636352b7db12768c566c3eec2d92a16d21c98ab650f642318e681736e9117f005e9322a3cedd9b0a7f28a8aa801ad73d281a4d57567e
7
+ data.tar.gz: 47cabf8903b98d634bfb158b64eba3e8750d5e24b3fd7cbe2c3d258daece4cf9b32ce257dfa03833c263e5fb6041273e68b630eae48a19d566daf172b33bf678
data/CHANGELOG.md CHANGED
@@ -1,7 +1,27 @@
1
1
  # Change Log
2
2
 
3
- ## [0.19.0](https://github.com/chef/inspec/tree/0.19.0) (2016-04-17)
4
- [Full Changelog](https://github.com/chef/inspec/compare/v0.18.0...0.19.0)
3
+ ## [0.19.1](https://github.com/chef/inspec/tree/0.19.1) (2016-04-18)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.19.0...0.19.1)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - configure command execution shells to sh/bash/zsh [\#659](https://github.com/chef/inspec/pull/659) ([arlimus](https://github.com/arlimus))
9
+ - be descriptive on shadow.entries [\#657](https://github.com/chef/inspec/pull/657) ([arlimus](https://github.com/arlimus))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - bugfix: print cmp expectations [\#656](https://github.com/chef/inspec/pull/656) ([arlimus](https://github.com/arlimus))
14
+
15
+ **Closed issues:**
16
+
17
+ - gem install failure on RHEL 7.2 Ruby 2.0 [\#653](https://github.com/chef/inspec/issues/653)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - add requirements for gem installation to readme [\#655](https://github.com/chef/inspec/pull/655) ([arlimus](https://github.com/arlimus))
22
+
23
+ ## [v0.19.0](https://github.com/chef/inspec/tree/v0.19.0) (2016-04-17)
24
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.18.0...v0.19.0)
5
25
 
6
26
  **Implemented enhancements:**
7
27
 
data/Gemfile CHANGED
@@ -2,6 +2,10 @@
2
2
  source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
+ group :development do
6
+ gem 'r-train', github: 'chef/train'
7
+ end
8
+
5
9
  # pin dependency for Ruby 1.9.3 since bundler is not
6
10
  # detecting that net-ssh 3 does not work with 1.9.3
7
11
  if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.9.3')
data/README.md CHANGED
@@ -47,6 +47,22 @@ InSpec requires Ruby ( >1.9 ).
47
47
 
48
48
  ### Install it via rubygems.org
49
49
 
50
+ When installing from source, gem dependencies may require ruby build tools to be installed.
51
+
52
+ For CentOS/RedHat/Fedora:
53
+
54
+ ```bash
55
+ yum -y install ruby ruby-devel make gcc
56
+ ```
57
+
58
+ For Ubuntu:
59
+
60
+ ```bash
61
+ apt-get -y install ruby ruby-dev gcc make
62
+ ```
63
+
64
+ To install inspec from [rubygems](https://rubygems.org/):
65
+
50
66
  ```bash
51
67
  gem install inspec
52
68
  ```
data/inspec.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'r-train', '~> 0.10.4'
27
+ spec.add_dependency 'r-train', '~> 0.10.5'
28
28
  spec.add_dependency 'thor', '~> 0.19'
29
29
  spec.add_dependency 'json', '~> 1.8'
30
30
  spec.add_dependency 'rainbow', '~> 2'
@@ -3,5 +3,5 @@
3
3
  # author: Christoph Hartmann
4
4
 
5
5
  module Inspec
6
- VERSION = '0.19.0'.freeze
6
+ VERSION = '0.19.1'.freeze
7
7
  end
@@ -282,13 +282,13 @@ RSpec::Matchers.define :cmp do |first_expected|
282
282
  end
283
283
 
284
284
  failure_message do |actual|
285
- actual = '0' + actual.to_s(8) if octal?(expected)
286
- "\nexpected: value #{@operation} #{expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
285
+ actual = '0' + actual.to_s(8) if octal?(@expected)
286
+ "\nexpected: value #{@operation} #{@expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
287
287
  end
288
288
 
289
289
  failure_message_when_negated do |actual|
290
- actual = '0' + actual.to_s(8) if octal?(expected)
291
- "\nexpected: value ! #{@operation} #{expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
290
+ actual = '0' + actual.to_s(8) if octal?(@expected)
291
+ "\nexpected: value ! #{@operation} #{@expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
292
292
  end
293
293
  end
294
294
 
@@ -4,6 +4,8 @@
4
4
  # author: Christoph Hartmann
5
5
  # license: All rights reserved
6
6
 
7
+ require 'shellwords'
8
+
7
9
  module Inspec::Resources
8
10
  class Cmd < Inspec.resource(1)
9
11
  name 'command'
@@ -17,14 +19,25 @@ module Inspec::Resources
17
19
  end
18
20
  "
19
21
 
22
+ SHELLS = {
23
+ 'sh' => ->(x, path = 'sh') { path + ' -c ' + Shellwords.escape(x) },
24
+ 'bash' => ->(x, path = 'bash') { path + ' -c ' + Shellwords.escape(x) },
25
+ 'zsh' => ->(x, path = 'zsh') { path + ' -c ' + Shellwords.escape(x) },
26
+ }.freeze
27
+
20
28
  attr_reader :command
21
29
 
22
- def initialize(cmd)
30
+ def initialize(cmd, opts = {})
23
31
  @command = cmd
32
+ unless opts.is_a?(Hash)
33
+ skip_resource "Called #{self} with invalid command options. See the resource help for valid examples."
34
+ opts = {}
35
+ end
36
+ @opts = opts
24
37
  end
25
38
 
26
39
  def result
27
- @result ||= inspec.backend.run_command(@command)
40
+ @result ||= inspec.backend.run_command(wrap_cmd)
28
41
  end
29
42
 
30
43
  def stdout
@@ -59,5 +72,18 @@ module Inspec::Resources
59
72
  def to_s
60
73
  "Command #{@command}"
61
74
  end
75
+
76
+ private
77
+
78
+ def wrap_cmd
79
+ shell = @opts[:shell]
80
+ return @command if shell.nil?
81
+
82
+ wrapper = SHELLS[shell]
83
+ # TODO: fail with an error if the command isn't found
84
+ return @command if wrapper.nil?
85
+
86
+ wrapper.call(@command)
87
+ end
62
88
  end
63
89
  end
@@ -67,7 +67,11 @@ module Inspec::Resources
67
67
  end
68
68
 
69
69
  def entries
70
- @lines.map { |line| Shadow.new(@path, content: line, filters: @filters) }
70
+ @lines.map do |line|
71
+ params = parse_shadow_line(line)
72
+ Shadow.new(@path, content: line,
73
+ filters: "#{@filters} on entry user=#{params['user']}")
74
+ end
71
75
  end
72
76
 
73
77
  def users(name = nil)
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ # author: Christoph Hartmann
3
+ # author: Dominik Richter
4
+
5
+ require 'helper'
6
+ require 'inspec/resource'
7
+
8
+ describe Inspec::Resources::Cmd do
9
+ it 'runs regular commands' do
10
+ x = rand.to_s
11
+ load_resource('command', x).method(:wrap_cmd).call
12
+ .must_equal x
13
+ end
14
+
15
+ it 'runs sh commands' do
16
+ x = rand.to_s
17
+ load_resource('command', '$("'+x+'")', {shell: 'sh'})
18
+ .method(:wrap_cmd).call
19
+ .must_equal "sh -c \\$\\(\\\"#{x}\\\"\\)"
20
+ end
21
+
22
+ it 'runs bash commands' do
23
+ x = rand.to_s
24
+ load_resource('command', '$("'+x+'")', {shell: 'bash'})
25
+ .method(:wrap_cmd).call
26
+ .must_equal "bash -c \\$\\(\\\"#{x}\\\"\\)"
27
+ end
28
+
29
+ it 'runs zsh commands' do
30
+ x = rand.to_s
31
+ load_resource('command', '$("'+x+'")', {shell: 'zsh'})
32
+ .method(:wrap_cmd).call
33
+ .must_equal "zsh -c \\$\\(\\\"#{x}\\\"\\)"
34
+ end
35
+ 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: 0.19.0
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-17 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r-train
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.4
19
+ version: 0.10.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.4
26
+ version: 0.10.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -541,6 +541,7 @@ files:
541
541
  - test/unit/resources/auditd_rules_test.rb
542
542
  - test/unit/resources/bond_test.rb
543
543
  - test/unit/resources/bridge_test.rb
544
+ - test/unit/resources/command_test.rb
544
545
  - test/unit/resources/csv_test.rb
545
546
  - test/unit/resources/etc_group_test.rb
546
547
  - test/unit/resources/file_test.rb
@@ -811,6 +812,7 @@ test_files:
811
812
  - test/unit/resources/auditd_rules_test.rb
812
813
  - test/unit/resources/bond_test.rb
813
814
  - test/unit/resources/bridge_test.rb
815
+ - test/unit/resources/command_test.rb
814
816
  - test/unit/resources/csv_test.rb
815
817
  - test/unit/resources/etc_group_test.rb
816
818
  - test/unit/resources/file_test.rb