inspec 0.21.2 → 0.21.3
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 +4 -4
- data/CHANGELOG.md +14 -2
- data/docs/matchers.rst +0 -64
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +8 -16
- data/lib/resources/os_env.rb +1 -1
- data/lib/resources/port.rb +4 -4
- data/test/helper.rb +1 -1
- data/test/unit/resources/port_test.rb +8 -8
- metadata +1 -3
- data/test/integration/default/matcher.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6b6f3f9425e2fdd338472f8b5ce2f8a8b9d7f68
|
4
|
+
data.tar.gz: 0fbf58b53e5cd374f8078f3e159655d61bda41e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9107c45334fb70cba6cfba959270e698d09482029fda4a596e63f9067e9bccfb58e82e9e4e4555fd77b682eccc08c0d4a35721ff0d220bae97bc58c829b08e16
|
7
|
+
data.tar.gz: 18313760dd162fc7ec7e4876d17e00bb06972f16064e7a3ecc457cbcb01fd2ce70713c3cc707baf201dbd0569a562439748c2de9d54307b47f21619b303489a3
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.21.
|
4
|
-
[Full Changelog](https://github.com/chef/inspec/compare/v0.21.
|
3
|
+
## [0.21.3](https://github.com/chef/inspec/tree/0.21.3) (2016-05-12)
|
4
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.21.2...0.21.3)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- Return empty array instead of nil for port methods [\#739](https://github.com/chef/inspec/pull/739) ([alexpop](https://github.com/alexpop))
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- deprecate array matcher [\#737](https://github.com/chef/inspec/pull/737) ([chris-rock](https://github.com/chris-rock))
|
13
|
+
- Escape os\_env command on Windows to handle env variables containing parentheses. [\#735](https://github.com/chef/inspec/pull/735) ([tpcwang](https://github.com/tpcwang))
|
14
|
+
|
15
|
+
## [v0.21.2](https://github.com/chef/inspec/tree/v0.21.2) (2016-05-11)
|
16
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.21.1...v0.21.2)
|
5
17
|
|
6
18
|
**Implemented enhancements:**
|
7
19
|
|
data/docs/matchers.rst
CHANGED
@@ -10,7 +10,6 @@ Inspec uses matchers to help compare resource values to expectations. The follow
|
|
10
10
|
* `eq`
|
11
11
|
* `include`
|
12
12
|
* `match`
|
13
|
-
* Array matchers: `contain_match`, `all_match`, `none_match`, `contain_duplicates`
|
14
13
|
|
15
14
|
|
16
15
|
be
|
@@ -136,66 +135,3 @@ Check if a string matches a regular expression.
|
|
136
135
|
describe sshd_config do
|
137
136
|
its('Ciphers') { should_not match /cbc/ }
|
138
137
|
end
|
139
|
-
|
140
|
-
|
141
|
-
Array Matchers
|
142
|
-
=====================================================
|
143
|
-
|
144
|
-
The following matchers are designed to work with arrays:
|
145
|
-
|
146
|
-
|
147
|
-
contain_match
|
148
|
-
-----------------------------------------------------
|
149
|
-
|
150
|
-
Check if an array contains at least one item that matches the regex:
|
151
|
-
|
152
|
-
.. code-block:: ruby
|
153
|
-
|
154
|
-
describe ['lemon', 'ginger', 'grapes'] do
|
155
|
-
it { should contain_match /^gin/}
|
156
|
-
end
|
157
|
-
describe port(25) do
|
158
|
-
its('addresses') it { should_not contain_match /0\.0\.0\.0/}
|
159
|
-
end
|
160
|
-
|
161
|
-
|
162
|
-
all_match
|
163
|
-
-----------------------------------------------------
|
164
|
-
|
165
|
-
Check if all items of an array match the regex:
|
166
|
-
|
167
|
-
.. code-block:: ruby
|
168
|
-
|
169
|
-
describe ['grapefruit', 'grapes'] do
|
170
|
-
it { should all_match /^grape.+/}
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
none_match
|
175
|
-
-----------------------------------------------------
|
176
|
-
|
177
|
-
Check if all items of an array match the regex:
|
178
|
-
|
179
|
-
.. code-block:: ruby
|
180
|
-
|
181
|
-
describe ['ginger', 'grapefruit'] do
|
182
|
-
it { should none_match /^sugar$/}
|
183
|
-
end
|
184
|
-
describe port(25) do
|
185
|
-
its('addresses') it { should none_match /^0\.0\.0\.0$/ }
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
contain_duplicates
|
190
|
-
-----------------------------------------------------
|
191
|
-
|
192
|
-
Check if an array contains duplicate items:
|
193
|
-
|
194
|
-
.. code-block:: ruby
|
195
|
-
|
196
|
-
describe [80, 443, 80] do
|
197
|
-
it { should contain_duplicates }
|
198
|
-
end
|
199
|
-
describe ['ginger', 'grapefruit'] do
|
200
|
-
it { should_not contain_duplicates }
|
201
|
-
end
|
data/lib/inspec/version.rb
CHANGED
data/lib/matchers/matchers.rb
CHANGED
@@ -70,34 +70,26 @@ end
|
|
70
70
|
# matcher to check /etc/passwd, /etc/shadow and /etc/group
|
71
71
|
RSpec::Matchers.define :contain_legacy_plus do
|
72
72
|
match do |file|
|
73
|
+
warn '[DEPRECATION] `contain_legacy_plus` is deprecated and will be removed for InSpec 1.0. Please use `describe file(\'/etc/passwd\') do its(\'content\') { should_not match /^\+:/ } end`'
|
73
74
|
file.content =~ /^\+:/
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
77
|
-
# verifies that all entries match the regex
|
78
|
-
RSpec::Matchers.define :all_match do |regex|
|
79
|
-
match do |arr|
|
80
|
-
Array(arr).all? { |element| element.to_s.match(regex) }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# verifies that all entries don't match a regex
|
85
|
-
RSpec::Matchers.define :none_match do |regex|
|
86
|
-
match do |arr|
|
87
|
-
Array(arr).all? { |element| !element.to_s.match(regex) }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
78
|
# verifies that no entry in an array contains a value
|
92
79
|
RSpec::Matchers.define :contain_match do |regex|
|
93
80
|
match do |arr|
|
94
|
-
|
81
|
+
warn '[DEPRECATION] `contain_match` is deprecated and will be removed for InSpec 1.0. See https://github.com/chef/inspec/issues/738 for more details'
|
82
|
+
arr.inject { |result, i|
|
83
|
+
result = i.match(regex)
|
84
|
+
result || i.match(/$/)
|
85
|
+
}
|
95
86
|
end
|
96
87
|
end
|
97
88
|
|
98
89
|
RSpec::Matchers.define :contain_duplicates do
|
99
90
|
match do |arr|
|
100
|
-
|
91
|
+
warn '[DEPRECATION] `contain_duplicates` is deprecated and will be removed for InSpec 1.0. See https://github.com/chef/inspec/issues/738 for more details'
|
92
|
+
dup = arr.select { |element| arr.count(element) > 1 }
|
101
93
|
!dup.uniq.empty?
|
102
94
|
end
|
103
95
|
end
|
data/lib/resources/os_env.rb
CHANGED
data/lib/resources/port.rb
CHANGED
@@ -59,22 +59,22 @@ module Inspec::Resources
|
|
59
59
|
|
60
60
|
def protocols
|
61
61
|
res = info.map { |x| x[:protocol] }.uniq.compact
|
62
|
-
res.size > 0 ? res :
|
62
|
+
res.size > 0 ? res : []
|
63
63
|
end
|
64
64
|
|
65
65
|
def processes
|
66
66
|
res = info.map { |x| x[:process] }.uniq.compact
|
67
|
-
res.size > 0 ? res :
|
67
|
+
res.size > 0 ? res : []
|
68
68
|
end
|
69
69
|
|
70
70
|
def addresses
|
71
71
|
res = info.map { |x| x[:address] }.uniq.compact
|
72
|
-
res.size > 0 ? res :
|
72
|
+
res.size > 0 ? res : []
|
73
73
|
end
|
74
74
|
|
75
75
|
def pids
|
76
76
|
res = info.map { |x| x[:pid] }.uniq.compact
|
77
|
-
res.size > 0 ? res :
|
77
|
+
res.size > 0 ? res : []
|
78
78
|
end
|
79
79
|
|
80
80
|
def to_s
|
data/test/helper.rb
CHANGED
@@ -142,7 +142,7 @@ class MockLoader
|
|
142
142
|
'secedit /export /cfg win_secpol.cfg' => cmd.call('success'),
|
143
143
|
'Remove-Item win_secpol.cfg' => cmd.call('success'),
|
144
144
|
'env' => cmd.call('env'),
|
145
|
-
'$Env:PATH' => cmd.call('$env-PATH'),
|
145
|
+
'${Env:PATH}' => cmd.call('$env-PATH'),
|
146
146
|
# registry key test (winrm 1.6.0, 1.6.1)
|
147
147
|
'2790db1e88204a073ed7fd3493f5445e5ce531afd0d2724a0e36c17110c535e6' => cmd.call('reg_schedule'),
|
148
148
|
'25a1a38fafc289a646d30f7aa966ce0901c267798f47abf2f9440e27d31a5b7d' => cmd.call('reg_schedule'),
|
@@ -36,7 +36,7 @@ describe 'Inspec::Resources::Port' do
|
|
36
36
|
resource = MockLoader.new(:windows).load_resource('port', 135)
|
37
37
|
_(resource.listening?).must_equal true
|
38
38
|
_(resource.protocols).must_equal ['tcp']
|
39
|
-
_(resource.processes).must_equal
|
39
|
+
_(resource.processes).must_equal []
|
40
40
|
_(resource.addresses).must_equal ["::", "192.168.10.157"]
|
41
41
|
end
|
42
42
|
|
@@ -60,10 +60,10 @@ describe 'Inspec::Resources::Port' do
|
|
60
60
|
it 'verify running on undefined' do
|
61
61
|
resource = MockLoader.new(:undefined).load_resource('port', 22)
|
62
62
|
_(resource.listening?).must_equal false
|
63
|
-
_(resource.protocols).must_equal
|
64
|
-
_(resource.pids).must_equal
|
65
|
-
_(resource.processes).must_equal
|
66
|
-
_(resource.addresses).must_equal
|
63
|
+
_(resource.protocols).must_equal []
|
64
|
+
_(resource.pids).must_equal []
|
65
|
+
_(resource.processes).must_equal []
|
66
|
+
_(resource.addresses).must_equal []
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'verify port and interface on Ubuntu 14.04' do
|
@@ -78,7 +78,7 @@ describe 'Inspec::Resources::Port' do
|
|
78
78
|
it 'verify not listening port on interface on Ubuntu 14.04' do
|
79
79
|
resource = MockLoader.new(:ubuntu1404).load_resource('port', '127.0.0.1', 22)
|
80
80
|
_(resource.listening?).must_equal false
|
81
|
-
_(resource.addresses).must_equal
|
81
|
+
_(resource.addresses).must_equal []
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'verify port on Solaris 10' do
|
@@ -103,7 +103,7 @@ describe 'Inspec::Resources::Port' do
|
|
103
103
|
it 'verify not listening port on hpux' do
|
104
104
|
resource = MockLoader.new(:hpux).load_resource('port', 23)
|
105
105
|
_(resource.listening?).must_equal false
|
106
|
-
_(resource.protocols).must_equal
|
107
|
-
_(resource.addresses).must_equal
|
106
|
+
_(resource.protocols).must_equal []
|
107
|
+
_(resource.addresses).must_equal []
|
108
108
|
end
|
109
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.
|
4
|
+
version: 0.21.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
@@ -411,7 +411,6 @@ files:
|
|
411
411
|
- test/integration/default/json_spec.rb
|
412
412
|
- test/integration/default/kernel_module_spec.rb
|
413
413
|
- test/integration/default/kernel_parameter_spec.rb
|
414
|
-
- test/integration/default/matcher.rb
|
415
414
|
- test/integration/default/mount_spec.rb
|
416
415
|
- test/integration/default/os_spec.rb
|
417
416
|
- test/integration/default/package_spec.rb
|
@@ -687,7 +686,6 @@ test_files:
|
|
687
686
|
- test/integration/default/json_spec.rb
|
688
687
|
- test/integration/default/kernel_module_spec.rb
|
689
688
|
- test/integration/default/kernel_parameter_spec.rb
|
690
|
-
- test/integration/default/matcher.rb
|
691
689
|
- test/integration/default/mount_spec.rb
|
692
690
|
- test/integration/default/os_spec.rb
|
693
691
|
- test/integration/default/package_spec.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# 'all_match' matcher tests
|
4
|
-
describe ['ananas', 'apples', 'oranges', 'air', 'alot'] do
|
5
|
-
it { should all_match /[a]./}
|
6
|
-
end
|
7
|
-
describe ['ananas', 'apples', 'oranges', 'melons', 'air'] do
|
8
|
-
it { should_not all_match /[a]./}
|
9
|
-
end
|
10
|
-
describe [true, true, true] do
|
11
|
-
it { should all_match /^true$/}
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
# 'none_match' matcher tests
|
16
|
-
describe ['kiwi', 'avocado', 'grapefruit'] do
|
17
|
-
it { should none_match /xyz/}
|
18
|
-
end
|
19
|
-
describe ['kiwi', 'avocado', 'grapefruit'] do
|
20
|
-
it { should_not none_match /^avo/}
|
21
|
-
end
|
22
|
-
describe 999 do
|
23
|
-
it { should none_match /^666/}
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
# 'contain_match' matcher tests
|
28
|
-
describe ['lemon', 'ginger', 'grapes'] do
|
29
|
-
it { should contain_match /^gin/}
|
30
|
-
end
|
31
|
-
describe ['lemon', 'ginger', 'gra(pes'] do
|
32
|
-
it { should contain_match 'gra\(pe' }
|
33
|
-
end
|
34
|
-
describe ['lemon', 'ginger', 'grapes'] do
|
35
|
-
it { should_not contain_match /^chocolate/}
|
36
|
-
end
|
37
|
-
describe 'kiwi' do
|
38
|
-
it { should contain_match /^kiw/}
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
# 'contain_duplicates' matcher tests
|
43
|
-
describe ['onion', 'carrot', 'onion'] do
|
44
|
-
it { should contain_duplicates }
|
45
|
-
end
|
46
|
-
describe ['onion', 'carrot', 'brocoli'] do
|
47
|
-
it { should_not contain_duplicates }
|
48
|
-
end
|
49
|
-
describe [80, 443] do
|
50
|
-
it { should_not contain_duplicates }
|
51
|
-
end
|