inspec 0.19.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a7bd506ba6b5577bc33e6a4421be6891fe2bc664
4
- data.tar.gz: dcfde04ac7bc6c6119112d719c2a56a00f324043
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWU1MWE2NmFhMTQ0ODNhZDc2Zjk1YmM2OWNhNzdjNGRhYzBjMzllNA==
5
+ data.tar.gz: !binary |-
6
+ NjI5MGVjN2IzM2U4NDczZjU2NGZmZTQxNDJjNTMzN2M3MDc5YTFjMw==
5
7
  SHA512:
6
- metadata.gz: dca0da99fe77fa5df70d636352b7db12768c566c3eec2d92a16d21c98ab650f642318e681736e9117f005e9322a3cedd9b0a7f28a8aa801ad73d281a4d57567e
7
- data.tar.gz: 47cabf8903b98d634bfb158b64eba3e8750d5e24b3fd7cbe2c3d258daece4cf9b32ce257dfa03833c263e5fb6041273e68b630eae48a19d566daf172b33bf678
8
+ metadata.gz: !binary |-
9
+ N2EzZTRjZjA4ZDJkNTliM2MxNTJhNzNmMGVmODZlMzNkZWNmNWY2YmVkMDhi
10
+ MjBlODgzYzc5Njg3MGVjZmQyZjdjNmU4OGYyMGU2MmRhOGYxM2JlN2FjOGUw
11
+ Yjc1M2UwMjMwNmQ4N2U4YzRlMWUyOGM3Njc4N2VjYjE5NDgxZDg=
12
+ data.tar.gz: !binary |-
13
+ OTZkMDUwZGFmZjUxYmU3ZDlhYzQyNDJjMzQ5Y2I1YzUyZDVmZmZiZWU2NDBi
14
+ YjZmNzBjMGZiYmUxZTc5NjhhMWE4ZmM5NDZjOTk0YjU5ZDdkZTY0ZTdiOTY4
15
+ ZTM1ZGY3Y2EzYzM2ZWI1NDQ0NjAxOTJlMjk3OWU0NDNjOTI2ZWM=
@@ -1,7 +1,29 @@
1
1
  # Change Log
