inspec 1.32.1 → 1.33.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2372 -4
- data/Gemfile +0 -1
- data/Rakefile +0 -14
- data/docs/matchers.md +11 -0
- data/inspec.gemspec +1 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +38 -0
- data/lib/resources/docker_container.rb +14 -2
- metadata +6 -12
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
require 'bundler'
|
5
5
|
require 'bundler/gem_tasks'
|
6
6
|
require 'rake/testtask'
|
7
|
-
require_relative 'tasks/changelog'
|
8
7
|
require_relative 'tasks/maintainers'
|
9
8
|
require_relative 'tasks/spdx'
|
10
9
|
|
@@ -138,19 +137,6 @@ task :version do
|
|
138
137
|
inspec_version
|
139
138
|
end
|
140
139
|
|
141
|
-
# Update the version of this gem and create an updated
|
142
|
-
# changelog. It covers everything short of actually releasing
|
143
|
-
# the gem.
|
144
|
-
desc 'Bump the version of this gem'
|
145
|
-
task :bump_version, [:version] do |_, args|
|
146
|
-
v = args[:version] || ENV['to']
|
147
|
-
fail "You must specify a target version! rake bump_version to=1.2.3" if v.empty?
|
148
|
-
check_update_requirements
|
149
|
-
inspec_version(v)
|
150
|
-
Rake::Task['changelog'].invoke
|
151
|
-
Rake::Task['docs:cli'].invoke
|
152
|
-
end
|
153
|
-
|
154
140
|
desc 'Release a new docker image'
|
155
141
|
task :release_docker do
|
156
142
|
version = Inspec::VERSION
|
data/docs/matchers.md
CHANGED
@@ -8,6 +8,7 @@ Inspec uses matchers to help compare resource values to expectations.
|
|
8
8
|
The following matchers are available:
|
9
9
|
|
10
10
|
* `be`
|
11
|
+
* `be_in`
|
11
12
|
* `cmp`
|
12
13
|
* `eq`
|
13
14
|
* `include`
|
@@ -125,6 +126,16 @@ describe passwd do
|
|
125
126
|
end
|
126
127
|
```
|
127
128
|
|
129
|
+
## be_in
|
130
|
+
|
131
|
+
Verifies that an item is included in a list.
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
describe resource do
|
135
|
+
its('item') { should be_in LIST }
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
128
139
|
## match
|
129
140
|
|
130
141
|
Check if a string matches a regular expression.
|
data/inspec.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.required_ruby_version = '>= 2.1'
|
28
28
|
|
29
|
-
spec.add_dependency 'train', '
|
29
|
+
spec.add_dependency 'train', '~> 0.26'
|
30
30
|
spec.add_dependency 'thor', '~> 0.19'
|
31
31
|
spec.add_dependency 'json', '>= 1.8', '< 3.0'
|
32
32
|
spec.add_dependency 'rainbow', '~> 2'
|
data/lib/inspec/version.rb
CHANGED
data/lib/matchers/matchers.rb
CHANGED
@@ -222,6 +222,44 @@ RSpec::Matchers.define :contain do |rule|
|
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
|
+
# `be_in` matcher
|
226
|
+
# You can use it in the following cases:
|
227
|
+
# - check if an item or array is included in a given array
|
228
|
+
# eg:
|
229
|
+
# describe nginx do
|
230
|
+
# its('user') { should be_in AUTHORIZED_USER_LIST }
|
231
|
+
# end
|
232
|
+
# describe nginx do
|
233
|
+
# its('module_list') { should be_in AUTHORIZED_MODULE_LIST }
|
234
|
+
# end
|
235
|
+
RSpec::Matchers.define :be_in do |list|
|
236
|
+
match do |item|
|
237
|
+
# Handle both single item and array
|
238
|
+
item.is_a?(Array) ? (item - list).empty? : list.include?(item)
|
239
|
+
end
|
240
|
+
|
241
|
+
match_when_negated do |item|
|
242
|
+
# Handle both single item and array
|
243
|
+
item.is_a?(Array) ? (item & list).empty? : !list.include?(item)
|
244
|
+
end
|
245
|
+
|
246
|
+
failure_message do |item|
|
247
|
+
if item.is_a?(Array)
|
248
|
+
"expected `#{item}` to be in the list: `#{list}` \nDiff:\n #{(item - list)}"
|
249
|
+
else
|
250
|
+
"expected `#{item}` to be in the list: `#{list}`"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
failure_message_when_negated do |item|
|
255
|
+
if item.is_a?(Array)
|
256
|
+
"expected `#{item}` not to be in the list: `#{list}` \nComm:\n #{(item & list)}"
|
257
|
+
else
|
258
|
+
"expected `#{item}` not to be in the list: `#{list}`"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
225
263
|
# This matcher implements a compare feature that cannot be covered by the default
|
226
264
|
# `eq` matcher
|
227
265
|
# You can use it in the following cases:
|
@@ -74,11 +74,13 @@ module Inspec::Resources
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def repo
|
77
|
-
|
77
|
+
return if image_name_from_image.nil?
|
78
|
+
image_name_from_image.split(':')[0]
|
78
79
|
end
|
79
80
|
|
80
81
|
def tag
|
81
|
-
|
82
|
+
return if image_name_from_image.nil?
|
83
|
+
image_name_from_image.split(':')[1]
|
82
84
|
end
|
83
85
|
|
84
86
|
def to_s
|
@@ -88,6 +90,16 @@ module Inspec::Resources
|
|
88
90
|
|
89
91
|
private
|
90
92
|
|
93
|
+
def image_name_from_image
|
94
|
+
return if image.nil?
|
95
|
+
# possible image names include:
|
96
|
+
# alpine
|
97
|
+
# ubuntu:14.04
|
98
|
+
# repo.example.com:5000/ubuntu
|
99
|
+
# repo.example.com:5000/ubuntu:1404
|
100
|
+
image.include?('/') ? image.split('/')[1] : image
|
101
|
+
end
|
102
|
+
|
91
103
|
def container_info
|
92
104
|
return @info if defined?(@info)
|
93
105
|
opts = @opts
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.33.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: 2017-08-
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.24.0
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '0.26'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.24.0
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '0.26'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: thor
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|