inspec 0.17.0 → 0.17.1
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 +10 -2
- data/lib/inspec/objects.rb +11 -0
- data/lib/inspec/objects/control.rb +35 -0
- data/lib/inspec/objects/each_loop.rb +32 -0
- data/lib/inspec/objects/list.rb +15 -0
- data/lib/inspec/objects/or_test.rb +22 -0
- data/lib/inspec/objects/ruby_helper.rb +15 -0
- data/lib/inspec/objects/test.rb +78 -0
- data/lib/inspec/objects/value.rb +27 -0
- data/lib/inspec/version.rb +1 -1
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92931c330ebe81c9d87899956cec70d7c395854b
|
4
|
+
data.tar.gz: 93b49fae335d4c153393eca778a0973a46bebb9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e78120e5ec5764f3a9a6ce35db482adf9a8304ba13dac930a181984ace5d5cb4e0b8898e9cf26f17e495a382df1acdfc7ce5f97042a7342302a6c6e5d20a2ca3
|
7
|
+
data.tar.gz: 37bc84c9da07415c800a24af962008098c2b2f8711ac3c1f093ec09f3482a37c4aaa8ff531a52d51f9b9a8377d3485f9b2675c44a7d1bfa29a8d740b60c84130
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.17.
|
4
|
-
[Full Changelog](https://github.com/chef/inspec/compare/v0.
|
3
|
+
## [0.17.1](https://github.com/chef/inspec/tree/0.17.1) (2016-03-31)
|
4
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.17.0...0.17.1)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- add inspec objects \(not exposed by default\) [\#608](https://github.com/chef/inspec/pull/608) ([arlimus](https://github.com/arlimus))
|
9
|
+
|
10
|
+
## [v0.17.0](https://github.com/chef/inspec/tree/v0.17.0) (2016-03-31)
|
11
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.16.4...v0.17.0)
|
5
12
|
|
6
13
|
**Implemented enhancements:**
|
7
14
|
|
@@ -15,6 +22,7 @@
|
|
15
22
|
|
16
23
|
**Merged pull requests:**
|
17
24
|
|
25
|
+
- 0.17.0 [\#604](https://github.com/chef/inspec/pull/604) ([arlimus](https://github.com/arlimus))
|
18
26
|
- add file uid and gid accessors [\#603](https://github.com/chef/inspec/pull/603) ([arlimus](https://github.com/arlimus))
|
19
27
|
- fix errors introduced in \#593 [\#594](https://github.com/chef/inspec/pull/594) ([chris-rock](https://github.com/chris-rock))
|
20
28
|
- Updated documentation and examples to include tags and references [\#593](https://github.com/chef/inspec/pull/593) ([aaronlippold](https://github.com/aaronlippold))
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
autoload :Control, 'inspec/objects/control'
|
5
|
+
autoload :EachLoop, 'inspec/objects/each_loop'
|
6
|
+
autoload :List, 'inspec/objects/list'
|
7
|
+
autoload :OrTest, 'inspec/objects/or_test'
|
8
|
+
autoload :RubyHelper, 'inspec/objects/ruby_helper'
|
9
|
+
autoload :Test, 'inspec/objects/test'
|
10
|
+
autoload :Value, 'inspec/objects/value'
|
11
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
class Control
|
5
|
+
attr_accessor :id, :title, :desc, :impact, :tests
|
6
|
+
def initialize
|
7
|
+
@tests = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_test(t)
|
11
|
+
@tests.push(t)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
{ id: id, title: title, desc: desc, impact: impact, tests: tests.map(&:to_hash) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_ruby
|
19
|
+
res = ["control #{id.inspect} do"]
|
20
|
+
res.push " title #{title.inspect}" unless title.to_s.empty?
|
21
|
+
res.push " desc #{desc.inspect}" unless desc.to_s.empty?
|
22
|
+
res.push " impact #{impact}" unless impact.nil?
|
23
|
+
tests.each { |t| res.push(indent(t.to_ruby, 2)) }
|
24
|
+
res.push 'end'
|
25
|
+
res.join("\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def indent(txt, d)
|
31
|
+
dt = ' '*d
|
32
|
+
dt + txt.gsub("\n", "\n"+dt)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
class EachLoop < List
|
5
|
+
attr_reader :tests
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@tests = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_test(t = nil)
|
12
|
+
t ||= Test.new
|
13
|
+
t.qualifier[0] = ['entry']
|
14
|
+
@tests.push(t)
|
15
|
+
t
|
16
|
+
end
|
17
|
+
|
18
|
+
def negate!
|
19
|
+
@tests.each(&:negate!)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_hash
|
23
|
+
{ qualifier: qualifier, test: @test }
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_ruby
|
27
|
+
obj = super
|
28
|
+
all_tests = @tests.map(&:to_ruby).join("\n")
|
29
|
+
format("%s.each do |entry|\n %s\nend", obj, all_tests)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
class List < Value
|
5
|
+
def map
|
6
|
+
fail 'Inspec::List.map needs to be called with a block' unless block_given?
|
7
|
+
t = List.new
|
8
|
+
t.qualifier = [['x']]
|
9
|
+
yield(t)
|
10
|
+
return if t.qualifier == [['x']]
|
11
|
+
@qualifier.push(['map', "{ |x| #{t.to_ruby} }"])
|
12
|
+
self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
class OrTest
|
5
|
+
def initialize(tests)
|
6
|
+
@tests = tests
|
7
|
+
end
|
8
|
+
|
9
|
+
def skip
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_ruby
|
14
|
+
format("describe.one do\n %s\nend",
|
15
|
+
@tests.map(&:to_ruby).join("\n"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
{ describe_one: @tests.map(&:to_hash) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
module RubyHelper
|
5
|
+
def ruby_qualifier(q)
|
6
|
+
if q.length <= 1
|
7
|
+
q[0]
|
8
|
+
elsif q[0] == 'map' && q.length == 2
|
9
|
+
q[0] + ' ' + q[1]
|
10
|
+
else
|
11
|
+
q[0] + '(' + q[1..-1].map(&:inspect).join(', ') + ')'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
class Test
|
5
|
+
attr_accessor :qualifier, :matcher, :expectation, :skip, :negated, :variables
|
6
|
+
include RubyHelper
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@qualifier = []
|
10
|
+
@negated = false
|
11
|
+
@variables = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def negate!
|
15
|
+
@negated = !@negated
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_ruby
|
19
|
+
return rb_skip if !skip.nil?
|
20
|
+
rb_describe
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_hash
|
24
|
+
{ qualifier: qualifier, matcher: matcher, expectation: expectation, skip: skip, negated: negated }
|
25
|
+
end
|
26
|
+
|
27
|
+
def resource
|
28
|
+
@resource ||=
|
29
|
+
if qualifier.empty? || qualifier[0].empty? || qualifier[0][0].empty?
|
30
|
+
nil
|
31
|
+
else
|
32
|
+
qualifier[0][0]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def remove_expectation
|
37
|
+
remove_instance_variable(:@expectation)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def describe_chain
|
43
|
+
return nil if @qualifier.empty?
|
44
|
+
|
45
|
+
resource = (@qualifier.length > 1) ? @qualifier[0..-2] : [@qualifier[0]]
|
46
|
+
res = resource.map { |q| ruby_qualifier(q) }.join('.')
|
47
|
+
xres = nil
|
48
|
+
|
49
|
+
if @qualifier.length > 1
|
50
|
+
last = @qualifier[-1]
|
51
|
+
if last.length == 1
|
52
|
+
xres = last[0]
|
53
|
+
else
|
54
|
+
res += '.' + ruby_qualifier(last)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
[res, xres]
|
59
|
+
end
|
60
|
+
|
61
|
+
def rb_describe
|
62
|
+
vars = variables.map(&:to_ruby).join("\n")
|
63
|
+
vars += "\n" unless vars.empty?
|
64
|
+
res, xtra = describe_chain
|
65
|
+
itsy = xtra.nil? ? 'it' : 'its(' + xtra.to_sym.inspect + ')'
|
66
|
+
naughty = @negated ? '_not' : ''
|
67
|
+
xpect = defined?(@expectation) ? expectation.inspect : ''
|
68
|
+
format("%sdescribe %s do\n %s { should%s %s %s }\nend",
|
69
|
+
vars, res, itsy, naughty, matcher, xpect)
|
70
|
+
end
|
71
|
+
|
72
|
+
def rb_skip
|
73
|
+
dc = describe_chain
|
74
|
+
obj = dc.nil? ? skip.inspect : dc[0]
|
75
|
+
format("describe %s do\n skip %s\nend", obj, skip.inspect)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
class Value
|
5
|
+
include ::Inspec::RubyHelper
|
6
|
+
|
7
|
+
attr_accessor :qualifier
|
8
|
+
attr_accessor :skip
|
9
|
+
attr_accessor :variable
|
10
|
+
|
11
|
+
def initialize(qualifiers = [])
|
12
|
+
@qualifier = qualifiers
|
13
|
+
@variable = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_ruby
|
17
|
+
res = @variable.nil? ? '' : "#{@variable} = "
|
18
|
+
res + @qualifier.map { |x| ruby_qualifier(x) }.join('.')
|
19
|
+
end
|
20
|
+
|
21
|
+
def name_variable(cache = [])
|
22
|
+
@variable = Array('a'..'z').find { |x| !cache.include?(x) }
|
23
|
+
cache.push(@variable)
|
24
|
+
@variable
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/inspec/version.rb
CHANGED
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.17.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
@@ -246,6 +246,14 @@ files:
|
|
246
246
|
- lib/inspec/fetcher.rb
|
247
247
|
- lib/inspec/log.rb
|
248
248
|
- lib/inspec/metadata.rb
|
249
|
+
- lib/inspec/objects.rb
|
250
|
+
- lib/inspec/objects/control.rb
|
251
|
+
- lib/inspec/objects/each_loop.rb
|
252
|
+
- lib/inspec/objects/list.rb
|
253
|
+
- lib/inspec/objects/or_test.rb
|
254
|
+
- lib/inspec/objects/ruby_helper.rb
|
255
|
+
- lib/inspec/objects/test.rb
|
256
|
+
- lib/inspec/objects/value.rb
|
249
257
|
- lib/inspec/plugins.rb
|
250
258
|
- lib/inspec/plugins/cli.rb
|
251
259
|
- lib/inspec/plugins/fetcher.rb
|