inspec 0.22.1 → 0.23
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 +21 -2
- data/README.md +20 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/os.rb +18 -1
- data/lib/resources/port.rb +61 -72
- data/lib/utils/filter.rb +34 -21
- data/test/helper.rb +1 -1
- data/test/unit/resources/os_test.rb +40 -0
- data/test/unit/resources/port_test.rb +20 -0
- data/test/unit/utils/filter_table_test.rb +20 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8531472157b9bbcf1f5cfae47afb58e26768955d
|
4
|
+
data.tar.gz: e11d0a1081f017dedb9a5c207790d6c599286058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba616285cc0d78bd09a257367933ec1b16ce53c4ef8db770cf5a8a3885ff7fd885589d1b568982bfa0d5fe76d30cacebece6f40622a9e6d66e116759b608b0ad
|
7
|
+
data.tar.gz: 91e3dfc02e260cef1c4d0b518717b40c6068b225748bb8a26f263a709cfd4ea9d60ec5d9e52fcd11e608a31dafe389888ab94cb15ff3838edaef6030693364cd
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.
|
4
|
-
[Full Changelog](https://github.com/chef/inspec/compare/v0.22.
|
3
|
+
## [0.23](https://github.com/chef/inspec/tree/0.23) (2016-05-31)
|
4
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.22.1...0.23)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- connect `port` and filter table [\#776](https://github.com/chef/inspec/pull/776) ([arlimus](https://github.com/arlimus))
|
9
|
+
- add resource to filter table blocks [\#775](https://github.com/chef/inspec/pull/775) ([arlimus](https://github.com/arlimus))
|
10
|
+
- add helper methods for os resource [\#774](https://github.com/chef/inspec/pull/774) ([chris-rock](https://github.com/chris-rock))
|
11
|
+
|
12
|
+
**Closed issues:**
|
13
|
+
|
14
|
+
- inspec hangs on command\('ausearch -k docker'\).stdout [\#768](https://github.com/chef/inspec/issues/768)
|
15
|
+
- registry\_key test failing on Windows 2008 R2 [\#767](https://github.com/chef/inspec/issues/767)
|
16
|
+
- InSpec login successful with wrong username [\#766](https://github.com/chef/inspec/issues/766)
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- update readme with blogs [\#769](https://github.com/chef/inspec/pull/769) ([chris-rock](https://github.com/chris-rock))
|
21
|
+
|
22
|
+
## [v0.22.1](https://github.com/chef/inspec/tree/v0.22.1) (2016-05-18)
|
23
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.22.0...v0.22.1)
|
5
24
|
|
6
25
|
**Fixed bugs:**
|
7
26
|
|
data/README.md
CHANGED
@@ -210,7 +210,26 @@ Which will provide you with:
|
|
210
210
|
|
211
211
|
## Documentation
|
212
212
|
|
213
|
-
Documentation
|
213
|
+
Documentation
|
214
|
+
|
215
|
+
* https://github.com/chef/inspec/tree/master/docs
|
216
|
+
|
217
|
+
Blogs:
|
218
|
+
|
219
|
+
* [The Road to InSpec](https://www.chef.io/blog/2015/11/04/the-road-to-inspec/)
|
220
|
+
* [Introduction to InSpec](http://tfitch.com/automation-tools-bootcamp/inspec.html)
|
221
|
+
* [InSpec Tutorial: Day 1 - Hello World](http://www.anniehedgie.com/inspec-basics-1)
|
222
|
+
* [InSpec Tutorial: Day 2 - Command Resource Blog Logo](http://www.anniehedgie.com/inspec-basics-2)
|
223
|
+
* [InSpec Tutorial: Day 3 - File Resource](http://www.anniehedgie.com/inspec-basics-3)
|
224
|
+
* [InSpec Tutorial: Day 4 - Custom Matchers](http://www.anniehedgie.com/inspec-basics-4)
|
225
|
+
* [Windows infrastructure testing using InSpec – Part I](http://datatomix.com/?p=236)
|
226
|
+
* [Windows infrastructure testing using InSpec and Profiles – Part II](http://datatomix.com/?p=238)
|
227
|
+
* [Testing Ansible with Inspec](http://scienceofficersblog.blogspot.de/2016/02/testing-ansible-with-inspec.html)
|
228
|
+
|
229
|
+
Podcasts:
|
230
|
+
|
231
|
+
* [InSpec Foodfight](http://foodfightshow.org/2016/02/inspec.html)
|
232
|
+
* [Test Driven Infrastructure With Arthur Maltson And Michael Goetz](https://www.arresteddevops.com/tdi/)
|
214
233
|
|
215
234
|
## Share your Profiles
|
216
235
|
|
data/lib/inspec/version.rb
CHANGED
data/lib/resources/os.rb
CHANGED
@@ -7,9 +7,17 @@ module Inspec::Resources
|
|
7
7
|
name 'os'
|
8
8
|
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
|
9
9
|
example "
|
10
|
-
describe os
|
10
|
+
describe os.family do
|
11
11
|
it { should eq 'redhat' }
|
12
12
|
end
|
13
|
+
|
14
|
+
describe os.redhat? do
|
15
|
+
it { should eq true }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe os.linux? do
|
19
|
+
it { should eq true }
|
20
|
+
end
|
13
21
|
"
|
14
22
|
|
15
23
|
# reuse helper methods from backend
|
@@ -25,6 +33,15 @@ module Inspec::Resources
|
|
25
33
|
inspec.backend.os[name]
|
26
34
|
end
|
27
35
|
|
36
|
+
# add helper methods for easy access of properties
|
37
|
+
# allows users to use os.name, os.family, os.release, os.arch
|
38
|
+
%w{name family release arch}.each do |property|
|
39
|
+
define_method(property.to_sym) do
|
40
|
+
inspec.backend.os[property.to_sym]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# helper to collect a hash object easily
|
28
45
|
def params
|
29
46
|
{
|
30
47
|
name: inspec.backend.os[:name],
|
data/lib/resources/port.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# author: Dominik Richter
|
4
4
|
|
5
5
|
require 'utils/parser'
|
6
|
+
require 'utils/filter'
|
7
|
+
|
6
8
|
# Usage:
|
7
9
|
# describe port(80) do
|
8
10
|
# it { should be_listening }
|
@@ -25,11 +27,17 @@ module Inspec::Resources
|
|
25
27
|
it { should be_listening }
|
26
28
|
its('protocols') {should eq ['tcp']}
|
27
29
|
end
|
30
|
+
|
31
|
+
describe port.where { protocol =~ /tcp/ && port > 80 } do
|
32
|
+
it { should_not be_listening }
|
33
|
+
end
|
28
34
|
"
|
29
35
|
|
30
|
-
def initialize(
|
31
|
-
|
32
|
-
@
|
36
|
+
def initialize(*args)
|
37
|
+
args.unshift(nil) if args.length <= 1 # add the ip address to the front
|
38
|
+
@ip = args[0]
|
39
|
+
@port = args[1]
|
40
|
+
|
33
41
|
@port_manager = nil
|
34
42
|
@cache = nil
|
35
43
|
os = inspec.os
|
@@ -53,32 +61,19 @@ module Inspec::Resources
|
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
res = info.map { |x| x[:process] }.uniq.compact
|
67
|
-
res.size > 0 ? res : []
|
68
|
-
end
|
69
|
-
|
70
|
-
def addresses
|
71
|
-
res = info.map { |x| x[:address] }.uniq.compact
|
72
|
-
res.size > 0 ? res : []
|
73
|
-
end
|
74
|
-
|
75
|
-
def pids
|
76
|
-
res = info.map { |x| x[:pid] }.uniq.compact
|
77
|
-
res.size > 0 ? res : []
|
78
|
-
end
|
64
|
+
filter = FilterTable.create
|
65
|
+
filter.add_accessor(:where)
|
66
|
+
.add_accessor(:entries)
|
67
|
+
.add(:ports, field: 'port', style: :simple)
|
68
|
+
.add(:addresses, field: 'address', style: :simple)
|
69
|
+
.add(:protocols, field: 'protocol', style: :simple)
|
70
|
+
.add(:processes, field: 'process', style: :simple)
|
71
|
+
.add(:pids, field: 'pid', style: :simple)
|
72
|
+
.add(:listening?) { |x| x.entries.length > 0 }
|
73
|
+
filter.connect(self, :info)
|
79
74
|
|
80
75
|
def to_s
|
81
|
-
"Port
|
76
|
+
"Port #{@port}"
|
82
77
|
end
|
83
78
|
|
84
79
|
private
|
@@ -88,22 +83,24 @@ module Inspec::Resources
|
|
88
83
|
# abort if os detection has not worked
|
89
84
|
return @cache = [] if @port_manager.nil?
|
90
85
|
# query ports
|
91
|
-
|
92
|
-
|
86
|
+
cache = @port_manager.info || []
|
87
|
+
cache.select! { |x| x['port'] == @port } unless @port.nil?
|
88
|
+
cache.select! { |x| x['address'] == @ip } unless @ip.nil?
|
89
|
+
@cache = cache
|
93
90
|
end
|
94
91
|
end
|
95
92
|
|
96
93
|
# implements an info method and returns all ip adresses and protocols for
|
97
94
|
# each port
|
98
95
|
# [{
|
99
|
-
# port
|
100
|
-
# address
|
101
|
-
# protocol
|
96
|
+
# 'port' => 22,
|
97
|
+
# 'address' => '0.0.0.0'
|
98
|
+
# 'protocol' => 'tcp'
|
102
99
|
# },
|
103
100
|
# {
|
104
|
-
# port
|
105
|
-
# address
|
106
|
-
# protocol
|
101
|
+
# 'port' => 22,
|
102
|
+
# 'address' => '::'
|
103
|
+
# 'protocol' => 'tcp6'
|
107
104
|
# }]
|
108
105
|
class PortsInfo
|
109
106
|
attr_reader :inspec
|
@@ -132,11 +129,9 @@ module Inspec::Resources
|
|
132
129
|
|
133
130
|
ports.map { |x|
|
134
131
|
{
|
135
|
-
port
|
136
|
-
address
|
137
|
-
protocol
|
138
|
-
process: nil,
|
139
|
-
pid: nil,
|
132
|
+
'port' => x['LocalPort'],
|
133
|
+
'address' => x['LocalAddress'],
|
134
|
+
'protocol' => 'tcp',
|
140
135
|
}
|
141
136
|
}
|
142
137
|
end
|
@@ -168,11 +163,11 @@ module Inspec::Resources
|
|
168
163
|
port_ids.each do |port_str|
|
169
164
|
# should not break on ipv6 addresses
|
170
165
|
ipv, proto, port, host = port_str.split(':', 4)
|
171
|
-
ports.push({ port
|
172
|
-
address
|
173
|
-
protocol
|
174
|
-
process
|
175
|
-
pid
|
166
|
+
ports.push({ 'port' => port.to_i,
|
167
|
+
'address' => host,
|
168
|
+
'protocol' => ipv == 'ipv6' ? proto + '6' : proto,
|
169
|
+
'process' => cmd,
|
170
|
+
'pid' => pid.to_i })
|
176
171
|
end
|
177
172
|
end
|
178
173
|
|
@@ -260,7 +255,7 @@ module Inspec::Resources
|
|
260
255
|
port_info = parse_netstat_line(line)
|
261
256
|
|
262
257
|
# only push protocols we are interested in
|
263
|
-
next unless %w{tcp tcp6 udp udp6}.include?(port_info[
|
258
|
+
next unless %w{tcp tcp6 udp udp6}.include?(port_info['protocol'])
|
264
259
|
ports.push(port_info)
|
265
260
|
end
|
266
261
|
ports
|
@@ -310,13 +305,12 @@ module Inspec::Resources
|
|
310
305
|
pid = pid.to_i if pid =~ /^\d+$/
|
311
306
|
process = process[1]
|
312
307
|
|
313
|
-
# map data
|
314
308
|
{
|
315
|
-
port
|
316
|
-
address
|
317
|
-
protocol
|
318
|
-
process
|
319
|
-
pid
|
309
|
+
'port' => port,
|
310
|
+
'address' => host,
|
311
|
+
'protocol' => protocol,
|
312
|
+
'process' => process,
|
313
|
+
'pid' => pid,
|
320
314
|
}
|
321
315
|
end
|
322
316
|
end
|
@@ -333,7 +327,7 @@ module Inspec::Resources
|
|
333
327
|
port_info = parse_sockstat_line(line)
|
334
328
|
|
335
329
|
# push data, if not headerfile
|
336
|
-
next unless %w{tcp tcp6 udp udp6}.include?(port_info[
|
330
|
+
next unless %w{tcp tcp6 udp udp6}.include?(port_info['protocol'])
|
337
331
|
ports.push(port_info)
|
338
332
|
end
|
339
333
|
ports
|
@@ -386,13 +380,12 @@ module Inspec::Resources
|
|
386
380
|
protocol = 'tcp' if protocol.eql?('tcp4')
|
387
381
|
protocol = 'udp' if protocol.eql?('udp4')
|
388
382
|
|
389
|
-
# map data
|
390
383
|
{
|
391
|
-
port
|
392
|
-
address
|
393
|
-
protocol
|
394
|
-
process
|
395
|
-
pid
|
384
|
+
'port' => port,
|
385
|
+
'address' => host,
|
386
|
+
'protocol' => protocol,
|
387
|
+
'process' => process,
|
388
|
+
'pid' => pid,
|
396
389
|
}
|
397
390
|
end
|
398
391
|
end
|
@@ -423,11 +416,9 @@ module Inspec::Resources
|
|
423
416
|
local_addr[local_addr.rindex('.')] = ':'
|
424
417
|
host, port = parse_net_address(local_addr, protocol)
|
425
418
|
{
|
426
|
-
port
|
427
|
-
address
|
428
|
-
protocol
|
429
|
-
process: nil, # we do not have pid on solaris
|
430
|
-
pid: nil, # we do not have pid on solaris
|
419
|
+
'port' => port,
|
420
|
+
'address' => host,
|
421
|
+
'protocol' => protocol,
|
431
422
|
}
|
432
423
|
}
|
433
424
|
ports
|
@@ -447,11 +438,11 @@ module Inspec::Resources
|
|
447
438
|
# parse all lines
|
448
439
|
cmd.each_line do |line|
|
449
440
|
port_info = parse_netstat_line(line)
|
450
|
-
next unless %w{tcp tcp6 udp udp6}.include?(port_info[
|
441
|
+
next unless %w{tcp tcp6 udp udp6}.include?(port_info['protocol'])
|
451
442
|
ports.push(port_info)
|
452
443
|
end
|
453
444
|
# select all ports, where we `listen`
|
454
|
-
ports.select { |val| val if 'listen'.casecmp(val[
|
445
|
+
ports.select { |val| val if 'listen'.casecmp(val['state']) == 0 }
|
455
446
|
end
|
456
447
|
|
457
448
|
def parse_netstat_line(line)
|
@@ -468,12 +459,10 @@ module Inspec::Resources
|
|
468
459
|
host, port = parse_net_address(local_addr, protocol)
|
469
460
|
# map data
|
470
461
|
{
|
471
|
-
port
|
472
|
-
address
|
473
|
-
protocol
|
474
|
-
state
|
475
|
-
process: nil,
|
476
|
-
pid: nil,
|
462
|
+
'port' => port,
|
463
|
+
'address' => host,
|
464
|
+
'protocol' => protocol,
|
465
|
+
'state' => state,
|
477
466
|
}
|
478
467
|
end
|
479
468
|
end
|
data/lib/utils/filter.rb
CHANGED
@@ -40,7 +40,7 @@ module FilterTable
|
|
40
40
|
end
|
41
41
|
|
42
42
|
class Table
|
43
|
-
attr_reader :params
|
43
|
+
attr_reader :params, :resource
|
44
44
|
def initialize(resource, params, filters)
|
45
45
|
@resource = resource
|
46
46
|
@params = params
|
@@ -81,10 +81,10 @@ module FilterTable
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
def
|
84
|
+
def get_field(field)
|
85
85
|
@params.map do |line|
|
86
|
-
|
87
|
-
end
|
86
|
+
line[field]
|
87
|
+
end
|
88
88
|
end
|
89
89
|
|
90
90
|
def to_s
|
@@ -132,17 +132,20 @@ module FilterTable
|
|
132
132
|
end
|
133
133
|
|
134
134
|
class Factory
|
135
|
+
Connector = Struct.new(:field_name, :block, :opts)
|
136
|
+
|
135
137
|
def initialize
|
136
138
|
@accessors = []
|
137
|
-
@
|
138
|
-
@blocks = {}
|
139
|
+
@connectors = {}
|
139
140
|
end
|
140
141
|
|
141
|
-
def connect(resource, table_accessor)
|
142
|
+
def connect(resource, table_accessor)
|
142
143
|
# create the table structure
|
143
|
-
|
144
|
-
|
145
|
-
|
144
|
+
connectors = @connectors
|
145
|
+
struct_fields = connectors.values.map(&:field_name)
|
146
|
+
connector_blocks = connectors.map do |method, c|
|
147
|
+
[method.to_sym, create_connector(c)]
|
148
|
+
end
|
146
149
|
|
147
150
|
# the struct to hold single items from the #entries method
|
148
151
|
entry_struct = Struct.new(*struct_fields.map(&:to_sym)) do
|
@@ -154,13 +157,8 @@ module FilterTable
|
|
154
157
|
|
155
158
|
# the main filter table
|
156
159
|
table = Class.new(Table) {
|
157
|
-
|
158
|
-
|
159
|
-
define_method method.to_sym do |condition = Show, &cond_block|
|
160
|
-
return block.call(self, condition) unless block.nil?
|
161
|
-
return where(nil).get_fields(field_name) if condition == Show && !block_given?
|
162
|
-
where({ field_name => condition }, &cond_block)
|
163
|
-
end
|
160
|
+
connector_blocks.each do |x|
|
161
|
+
define_method x[0], &x[1]
|
164
162
|
end
|
165
163
|
|
166
164
|
define_method :new_entry do |hashmap, filter = ''|
|
@@ -172,7 +170,7 @@ module FilterTable
|
|
172
170
|
}
|
173
171
|
|
174
172
|
# define all access methods with the parent resource
|
175
|
-
accessors = @accessors + @
|
173
|
+
accessors = @accessors + @connectors.keys
|
176
174
|
accessors.each do |method_name|
|
177
175
|
resource.send(:define_method, method_name.to_sym) do |*args, &block|
|
178
176
|
filter = table.new(self, method(table_accessor).call, ' with')
|
@@ -194,11 +192,26 @@ module FilterTable
|
|
194
192
|
throw RuntimeError, "Called filter.add for resource #{@resource} with method name nil!"
|
195
193
|
end
|
196
194
|
|
197
|
-
|
198
|
-
|
199
|
-
@blocks[method_name.to_sym] = block
|
195
|
+
@connectors[method_name.to_sym] =
|
196
|
+
Connector.new(opts[:field] || method_name, block, opts)
|
200
197
|
self
|
201
198
|
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def create_connector(c)
|
203
|
+
return ->(cond = Show) { c.block.call(self, cond) } if !c.block.nil?
|
204
|
+
|
205
|
+
lambda { |condition = Show, &cond_block|
|
206
|
+
if condition == Show && !block_given?
|
207
|
+
r = where(nil).get_field(c.field_name)
|
208
|
+
r = r.flatten.uniq.compact if c.opts[:style] == :simple
|
209
|
+
r
|
210
|
+
else
|
211
|
+
where({ c.field_name => condition }, &cond_block)
|
212
|
+
end
|
213
|
+
}
|
214
|
+
end
|
202
215
|
end
|
203
216
|
|
204
217
|
def self.create
|
data/test/helper.rb
CHANGED
@@ -51,7 +51,7 @@ class MockLoader
|
|
51
51
|
ubuntu1204: { family: 'ubuntu', release: '12.04', arch: 'x86_64' },
|
52
52
|
ubuntu1404: { family: 'ubuntu', release: '14.04', arch: 'x86_64' },
|
53
53
|
ubuntu1504: { family: 'ubuntu', release: '15.04', arch: 'x86_64' },
|
54
|
-
windows: { family: 'windows', release:
|
54
|
+
windows: { family: 'windows', release: '6.2.9200', arch: 'x86_64' },
|
55
55
|
wrlinux: { family: 'wrlinux', release: '7.0(3)I2(2)', arch: 'x86_64' },
|
56
56
|
solaris11: { family: "solaris", release: '11', arch: 'i386'},
|
57
57
|
solaris10: { family: "solaris", release: '10', arch: 'i386'},
|
@@ -0,0 +1,40 @@
|
|
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::Os' do
|
9
|
+
it 'verify os parsing on CentOS' do
|
10
|
+
resource = MockLoader.new(:centos7).load_resource('os')
|
11
|
+
_(resource.name).must_equal nil
|
12
|
+
_(resource.family).must_equal 'redhat'
|
13
|
+
_(resource.release).must_equal '7.1.1503'
|
14
|
+
_(resource.arch).must_equal 'x86_64'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'read env variable on Windows' do
|
18
|
+
resource = MockLoader.new(:windows).load_resource('os')
|
19
|
+
_(resource.name).must_equal nil
|
20
|
+
_(resource.family).must_equal 'windows'
|
21
|
+
_(resource.release).must_equal '6.2.9200'
|
22
|
+
_(resource.arch).must_equal 'x86_64'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'verify os parsing on Debian' do
|
26
|
+
resource = MockLoader.new(:debian8).load_resource('os')
|
27
|
+
_(resource.name).must_equal nil
|
28
|
+
_(resource.family).must_equal 'debian'
|
29
|
+
_(resource.release).must_equal '8'
|
30
|
+
_(resource.arch).must_equal 'x86_64'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'verify os parsing on Ubuntu' do
|
34
|
+
resource = MockLoader.new(:ubuntu1504).load_resource('os')
|
35
|
+
_(resource.name).must_equal nil
|
36
|
+
_(resource.family).must_equal 'ubuntu'
|
37
|
+
_(resource.release).must_equal '15.04'
|
38
|
+
_(resource.arch).must_equal 'x86_64'
|
39
|
+
end
|
40
|
+
end
|
@@ -15,6 +15,26 @@ describe 'Inspec::Resources::Port' do
|
|
15
15
|
_(resource.addresses).must_equal ["0.0.0.0", "::"]
|
16
16
|
end
|
17
17
|
|
18
|
+
it 'lists all ports' do
|
19
|
+
resource = MockLoader.new(:ubuntu1404).load_resource('port')
|
20
|
+
_(resource.entries.length).must_equal 4
|
21
|
+
_(resource.listening?).must_equal true
|
22
|
+
_(resource.protocols).must_equal %w{ tcp tcp6 udp }
|
23
|
+
_(resource.pids).must_equal [1, 2043, 545]
|
24
|
+
_(resource.processes).must_equal ['sshd', 'pidgin', 'rpcbind']
|
25
|
+
_(resource.addresses).must_equal ['0.0.0.0', '::']
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'filter ports by conditions' do
|
29
|
+
resource = MockLoader.new(:ubuntu1404).load_resource('port').where { protocol =~ /udp/i }
|
30
|
+
_(resource.entries.length).must_equal 1
|
31
|
+
_(resource.listening?).must_equal true
|
32
|
+
_(resource.protocols).must_equal ['udp']
|
33
|
+
_(resource.pids).must_equal [545]
|
34
|
+
_(resource.processes).must_equal ['rpcbind']
|
35
|
+
_(resource.addresses).must_equal ['0.0.0.0']
|
36
|
+
end
|
37
|
+
|
18
38
|
it 'verify UDP port on Ubuntu 14.04' do
|
19
39
|
resource = MockLoader.new(:ubuntu1404).load_resource('port', 111)
|
20
40
|
_(resource.listening?).must_equal true
|
@@ -28,6 +28,13 @@ describe FilterTable do
|
|
28
28
|
factory.must_be_kind_of FilterTable::Factory
|
29
29
|
end
|
30
30
|
|
31
|
+
it 'retrieves the resource from all entries' do
|
32
|
+
factory.add_accessor(:where)
|
33
|
+
.add(:baz?) { |x| x.resource }
|
34
|
+
.connect(resource, :data)
|
35
|
+
instance.baz?.must_equal instance
|
36
|
+
end
|
37
|
+
|
31
38
|
describe 'when calling add_accessor' do
|
32
39
|
it 'is chainable' do
|
33
40
|
factory.add_accessor(:sth).must_equal factory
|
@@ -62,6 +69,19 @@ describe FilterTable do
|
|
62
69
|
factory.add(:baz).connect(resource, :data)
|
63
70
|
instance.baz(123).must_be_kind_of(FilterTable::Table)
|
64
71
|
end
|
72
|
+
|
73
|
+
it 'retrieves all entries' do
|
74
|
+
factory.add(:foo).connect(resource, :data)
|
75
|
+
instance.foo.must_equal([3, 2, 2])
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'retrieves entries with simple style' do
|
79
|
+
factory.add(:foo, style: :simple)
|
80
|
+
.add(:num, style: :simple)
|
81
|
+
.connect(resource, :data)
|
82
|
+
instance.foo.must_equal([3, 2])
|
83
|
+
instance.num.must_equal([1, 2])
|
84
|
+
end
|
65
85
|
end
|
66
86
|
|
67
87
|
describe 'when calling entries' do
|
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.
|
4
|
+
version: '0.23'
|
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-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: r-train
|
@@ -591,6 +591,7 @@ files:
|
|
591
591
|
- test/unit/resources/ntp_conf_test.rb
|
592
592
|
- test/unit/resources/oneget_test.rb
|
593
593
|
- test/unit/resources/os_env_test.rb
|
594
|
+
- test/unit/resources/os_test.rb
|
594
595
|
- test/unit/resources/package_test.rb
|
595
596
|
- test/unit/resources/passwd_test.rb
|
596
597
|
- test/unit/resources/pip_test.rb
|
@@ -868,6 +869,7 @@ test_files:
|
|
868
869
|
- test/unit/resources/ntp_conf_test.rb
|
869
870
|
- test/unit/resources/oneget_test.rb
|
870
871
|
- test/unit/resources/os_env_test.rb
|
872
|
+
- test/unit/resources/os_test.rb
|
871
873
|
- test/unit/resources/package_test.rb
|
872
874
|
- test/unit/resources/passwd_test.rb
|
873
875
|
- test/unit/resources/pip_test.rb
|