2
2
 
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)
3
+ ## [0.19.2](https://github.com/chef/inspec/tree/0.19.2) (2016-04-21)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.19.1...0.19.2)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Fix indenting for translated loops and ors [\#673](https://github.com/chef/inspec/pull/673) ([alexpop](https://github.com/alexpop))
9
+ - add regexp to cmp matcher [\#667](https://github.com/chef/inspec/pull/667) ([arlimus](https://github.com/arlimus))
10
+ - remodel bash and shell wrappers [\#662](https://github.com/chef/inspec/pull/662) ([arlimus](https://github.com/arlimus))
11
+
12
+ **Fixed bugs:**
13
+
14
+ - bugfix: fix formatting of cmp expectations [\#668](https://github.com/chef/inspec/pull/668) ([arlimus](https://github.com/arlimus))
15
+
16
+ **Closed issues:**
17
+
18
+ - Octal Permissions Match [\#666](https://github.com/chef/inspec/issues/666)
19
+ - file permissions for symlinked files are not checked correctly [\#665](https://github.com/chef/inspec/issues/665)
20
+
21
+ **Merged pull requests:**
22
+
23
+ - release via travis + test via rubygems [\#663](https://github.com/chef/inspec/pull/663) ([arlimus](https://github.com/arlimus))
24
+
25
+ ## [v0.19.1](https://github.com/chef/inspec/tree/v0.19.1) (2016-04-18)
26
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.19.0...v0.19.1)
5
27
 
6
28
  **Implemented enhancements:**
7
29
 
@@ -18,6 +40,7 @@
18
40
 
19
41
  **Merged pull requests:**
20
42
 
43
+ - version bump: 0.19.1 [\#661](https://github.com/chef/inspec/pull/661) ([srenatus](https://github.com/srenatus))
21
44
  - add requirements for gem installation to readme [\#655](https://github.com/chef/inspec/pull/655) ([arlimus](https://github.com/arlimus))
22
45
 
23
46
  ## [v0.19.0](https://github.com/chef/inspec/tree/v0.19.0) (2016-04-17)
data/Gemfile CHANGED
@@ -2,10 +2,6 @@
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
-
9
5
  # pin dependency for Ruby 1.9.3 since bundler is not
10
6
  # detecting that net-ssh 3 does not work with 1.9.3
11
7
  if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.9.3')
@@ -70,6 +70,14 @@ Unlike ``eq``, cmp is a matcher for less-restrictive comparisons. It will try to
70
70
  its('users') { should cmp ['root'] }
71
71
  end
72
72
 
73
+ * Single-value arrays of strings may also be compared to a regex
74
+
75
+ .. code-block:: ruby
76
+
77
+ describe auditd_conf do
78
+ its('log_format') { should cmp /raw/i }
79
+ end
80
+
73
81
  * Improved printing of octal comparisons
74
82
 
75
83
  .. code-block:: ruby
@@ -25,7 +25,7 @@ module Inspec
25
25
 
26
26
  def to_ruby
27
27
  obj = super
28
- all_tests = @tests.map(&:to_ruby).join("\n")
28
+ all_tests = @tests.map(&:to_ruby).join("\n").gsub("\n", "\n ")
29
29
  format("%s.each do |entry|\n %s\nend", obj, all_tests)
30
30
  end
31
31
  end
@@ -11,8 +11,8 @@ module Inspec
11
11
  end
12
12
 
13
13
  def to_ruby
14
- format("describe.one do\n %s\nend",
15
- @tests.map(&:to_ruby).join("\n"))
14
+ all_tests = @tests.map(&:to_ruby).join("\n").gsub("\n", "\n ")
15
+ format("describe.one do\n %s\nend", all_tests)
16
16
  end
17
17
 
18
18
  def to_hash
@@ -54,6 +54,7 @@ require 'resources/apt'
54
54
  require 'resources/audit_policy'
55
55
  require 'resources/auditd_conf'
56
56
  require 'resources/auditd_rules'
57
+ require 'resources/bash'
57
58
  require 'resources/bond'
58
59
  require 'resources/bridge'
59
60
  require 'resources/command'
@@ -3,5 +3,5 @@
3
3
  # author: Christoph Hartmann
4
4
 
5
5
  module Inspec
6
- VERSION = '0.19.1'.freeze
6
+ VERSION = '0.19.2'.freeze
7
7
  end
@@ -240,13 +240,16 @@ RSpec::Matchers.define :cmp do |first_expected|
240
240
  end
241
241
 
242
242
  def octal?(value)
243
+ return false unless value.is_a?(String)
243
244
  !(value =~ /\A0+\d+\Z/).nil?
244
245
  end
245
246
 
246
- def try_match(actual, op, expected) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
247
+ def try_match(actual, op, expected) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
247
248
  # if actual and expected are strings
248
249
  if expected.is_a?(String) && actual.is_a?(String)
249
250
  return actual.casecmp(expected) == 0 if op == :==
251
+ elsif expected.is_a?(Regexp) && (actual.is_a?(String) || actual.is_a?(Integer))
252
+ return !actual.to_s.match(expected).nil?
250
253
  elsif expected.is_a?(String) && integer?(expected) && actual.is_a?(Integer)
251
254
  return actual.method(op).call(expected.to_i)
252
255
  elsif expected.is_a?(Integer) && integer?(actual)
@@ -274,21 +277,27 @@ RSpec::Matchers.define :cmp do |first_expected|
274
277
  try_match(actual, @operation, @expected)
275
278
  end
276
279
 
277
- [:==, :<, :<=, :>=, :>, :===, :=~].each do |op|
280
+ [:==, :'!=', :<, :<=, :>=, :>, :===, :=~].each do |op|
278
281
  chain(op) do |x|
279
282
  @operation = op
280
283
  @expected = x
281
284
  end
282
285
  end
283
286
 
287
+ def format_expectation(negate)
288
+ return 'expected: '+@expected.inspect if @operation == :== && !negate
289
+ negate_str = negate ? 'not ' : ''
290
+ "expected it #{negate_str}to be #{@operation} #{@expected.inspect}"
291
+ end
292
+
284
293
  failure_message do |actual|
285
294
  actual = '0' + actual.to_s(8) if octal?(@expected)
286
- "\nexpected: value #{@operation} #{@expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
295
+ "\n" + format_expectation(false) + "\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
287
296
  end
288
297
 
289
298
  failure_message_when_negated do |actual|
290
299
  actual = '0' + actual.to_s(8) if octal?(@expected)
291
- "\nexpected: value ! #{@operation} #{@expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
300
+ "\n" + format_expectation(true) + "\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
292
301
  end
293
302
  end
294
303
 
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ # author: Dominik Richter
3
+ # author: Christoph Hartmann
4
+
5
+ require 'utils/command_wrapper'
6
+ require 'resources/command'
7
+
8
+ module Inspec::Resources
9
+ class Bash < Cmd
10
+ name 'bash'
11
+ desc 'Run a command or script in BASH.'
12
+ example "
13
+ describe bash('ls -al /') do
14
+ its('stdout') { should match /bin/ }
15
+ its('stderr') { should eq '' }
16
+ its('exit_status') { should eq 0 }
17
+ end
18
+
19
+ # Specify the path of the executable:
20
+ bash('...', path: '/bin/bash')
21
+
22
+ # Specify arguments (defaults to -c)
23
+ bash('...', args: '-x -c')
24
+ "
25
+
26
+ def initialize(command, options = {})
27
+ @raw_command = command
28
+ options[:shell] = 'bash' if options.is_a?(Hash)
29
+ super(CommandWrapper.wrap(command, options))
30
+ end
31
+
32
+ def to_s
33
+ "Bash command #{@raw_command}"
34
+ end
35
+ end
36
+ end
@@ -4,8 +4,6 @@
4
4
  # author: Christoph Hartmann
5
5
  # license: All rights reserved
6
6
 
7
- require 'shellwords'
8
-
9
7
  module Inspec::Resources
10
8
  class Cmd < Inspec.resource(1)
11
9
  name 'command'
@@ -13,31 +11,20 @@ module Inspec::Resources
13
11
  example "
14
12
  describe command('ls -al /') do
15
13
  it { should exist }
16
- its(:stdout) { should match /bin/ }
14
+ its('stdout') { should match /bin/ }
17
15
  its('stderr') { should eq '' }
18
- its(:exit_status) { should eq 0 }
16
+ its('exit_status') { should eq 0 }
19
17
  end
20
18
  "
21
19
 
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
-
28
20
  attr_reader :command
29
21
 
30
- def initialize(cmd, opts = {})
22
+ def initialize(cmd)
31
23
  @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
37
24
  end
38
25
 
39
26
  def result
40
- @result ||= inspec.backend.run_command(wrap_cmd)
27
+ @result ||= inspec.backend.run_command(@command)
41
28
  end
42
29
 
43
30
  def stdout
@@ -72,18 +59,5 @@ module Inspec::Resources
72
59
  def to_s
73
60
  "Command #{@command}"
74
61
  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
88
62
  end
89
63
  end
@@ -17,7 +17,7 @@ module Inspec::Resources
17
17
  it { should be_readable }
18
18
  it { should be_writable }
19
19
  it { should be_owned_by 'root' }
20
- its('mode') { should eq 0644 }
20
+ its('mode') { should cmp '0644' }
21
21
  end
22
22
  "
23
23
  include MountParser
@@ -27,7 +27,7 @@ module Inspec::Resources
27
27
  end
28
28
 
29
29
  describe shadow.users('bin') do
30
- its('password') { should cmp 'x' }
30
+ its('passwords') { should cmp 'x' }
31
31
  its('count') { should eq 1 }
32
32
  end
33
33
  "
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ # author: Dominik Richter
3
+ # author: Christoph Hartmann
4
+
5
+ require 'shellwords'
6
+
7
+ class CommandWrapper
8
+ UNIX_SHELLS = %w{sh bash zsh}.freeze
9
+
10
+ def self.wrap(cmd, options)
11
+ unless options.is_a?(Hash)
12
+ fail 'All options for the command wrapper must be provided as a hash. '\
13
+ "You entered: #{options.inspect}. Please consult the documentation."
14
+ end
15
+
16
+ wrap = options[:wrap]
17
+ if !wrap.nil? && !wrap.is_a?(Proc)
18
+ fail "Called command wrapper with wrap: #{wrap.inspect}. It must be called with a Proc."
19
+ elsif !wrap.nil?
20
+ return wrap.call(cmd)
21
+ end
22
+
23
+ shell = options[:shell]
24
+ unless UNIX_SHELLS.include?(shell)
25
+ fail "Don't know how to wrap commands for shell: #{shell.inspect}."
26
+ end
27
+
28
+ path = options[:path] || shell
29
+ args = options[:args] || '-c'
30
+ path.to_s + ' ' + args + ' ' + Shellwords.escape(cmd)
31
+ end
32
+ end
@@ -35,24 +35,64 @@ if os.linux?
35
35
  it { should cmp len.to_s }
36
36
  end
37
37
 
38
+ describe 122 do
39
+ it { should cmp 122 }
40
+ it { should cmp < 133 }
41
+ it { should cmp > 111 }
42
+ it { should_not cmp < 122 }
43
+ it { should_not cmp > 122 }
44
+ it { should cmp <= 122 }
45
+ it { should cmp >= 122 }
46
+ it { should cmp >= -666 }
47
+ it { should_not cmp <= 111 }
48
+ it { should_not cmp >= 133 }
49
+ it { should cmp /122/ }
50
+ it { should_not cmp /133/ }
51
+ end
52
+
53
+ describe 0o640 do
54
+ it { should cmp 0o640 }
55
+ it { should cmp > 100 }
56
+ it { should_not cmp <= 0 }
57
+ it { should cmp == '416' }
58
+ it { should cmp /416$/ }
59
+ end
60
+
38
61
  describe '12' do
62
+ it { should cmp 12 }
39
63
  it { should cmp < 13 }
40
64
  it { should cmp > 11 }
41
65
  it { should_not cmp < 12 }
42
66
  it { should_not cmp > 12 }
43
67
  it { should cmp <= 12 }
44
68
  it { should cmp >= 12 }
69
+ it { should cmp >= -666 }
45
70
  it { should_not cmp <= 11 }
46
71
  it { should_not cmp >= 13 }
47
72
  end
48
73
 
74
+ describe 'some 123' do
75
+ it { should cmp 'some 123' }
76
+ it { should cmp /^SOME\s\d+(1|2|3)3/i }
77
+ it { should_not cmp /^SOME/ }
78
+ end
79
+
80
+ describe ['some-array'] do
81
+ it { should cmp 'some-array' }
82
+ it { should cmp /.+/ }
83
+ it { should_not cmp /^SOME/ }
84
+ end
85
+
49
86
  describe '' do
50
87
  it { should_not cmp >= 3 }
51
88
  it { should_not cmp < 3 }
89
+ it { should_not cmp /.+/ }
52
90
  end
53
91
 
54
92
  describe nil do
93
+ it { should cmp nil }
55
94
  it { should_not cmp >= 3 }
56
95
  it { should_not cmp < 3 }
96
+ it { should_not cmp /something/ }
57
97
  end
58
98
  end
@@ -0,0 +1,29 @@
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::Bash do
9
+ let(:x) { rand.to_s }
10
+ let(:resource) { load_resource('bash', '$("'+x+'")') }
11
+
12
+ it 'prints as a bash command' do
13
+ resource.to_s.must_equal 'Bash command $("'+x+'")'
14
+ end
15
+
16
+ it 'wraps the command' do
17
+ resource.command.must_equal "bash -c \\$\\(\\\"#{x}\\\"\\)"
18
+ end
19
+
20
+ it 'can specify an executable path' do
21
+ resource = load_resource('bash', '$("'+x+'")', path: '/bin/bash')
22
+ resource.command.must_equal "/bin/bash -c \\$\\(\\\"#{x}\\\"\\)"
23
+ end
24
+
25
+ it 'can specify a arguments' do
26
+ resource = load_resource('bash', '$("'+x+'")', args: '-x -c')
27
+ resource.command.must_equal "bash -x -c \\$\\(\\\"#{x}\\\"\\)"
28
+ end
29
+ end
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.19.2
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-18 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r-train
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
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
26
  version: 0.10.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.19'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.19'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rainbow
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: method_source
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.8'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubyzip
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '3'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec-its
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: '1.2'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: mocha
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
145
  version: '1.1'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
152
  version: '1.1'
153
153
  description: InSpec provides a framework for creating end-to-end infrastructure tests.
@@ -161,7 +161,7 @@ executables:
161
161
  extensions: []
162
162
  extra_rdoc_files: []
163
163
  files:
164
- - ".rubocop.yml"
164
+ - .rubocop.yml
165
165
  - CHANGELOG.md
166
166
  - Gemfile
167
167
  - LICENSE
@@ -278,6 +278,7 @@ files:
278
278
  - lib/resources/audit_policy.rb
279
279
  - lib/resources/auditd_conf.rb
280
280
  - lib/resources/auditd_rules.rb
281
+ - lib/resources/bash.rb
281
282
  - lib/resources/bond.rb
282
283
  - lib/resources/bridge.rb
283
284
  - lib/resources/command.rb
@@ -332,12 +333,12 @@ files:
332
333
  - lib/source_readers/flat.rb
333
334
  - lib/source_readers/inspec.rb
334
335
  - lib/utils/base_cli.rb
336
+ - lib/utils/command_wrapper.rb
335
337
  - lib/utils/convert.rb
336
338
  - lib/utils/detect.rb
337
339
  - lib/utils/filter_array.rb
338
340
  - lib/utils/find_files.rb
339
341
  - lib/utils/hash.rb
340
- - lib/utils/hash_map.rb
341
342
  - lib/utils/json_log.rb
342
343
  - lib/utils/modulator.rb
343
344
  - lib/utils/object_traversal.rb
@@ -523,8 +524,6 @@ files:
523
524
  - test/unit/mock/profiles/legacy-empty-metadata/metadata.rb
524
525
  - test/unit/mock/profiles/legacy-simple-metadata/metadata.rb
525
526
  - test/unit/mock/profiles/legacy-simple-metadata/test/.gitkeep
526
- - test/unit/mock/profiles/resource-tiny/inspec.yml
527
- - test/unit/mock/profiles/resource-tiny/libraries/resource.rb
528
527
  - test/unit/mock/profiles/simple-metadata/inspec.yml
529
528
  - test/unit/mock/profiles/skippy-profile-os/controls/one.rb
530
529
  - test/unit/mock/profiles/skippy-profile-os/inspec.yml
@@ -539,9 +538,9 @@ files:
539
538
  - test/unit/resources/audit_policy_test.rb
540
539
  - test/unit/resources/auditd_conf_test.rb
541
540
  - test/unit/resources/auditd_rules_test.rb
541
+ - test/unit/resources/bash_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
545
544
  - test/unit/resources/csv_test.rb
546
545
  - test/unit/resources/etc_group_test.rb
547
546
  - test/unit/resources/file_test.rb
@@ -587,7 +586,6 @@ files:
587
586
  - test/unit/source_readers/inspec_test.rb
588
587
  - test/unit/utils/filter_array_test.rb
589
588
  - test/unit/utils/find_files_test.rb
590
- - test/unit/utils/hash_map_test.rb
591
589
  - test/unit/utils/passwd_parser_test.rb
592
590
  - test/unit/utils/simpleconfig_test.rb
593
591
  - test/unit/utils/solaris_netstat_parser.rb
@@ -601,17 +599,17 @@ require_paths:
601
599
  - lib
602
600
  required_ruby_version: !ruby/object:Gem::Requirement
603
601
  requirements:
604
- - - ">="
602
+ - - ! '>='
605
603
  - !ruby/object:Gem::Version
606
604
  version: '0'
607
605
  required_rubygems_version: !ruby/object:Gem::Requirement
608
606
  requirements:
609
- - - ">="
607
+ - - ! '>='
610
608
  - !ruby/object:Gem::Version
611
609
  version: '0'
612
610
  requirements: []
613
611
  rubyforge_project:
614
- rubygems_version: 2.5.1
612
+ rubygems_version: 2.4.5
615
613
  signing_key:
616
614
  specification_version: 4
617
615
  summary: Infrastructure and compliance testing.
@@ -794,8 +792,6 @@ test_files:
794
792
  - test/unit/mock/profiles/legacy-empty-metadata/metadata.rb
795
793
  - test/unit/mock/profiles/legacy-simple-metadata/metadata.rb
796
794
  - test/unit/mock/profiles/legacy-simple-metadata/test/.gitkeep
797
- - test/unit/mock/profiles/resource-tiny/inspec.yml
798
- - test/unit/mock/profiles/resource-tiny/libraries/resource.rb
799
795
  - test/unit/mock/profiles/simple-metadata/inspec.yml
800
796
  - test/unit/mock/profiles/skippy-profile-os/controls/one.rb
801
797
  - test/unit/mock/profiles/skippy-profile-os/inspec.yml
@@ -810,9 +806,9 @@ test_files:
810
806
  - test/unit/resources/audit_policy_test.rb
811
807
  - test/unit/resources/auditd_conf_test.rb
812
808
  - test/unit/resources/auditd_rules_test.rb
809
+ - test/unit/resources/bash_test.rb
813
810
  - test/unit/resources/bond_test.rb
814
811
  - test/unit/resources/bridge_test.rb
815
- - test/unit/resources/command_test.rb
816
812
  - test/unit/resources/csv_test.rb
817
813
  - test/unit/resources/etc_group_test.rb
818
814
  - test/unit/resources/file_test.rb
@@ -858,7 +854,6 @@ test_files:
858
854
  - test/unit/source_readers/inspec_test.rb
859
855
  - test/unit/utils/filter_array_test.rb
860
856
  - test/unit/utils/find_files_test.rb
861
- - test/unit/utils/hash_map_test.rb
862
857
  - test/unit/utils/passwd_parser_test.rb
863
858
  - test/unit/utils/simpleconfig_test.rb
864
859
  - test/unit/utils/solaris_netstat_parser.rb
@@ -1,37 +0,0 @@
1
- # encoding: utf-8
2
- # author: Dominik Richter
3
- # author: Christoph Hartmann
4
-
5
- class HashMap
6
- class << self
7
- def [](hash, *keys)
8
- return hash if keys.empty? || hash.nil?
9
- key = keys.shift
10
- if hash.is_a?(Array)
11
- map = hash.map { |i| [i, key] }
12
- else
13
- map = hash[key]
14
- end
15
- [map, *keys]
16
- rescue NoMethodError => _
17
- nil
18
- end
19
- end
20
- end
21
-
22
- class StringMap
23
- class << self
24
- def [](hash, *keys)
25
- return hash if keys.empty? || hash.nil?
26
- key = keys.shift
27
- if hash.is_a?(Array)
28
- map = hash.map { |i| [i, key] }
29
- else
30
- map = hash[key]
31
- end
32
- [map, *keys]
33
- rescue NoMethodError => _
34
- nil
35
- end
36
- end
37
- end
@@ -1,10 +0,0 @@
1
- name: complete
2
- title: complete example profile
3
- maintainer: Chef Software, Inc.
4
- copyright: Chef Software, Inc.
5
- copyright_email: support@chef.io
6
- license: Proprietary, All rights reserved
7
- summary: Testing stub
8
- version: 1.0.0
9
- supports:
10
- - os-family: linux
@@ -1,3 +0,0 @@
1
- class Tiny < Inspec.resource(1)
2
- name 'tiny'
3
- end
@@ -1,35 +0,0 @@
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
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
- # author: Dominik Richter
3
- # author: Christoph Hartmann
4
-
5
- require 'helper'
6
- require 'utils/hash_map'
7
-
8
- describe HashMap do
9
- describe '#get_value' do
10
- it 'returns the source value if no keys are given' do
11
- x = rand
12
- HashMap[x].must_equal x
13
- end
14
-
15
- it 'retrieves a key from a map' do
16
- x = { a: rand }
17
- HashMap[x, :a].must_equal x[:a]
18
- end
19
-
20
- it 'returns nil if the key doesnt exist' do
21
- x = { a: rand }
22
- HashMap[x, :b].must_be :nil?
23
- end
24
-
25
- it 'can extract a nil key' do
26
- x = { nil => rand }
27
- HashMap[x, nil].must_equal x[nil]
28
- end
29
-
30
- it 'extracts multiple keys' do
31
- y = rand
32
- x = { a: { b: { c: y }}}
33
- HashMap[x, :a, :b, :c].must_equal y
34
- end
35
-
36
- it 'returns nil if a key in a list doesnt exist' do
37
- x = { a: { b: { c: rand }}}
38
- HashMap[x, :d, :b, :c].must_be :nil?
39
- end
40
-
41
- it 'retrieves exact keys by string' do
42
- x = { a: rand }
43
- HashMap[x, :a].must_equal x[:a]
44
- HashMap[x, 'a'].must_be :nil?
45
- end
46
-
47
- it 'retrieves exact keys by string' do
48
- x = { 'a' => rand }
49
- HashMap[x, 'a'].must_equal x['a']
50
- HashMap[x, :a].must_be :nil?
51
- end
52
-
53
- it 'con retrieve string keys' do
54
- x = { 'a' => rand }
55
- HashMap.extract_keys(x, ['a'], string_keys: true).must_equal x['a']
56
- HashMap.extract_keys(x, [:a], string_keys: true).must_equal x['a']
57
- end
58
- end
59
-
60
- describe 'as an instance' do
61
-
62
- end
63
- end