kitchen-inspec 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -9
- data/Berksfile +5 -5
- data/CHANGELOG.md +16 -2
- data/Gemfile +29 -19
- data/Guardfile +3 -3
- data/README.md +30 -22
- data/Rakefile +23 -22
- data/bin/console +3 -3
- data/kitchen-inspec.gemspec +14 -22
- data/lib/kitchen/verifier/inspec.rb +59 -59
- data/lib/kitchen/verifier/inspec_version.rb +1 -1
- metadata +4 -89
- data/.rubocop.yml +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc8423e2234f64b59f405374ed6c60f1af1e91f
|
4
|
+
data.tar.gz: 1fb144b60402be43a6740cb05222837bccc28965
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 367b7d059261f715856d82d25d5637c7e311b5bacaaa8d157de83974b53daebb9751589e3c3cb071fcacad53f03704a2314c2437e2c2d57cecd93bf98a031ed1
|
7
|
+
data.tar.gz: 78fa6b26c0293770b8372f192b94c6e3943b36384b4207b4ada35cbebb93962951915dc52a0f645c8296105ef004c1a626aa2d522664479fbe427aa16a97cc0a
|
data/.travis.yml
CHANGED
@@ -3,23 +3,22 @@ language: ruby
|
|
3
3
|
cache: bundler
|
4
4
|
dist: trusty
|
5
5
|
services:
|
6
|
-
- docker
|
6
|
+
- docker
|
7
7
|
bundler_args: "--without integration guard tools"
|
8
8
|
before_install:
|
9
|
-
- gem install bundler
|
10
|
-
- gem --version
|
9
|
+
- gem install bundler
|
10
|
+
- gem --version
|
11
11
|
matrix:
|
12
12
|
include:
|
13
|
-
- rvm: 1.9
|
14
|
-
- rvm: 2.
|
15
|
-
- rvm: 2.1
|
16
|
-
- rvm: ruby-head
|
17
|
-
- rvm: 2.2
|
13
|
+
- rvm: 2.1.9
|
14
|
+
- rvm: 2.2.5
|
15
|
+
- rvm: 2.3.1
|
18
16
|
bundler_args: "--without guard tools"
|
19
17
|
script: bundle exec rake test:integration OS='default profile contains_inspec'
|
20
|
-
- rvm: 2.
|
18
|
+
- rvm: 2.3.1
|
21
19
|
bundler_args: "--without guard tools"
|
22
20
|
script: bundle exec rake test:integration OS='supermarket'
|
21
|
+
- rvm: ruby-head
|
23
22
|
allow_failures:
|
24
23
|
- rvm: ruby-head
|
25
24
|
deploy:
|
data/Berksfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://supermarket.chef.io"
|
4
4
|
|
5
|
-
cookbook
|
6
|
-
cookbook
|
7
|
-
cookbook
|
8
|
-
cookbook
|
5
|
+
cookbook "apt"
|
6
|
+
cookbook "yum"
|
7
|
+
cookbook "os_prepare", path: "./test/cookbooks/os_prepare"
|
8
|
+
cookbook "ssh-hardening", git: "https://github.com/dev-sec/chef-ssh-hardening.git"
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.15.
|
4
|
-
[Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.
|
3
|
+
## [0.15.1](https://github.com/chef/kitchen-inspec/tree/0.15.1) (2016-09-05)
|
4
|
+
[Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.15.0...0.15.1)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Kitchen verify/test fails when using the command resource with curl [\#100](https://github.com/chef/kitchen-inspec/issues/100)
|
9
|
+
- Default to \( progress | documentation \) format for test-kitchen inspec verifier [\#91](https://github.com/chef/kitchen-inspec/issues/91)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Require Ruby 2.1+ [\#99](https://github.com/chef/kitchen-inspec/pull/99) ([tas50](https://github.com/tas50))
|
14
|
+
- Switch from finstyle / rubocop to chefstyle [\#98](https://github.com/chef/kitchen-inspec/pull/98) ([tas50](https://github.com/tas50))
|
15
|
+
- Update winrm password key for winrm-v2 [\#94](https://github.com/chef/kitchen-inspec/pull/94) ([mwrock](https://github.com/mwrock))
|
16
|
+
|
17
|
+
## [v0.15.0](https://github.com/chef/kitchen-inspec/tree/v0.15.0) (2016-07-15)
|
18
|
+
[Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.14.0...v0.15.0)
|
5
19
|
|
6
20
|
**Fixed bugs:**
|
7
21
|
|
data/Gemfile
CHANGED
@@ -1,33 +1,43 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
source
|
2
|
+
source "https://rubygems.org"
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :guard do
|
6
|
-
gem 'guard-rspec', :require => nil
|
7
|
-
gem 'guard-rubocop', :require => nil
|
8
|
-
end
|
9
|
-
|
10
|
-
group :test do
|
11
|
-
gem 'bundler', '~> 1.5'
|
12
|
-
gem 'minitest', '~> 5.5'
|
13
|
-
gem 'rake', '~> 10'
|
14
|
-
gem 'rubocop', '~> 0.32'
|
15
|
-
gem 'concurrent-ruby', '~> 0.9'
|
16
|
-
gem 'codeclimate-test-reporter', :require => nil
|
17
|
-
end
|
18
|
-
|
19
5
|
# pin dependency for Ruby 1.9.3 since bundler is not
|
20
6
|
# detecting that net-ssh 3 does not work with 1.9.3
|
21
7
|
if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.9.3')
|
22
8
|
gem 'net-ssh', '~> 2.9'
|
23
9
|
end
|
24
10
|
|
11
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
|
12
|
+
gem 'json', '< 2.0'
|
13
|
+
gem 'rack', '< 2.0'
|
14
|
+
gem 'ruby_dep', '< 1.4.0'
|
15
|
+
gem 'listen', '< 3.0.0'
|
16
|
+
end
|
17
|
+
|
18
|
+
group :guard do
|
19
|
+
gem "guard-rspec", :require => nil
|
20
|
+
gem "guard-rubocop", :require => nil
|
21
|
+
end
|
22
|
+
|
23
|
+
group :test do
|
24
|
+
gem "bundler", "~> 1.10"
|
25
|
+
gem "minitest", "~> 5.5"
|
26
|
+
gem "rake", "~> 11.0"
|
27
|
+
gem "chefstyle", "0.4.0"
|
28
|
+
gem "concurrent-ruby", "~> 0.9"
|
29
|
+
gem "codeclimate-test-reporter", :require => nil
|
30
|
+
gem "rspec"
|
31
|
+
gem "simplecov", "~> 0.12"
|
32
|
+
gem "countloc", "~> 0.4"
|
33
|
+
end
|
34
|
+
|
25
35
|
group :integration do
|
26
|
-
gem
|
27
|
-
gem
|
36
|
+
gem "berkshelf", ">= 4.3.5"
|
37
|
+
gem "kitchen-dokken"
|
28
38
|
end
|
29
39
|
|
30
40
|
group :tools do
|
31
|
-
gem
|
32
|
-
gem
|
41
|
+
gem "pry", "~> 0.10"
|
42
|
+
gem "github_changelog_generator", "1.13.1"
|
33
43
|
end
|
data/Guardfile
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
ignore %r{^\.gem/}
|
3
3
|
|
4
4
|
def rspec_opts
|
5
|
-
{ cmd:
|
5
|
+
{ cmd: "bundle exec rspec" }
|
6
6
|
end
|
7
7
|
|
8
8
|
def rubocop_opts
|
9
|
-
{ all_on_start: false, keep_failed: false, cli:
|
9
|
+
{ all_on_start: false, keep_failed: false, cli: "-r chefstyle" }
|
10
10
|
end
|
11
11
|
|
12
12
|
group :red_green_refactor, halt_on_fail: true do
|
13
13
|
guard :rspec, rspec_opts do
|
14
14
|
watch(%r{^spec/(.*)_spec\.rb})
|
15
15
|
watch(%r{^lib/(.*)([^/]+)\.rb}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
16
|
-
watch(%r{^spec/spec_helper\.rb}) {
|
16
|
+
watch(%r{^spec/spec_helper\.rb}) { "spec" }
|
17
17
|
end
|
18
18
|
|
19
19
|
guard :rubocop, rubocop_opts do
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# Kitchen::InSpec - A Test Kitchen Verifier for InSpec
|
2
2
|
|
3
|
+
[![Build Status Master](https://travis-ci.org/chef/kitchen-inspec.svg?branch=master)](https://travis-ci.org/chef/kitchen-inspec) [![Gem Version](https://badge.fury.io/rb/kitchen-inspec.svg)](https://badge.fury.io/rb/kitchen-inspec)
|
4
|
+
|
3
5
|
This is the kitchen driver for [InSpec](https://github.com/chef/inspec). To see the project in action, we have the following test-kitchen examples available:
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
- [Chef and InSpec](https://github.com/chef/inspec/tree/master/examples/kitchen-chef)
|
8
|
+
- [Puppet and InSpec](https://github.com/chef/inspec/tree/master/examples/kitchen-puppet)
|
9
|
+
- [Ansible and InSpec](https://github.com/chef/inspec/tree/master/examples/kitchen-ansible)
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
@@ -16,22 +18,28 @@ gem 'kitchen-inspec'
|
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
19
|
-
|
21
|
+
```shell
|
22
|
+
$ bundle
|
23
|
+
```
|
20
24
|
|
21
25
|
Or install it yourself as:
|
22
26
|
|
23
|
-
|
27
|
+
```shell
|
28
|
+
$ gem install kitchen-inspec
|
29
|
+
```
|
24
30
|
|
25
31
|
## Usage
|
26
32
|
|
27
33
|
In your .kitchen.yml include
|
28
|
-
|
34
|
+
|
35
|
+
```yaml
|
29
36
|
verifier:
|
30
37
|
name: inspec
|
31
38
|
```
|
32
39
|
|
33
40
|
Optionally specify sudo and sudo_command
|
34
|
-
|
41
|
+
|
42
|
+
```yaml
|
35
43
|
verifier:
|
36
44
|
name: inspec
|
37
45
|
sudo: true
|
@@ -49,8 +57,8 @@ By default `kitchen-inspec` expects test to be in `test/integration/%suite%` dir
|
|
49
57
|
├── README.md
|
50
58
|
├── metadata.rb
|
51
59
|
├── recipes
|
52
|
-
│
|
53
|
-
│
|
60
|
+
│ ├── default.rb
|
61
|
+
│ └── nginx.rb
|
54
62
|
└── test
|
55
63
|
└── integration
|
56
64
|
└── default
|
@@ -68,13 +76,13 @@ A complete profile is used here, including a custom inspec resource named `gordo
|
|
68
76
|
├── README.md
|
69
77
|
├── metadata.rb
|
70
78
|
├── recipes
|
71
|
-
│
|
72
|
-
│
|
79
|
+
│ ├── default.rb
|
80
|
+
│ └── nginx.rb
|
73
81
|
└── test
|
74
82
|
└── integration
|
75
83
|
└── default
|
76
84
|
├── controls
|
77
|
-
│
|
85
|
+
│ └── gordon.rb
|
78
86
|
├── inspec.yml
|
79
87
|
└── libraries
|
80
88
|
└── gordon_config.rb
|
@@ -91,8 +99,8 @@ If you need support with other testing frameworks, we recommend to place the tes
|
|
91
99
|
├── README.md
|
92
100
|
├── metadata.rb
|
93
101
|
├── recipes
|
94
|
-
│
|
95
|
-
│
|
102
|
+
│ ├── default.rb
|
103
|
+
│ └── nginx.rb
|
96
104
|
└── test
|
97
105
|
└── integration
|
98
106
|
└── default
|
@@ -104,7 +112,7 @@ If you need support with other testing frameworks, we recommend to place the tes
|
|
104
112
|
|
105
113
|
In case you want to reuse tests across multiple cookbooks, they should become an extra artifact independent of a Chef cookbook, call [InSpec profiles](https://github.com/chef/inspec/blob/master/docs/profiles.rst). Those can be easiliy added to existing local tests as demonstrated in previous sections. To include remote profiles, adapt the `verifier` attributes in `.kitchen.yml`
|
106
114
|
|
107
|
-
```
|
115
|
+
```yaml
|
108
116
|
suites:
|
109
117
|
- name: default
|
110
118
|
verifier:
|
@@ -114,14 +122,14 @@ suites:
|
|
114
122
|
|
115
123
|
`inspec_tests` accepts all values that `inspec exec profile` would expect. We support:
|
116
124
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
125
|
+
- local directory eg. `/path/to/profile`
|
126
|
+
- github url `https://github.com/dev-sec/tests-ssh-hardening`
|
127
|
+
- Chef Supermarket `supermarket://hardening/ssh-hardening` (list all available profiles with `inspec supermarket profiles`)
|
128
|
+
- Chef Compliance `compliance://base/ssh`
|
121
129
|
|
122
130
|
The following example illustrates the usage in a `.kitchen.yml`
|
123
131
|
|
124
|
-
```
|
132
|
+
```yaml
|
125
133
|
suites:
|
126
134
|
- name: contains_inspec
|
127
135
|
run_list:
|
@@ -162,10 +170,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
162
170
|
|
163
171
|
## Contributing
|
164
172
|
|
165
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/chef/kitchen-inspec
|
173
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/chef/kitchen-inspec>.
|
166
174
|
|
167
175
|
## License
|
168
176
|
|
169
|
-
Apache 2.0 (see [LICENSE]
|
177
|
+
Apache 2.0 (see [LICENSE])
|
170
178
|
|
171
179
|
[license]: https://github.com/chef/kitchen-inspec/blob/master/LICENSE
|
data/Rakefile
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rspec/core/rake_task"
|
5
|
-
require
|
5
|
+
require "chefstyle"
|
6
|
+
require "rubocop/rake_task"
|
6
7
|
|
7
8
|
# Specs
|
8
9
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -11,13 +12,13 @@ desc "Run all test suites"
|
|
11
12
|
task :test => [:spec]
|
12
13
|
|
13
14
|
# Rubocop
|
14
|
-
desc
|
15
|
+
desc "Run Rubocop lint checks"
|
15
16
|
task :rubocop do
|
16
17
|
RuboCop::RakeTask.new
|
17
18
|
end
|
18
19
|
|
19
20
|
# lint the project
|
20
|
-
desc
|
21
|
+
desc "Run robocop linter"
|
21
22
|
task lint: [:rubocop]
|
22
23
|
|
23
24
|
desc "Display LOC stats"
|
@@ -36,20 +37,20 @@ task :default => [:test, :quality]
|
|
36
37
|
# Automatically generate a changelog for this project. Only loaded if
|
37
38
|
# the necessary gem is installed.
|
38
39
|
begin
|
39
|
-
require
|
40
|
+
require "github_changelog_generator/task"
|
40
41
|
GitHubChangelogGenerator::RakeTask.new :changelog
|
41
42
|
rescue LoadError
|
42
|
-
puts
|
43
|
+
puts ">>>>> GitHub Changelog Generator not loaded, omitting tasks"
|
43
44
|
end
|
44
45
|
|
45
46
|
# Print the current version of this gem or update it.
|
46
47
|
#
|
47
48
|
# @param [Type] target the new version you want to set, or nil if you only want to show
|
48
49
|
def kitchen_inspec_version(target = nil)
|
49
|
-
path =
|
50
|
-
require_relative path.sub(/.rb$/,
|
50
|
+
path = "lib/kitchen/verifier/inspec_version.rb"
|
51
|
+
require_relative path.sub(/.rb$/, "")
|
51
52
|
|
52
|
-
nu_version = target.nil? ?
|
53
|
+
nu_version = target.nil? ? "" : " -> #{target}"
|
53
54
|
puts "Kitchen-inspec: #{Kitchen::Verifier::INSPEC_VERSION}#{nu_version}"
|
54
55
|
|
55
56
|
unless target.nil?
|
@@ -66,7 +67,7 @@ end
|
|
66
67
|
# @param [Type] msg the message to display if the command is missing
|
67
68
|
def require_command(x, msg = nil)
|
68
69
|
return if system("command -v #{x} || exit 1")
|
69
|
-
msg ||=
|
70
|
+
msg ||= "Please install it first!"
|
70
71
|
puts "\033[31;1mCan't find command #{x.inspect}. #{msg}\033[0m"
|
71
72
|
exit 1
|
72
73
|
end
|
@@ -84,11 +85,11 @@ end
|
|
84
85
|
|
85
86
|
# Check the requirements for running an update of this repository.
|
86
87
|
def check_update_requirements
|
87
|
-
require_command
|
88
|
-
require_command
|
88
|
+
require_command "git"
|
89
|
+
require_command "github_changelog_generator", "\n"\
|
89
90
|
"For more information on how to install it see:\n"\
|
90
91
|
" https://github.com/skywinder/github-changelog-generator\n"
|
91
|
-
require_env
|
92
|
+
require_env "CHANGELOG_GITHUB_TOKEN", "\n"\
|
92
93
|
"Please configure this token to make sure you can run all commands\n"\
|
93
94
|
"against GitHub.\n\n"\
|
94
95
|
"See github_changelog_generator homepage for more information:\n"\
|
@@ -96,33 +97,33 @@ def check_update_requirements
|
|
96
97
|
end
|
97
98
|
|
98
99
|
# Show the current version of this gem.
|
99
|
-
desc
|
100
|
+
desc "Show the version of this gem"
|
100
101
|
task :version do
|
101
102
|
kitchen_inspec_version
|
102
103
|
end
|
103
104
|
|
104
|
-
desc
|
105
|
+
desc "Generate the changelog"
|
105
106
|
task :changelog do
|
106
|
-
require_relative
|
107
|
+
require_relative "lib/kitchen/verifier/inspec_version"
|
107
108
|
system "github_changelog_generator -u chef -p kitchen-inspec --future-release #{Kitchen::Verifier::INSPEC_VERSION}"
|
108
109
|
end
|
109
110
|
|
110
111
|
# Update the version of this gem and create an updated
|
111
112
|
# changelog. It covers everything short of actually releasing
|
112
113
|
# the gem.
|
113
|
-
desc
|
114
|
+
desc "Bump the version of this gem"
|
114
115
|
task :bump_version, [:version] do |_, args|
|
115
|
-
v = args[:version] || ENV[
|
116
|
-
|
116
|
+
v = args[:version] || ENV["to"]
|
117
|
+
raise "You must specify a target version! rake release[1.2.3]" if v.empty?
|
117
118
|
check_update_requirements
|
118
119
|
kitchen_inspec_version(v)
|
119
|
-
Rake::Task[
|
120
|
+
Rake::Task["changelog"].invoke
|
120
121
|
end
|
121
122
|
|
122
123
|
namespace :test do
|
123
124
|
task :integration do
|
124
|
-
concurrency = ENV[
|
125
|
-
os = ENV[
|
126
|
-
sh(
|
125
|
+
concurrency = ENV["CONCURRENCY"] || 1
|
126
|
+
os = ENV["OS"] || ""
|
127
|
+
sh("sh", "-c", "bundle exec kitchen test -c #{concurrency} #{os}")
|
127
128
|
end
|
128
129
|
end
|
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "kitchen/inspec"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require 'kitchen/inspec'
|
|
11
11
|
# require 'pry'
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require "irb"
|
15
15
|
IRB.start
|
data/kitchen-inspec.gemspec
CHANGED
@@ -1,34 +1,26 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "kitchen/verifier/inspec_version"
|
5
|
+
require "English"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "kitchen-inspec"
|
9
9
|
spec.version = Kitchen::Verifier::INSPEC_VERSION
|
10
|
-
spec.license =
|
11
|
-
spec.authors = [
|
12
|
-
spec.email = [
|
10
|
+
spec.license = "Apache-2.0"
|
11
|
+
spec.authors = ["Fletcher Nichol"]
|
12
|
+
spec.email = ["fnichol@chef.io"]
|
13
13
|
|
14
|
-
spec.summary =
|
14
|
+
spec.summary = "A Test Kitchen Verifier for InSpec"
|
15
15
|
spec.description = spec.summary
|
16
|
-
spec.homepage =
|
16
|
+
spec.homepage = "http://github.com/chef/kitchen-inspec"
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
19
19
|
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
-
spec.bindir =
|
20
|
+
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
23
|
-
spec.
|
24
|
-
spec.add_dependency
|
25
|
-
spec.
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1.10'
|
27
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
-
spec.add_development_dependency 'rspec'
|
29
|
-
spec.add_development_dependency 'simplecov', '~> 0.10'
|
30
|
-
# style and complexity libraries are tightly version pinned as newer releases
|
31
|
-
# may introduce new and undesireable style choices which would be immediately
|
32
|
-
# enforced in CI
|
33
|
-
spec.add_development_dependency 'finstyle', '1.5.0'
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
spec.required_ruby_version = ">= 2.1.0"
|
24
|
+
spec.add_dependency "inspec", ">=0.22.0", "<1.0.0"
|
25
|
+
spec.add_dependency "test-kitchen", "~> 1.6"
|
34
26
|
end
|
@@ -17,13 +17,13 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
20
|
+
require "kitchen/transport/ssh"
|
21
|
+
require "kitchen/transport/winrm"
|
22
|
+
require "kitchen/verifier/inspec_version"
|
23
|
+
require "kitchen/verifier/base"
|
24
24
|
|
25
|
-
require
|
26
|
-
require
|
25
|
+
require "uri"
|
26
|
+
require "pathname"
|
27
27
|
|
28
28
|
module Kitchen
|
29
29
|
module Verifier
|
@@ -53,7 +53,7 @@ module Kitchen
|
|
53
53
|
# Unfortunately there is no way to read `test_base_path` from the
|
54
54
|
# .kitchen.yml, it can only be provided on the CLI.
|
55
55
|
# See https://github.com/test-kitchen/test-kitchen/issues/1077
|
56
|
-
inspec_test_dir = File.join(config[:kitchen_root],
|
56
|
+
inspec_test_dir = File.join(config[:kitchen_root], "test", "recipes")
|
57
57
|
if File.directory?(inspec_test_dir)
|
58
58
|
config[:test_base_path] = inspec_test_dir
|
59
59
|
end
|
@@ -63,7 +63,7 @@ module Kitchen
|
|
63
63
|
|
64
64
|
# (see Base#call)
|
65
65
|
def call(state)
|
66
|
-
logger.debug(
|
66
|
+
logger.debug("Initialize InSpec")
|
67
67
|
opts = runner_options(instance.transport, state)
|
68
68
|
runner = ::Inspec::Runner.new(opts)
|
69
69
|
|
@@ -74,25 +74,25 @@ module Kitchen
|
|
74
74
|
logger.debug("Running tests from: #{tests.inspect}")
|
75
75
|
exit_code = runner.run
|
76
76
|
return if exit_code == 0
|
77
|
-
|
77
|
+
raise ActionFailed, "Inspec Runner returns #{exit_code}"
|
78
78
|
end
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
82
|
# (see Base#load_needed_dependencies!)
|
83
83
|
def load_needed_dependencies!
|
84
|
-
require
|
84
|
+
require "inspec"
|
85
85
|
# TODO: this should be easier. I would expect to load a single class here
|
86
86
|
# load supermarket plugin, this is part of the inspec gem
|
87
|
-
require
|
88
|
-
require
|
87
|
+
require "bundles/inspec-supermarket/api"
|
88
|
+
require "bundles/inspec-supermarket/target"
|
89
89
|
|
90
90
|
# load the compliance plugin
|
91
|
-
require
|
92
|
-
require
|
93
|
-
require
|
94
|
-
require
|
95
|
-
require
|
91
|
+
require "bundles/inspec-compliance/configuration"
|
92
|
+
require "bundles/inspec-compliance/support"
|
93
|
+
require "bundles/inspec-compliance/http"
|
94
|
+
require "bundles/inspec-compliance/api"
|
95
|
+
require "bundles/inspec-compliance/target"
|
96
96
|
end
|
97
97
|
|
98
98
|
# Returns an Array of test suite filenames for the related suite currently
|
@@ -111,14 +111,14 @@ module Kitchen
|
|
111
111
|
base = File.join(config[:test_base_path], config[:suite_name])
|
112
112
|
legacy_mode = false
|
113
113
|
# check for testing frameworks, we may need to add more
|
114
|
-
%w{inspec serverspec bats pester rspec cucumber minitest bash}.each
|
114
|
+
%w{inspec serverspec bats pester rspec cucumber minitest bash}.each do |fw|
|
115
115
|
if Pathname.new(File.join(base, fw)).exist?
|
116
116
|
logger.info("Detected alternative framework tests for `#{fw}`")
|
117
117
|
legacy_mode = true
|
118
118
|
end
|
119
|
-
|
119
|
+
end
|
120
120
|
|
121
|
-
base = File.join(base,
|
121
|
+
base = File.join(base, "inspec") if legacy_mode
|
122
122
|
logger.info("Use `#{base}` for testing")
|
123
123
|
|
124
124
|
# only return the directory if it exists
|
@@ -147,13 +147,13 @@ module Kitchen
|
|
147
147
|
elsif defined?(Kitchen::Transport::Dokken) && transport.is_a?(Kitchen::Transport::Dokken)
|
148
148
|
runner_options_for_docker(transport_data)
|
149
149
|
else
|
150
|
-
|
150
|
+
raise Kitchen::UserError, "Verifier #{name} does not support the #{transport.name} Transport"
|
151
151
|
end.tap do |runner_options|
|
152
152
|
# default color to true to match InSpec behavior
|
153
|
-
runner_options[
|
154
|
-
runner_options[
|
155
|
-
runner_options[
|
156
|
-
runner_options[
|
153
|
+
runner_options["color"] = (config[:color].nil? ? true : config[:color])
|
154
|
+
runner_options["format"] = config[:format] unless config[:format].nil?
|
155
|
+
runner_options["output"] = config[:output] unless config[:output].nil?
|
156
|
+
runner_options["profiles_path"] = config[:profiles_path] unless config[:profiles_path].nil?
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -164,26 +164,26 @@ module Kitchen
|
|
164
164
|
def runner_options_for_ssh(config_data)
|
165
165
|
kitchen = instance.transport.send(:connection_options, config_data).dup
|
166
166
|
opts = {
|
167
|
-
|
168
|
-
|
167
|
+
"backend" => "ssh",
|
168
|
+
"logger" => logger,
|
169
169
|
# pass-in sudo config from kitchen verifier
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
170
|
+
"sudo" => config[:sudo],
|
171
|
+
"sudo_command" => config[:sudo_command],
|
172
|
+
"host" => kitchen[:hostname],
|
173
|
+
"port" => kitchen[:port],
|
174
|
+
"user" => kitchen[:username],
|
175
|
+
"keepalive" => kitchen[:keepalive],
|
176
|
+
"keepalive_interval" => kitchen[:keepalive_interval],
|
177
|
+
"connection_timeout" => kitchen[:timeout],
|
178
|
+
"connection_retries" => kitchen[:connection_retries],
|
179
|
+
"connection_retry_sleep" => kitchen[:connection_retry_sleep],
|
180
|
+
"max_wait_until_ready" => kitchen[:max_wait_until_ready],
|
181
|
+
"compression" => kitchen[:compression],
|
182
|
+
"compression_level" => kitchen[:compression_level],
|
183
|
+
"keys_only" => true,
|
184
184
|
}
|
185
|
-
opts[
|
186
|
-
opts[
|
185
|
+
opts["key_files"] = kitchen[:keys] unless kitchen[:keys].nil?
|
186
|
+
opts["password"] = kitchen[:password] unless kitchen[:password].nil?
|
187
187
|
opts
|
188
188
|
end
|
189
189
|
|
@@ -194,15 +194,15 @@ module Kitchen
|
|
194
194
|
def runner_options_for_winrm(config_data)
|
195
195
|
kitchen = instance.transport.send(:connection_options, config_data).dup
|
196
196
|
opts = {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
197
|
+
"backend" => "winrm",
|
198
|
+
"logger" => logger,
|
199
|
+
"host" => URI(kitchen[:endpoint]).hostname,
|
200
|
+
"port" => URI(kitchen[:endpoint]).port,
|
201
|
+
"user" => kitchen[:user],
|
202
|
+
"password" => kitchen[:password] || kitchen[:pass],
|
203
|
+
"connection_retries" => kitchen[:connection_retries],
|
204
|
+
"connection_retry_sleep" => kitchen[:connection_retry_sleep],
|
205
|
+
"max_wait_until_ready" => kitchen[:max_wait_until_ready],
|
206
206
|
}
|
207
207
|
opts
|
208
208
|
end
|
@@ -218,13 +218,13 @@ module Kitchen
|
|
218
218
|
# - config_data[:data_container][:Id] : (hosts chef-client)
|
219
219
|
# - config_data[:runner_container][:Id] : (the kitchen-container)
|
220
220
|
opts = {
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
221
|
+
"backend" => "docker",
|
222
|
+
"logger" => logger,
|
223
|
+
"host" => config_data[:runner_container][:Id],
|
224
|
+
"connection_timeout" => kitchen[:timeout],
|
225
|
+
"connection_retries" => kitchen[:connection_retries],
|
226
|
+
"connection_retry_sleep" => kitchen[:connection_retry_sleep],
|
227
|
+
"max_wait_until_ready" => kitchen[:max_wait_until_ready],
|
228
228
|
}
|
229
229
|
logger.debug "Connect to Container: #{opts['host']}"
|
230
230
|
opts
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-inspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inspec
|
@@ -44,90 +44,6 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.6'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: countloc
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.4'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.4'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: bundler
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.10'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.10'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rake
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '10.0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '10.0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: rspec
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: simplecov
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0.10'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '0.10'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: finstyle
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - '='
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: 1.5.0
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - '='
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: 1.5.0
|
131
47
|
description: A Test Kitchen Verifier for InSpec
|
132
48
|
email:
|
133
49
|
- fnichol@chef.io
|
@@ -138,7 +54,6 @@ files:
|
|
138
54
|
- ".gitignore"
|
139
55
|
- ".kitchen.yml"
|
140
56
|
- ".rspec"
|
141
|
-
- ".rubocop.yml"
|
142
57
|
- ".travis.yml"
|
143
58
|
- Berksfile
|
144
59
|
- CHANGELOG.md
|
@@ -164,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
79
|
requirements:
|
165
80
|
- - ">="
|
166
81
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
82
|
+
version: 2.1.0
|
168
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
84
|
requirements:
|
170
85
|
- - ">="
|
@@ -172,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
87
|
version: '0'
|
173
88
|
requirements: []
|
174
89
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.4.6
|
176
91
|
signing_key:
|
177
92
|
specification_version: 4
|
178
93
|
summary: A Test Kitchen Verifier for InSpec
|
data/.rubocop.yml
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
---
|
2
|
-
AllCops:
|
3
|
-
Exclude:
|
4
|
-
- Gemfile
|
5
|
-
- Rakefile
|
6
|
-
- 'test/**/*'
|
7
|
-
- 'examples/**/*'
|
8
|
-
- 'vendor/**/*'
|
9
|
-
Documentation:
|
10
|
-
Enabled: false
|
11
|
-
AlignParameters:
|
12
|
-
Enabled: true
|
13
|
-
Encoding:
|
14
|
-
Enabled: true
|
15
|
-
HashSyntax:
|
16
|
-
Enabled: true
|
17
|
-
LineLength:
|
18
|
-
Enabled: false
|
19
|
-
EmptyLinesAroundBlockBody:
|
20
|
-
Enabled: false
|
21
|
-
MethodLength:
|
22
|
-
Max: 40
|
23
|
-
NumericLiterals:
|
24
|
-
MinDigits: 10
|
25
|
-
Metrics/CyclomaticComplexity:
|
26
|
-
Max: 10
|
27
|
-
Metrics/PerceivedComplexity:
|
28
|
-
Max: 10
|
29
|
-
Metrics/AbcSize:
|
30
|
-
Max: 33
|
31
|
-
Style/PercentLiteralDelimiters:
|
32
|
-
PreferredDelimiters:
|
33
|
-
'%': '{}'
|
34
|
-
'%i': ()
|
35
|
-
'%q': '{}'
|
36
|
-
'%Q': ()
|
37
|
-
'%r': '{}'
|
38
|
-
'%s': ()
|
39
|
-
'%w': '{}'
|
40
|
-
'%W': ()
|
41
|
-
'%x': ()
|
42
|
-
Style/AlignHash:
|
43
|
-
Enabled: false
|
44
|
-
Style/PredicateName:
|
45
|
-
Enabled: false
|
46
|
-
Style/ClassAndModuleChildren:
|
47
|
-
Enabled: false
|
48
|
-
Style/BracesAroundHashParameters:
|
49
|
-
Enabled: false
|
50
|
-
Style/AndOr:
|
51
|
-
Enabled: false
|
52
|
-
Style/Not:
|
53
|
-
Enabled: false
|
54
|
-
Style/TrailingComma:
|
55
|
-
EnforcedStyleForMultiline: comma
|
56
|
-
Style/NegatedIf:
|
57
|
-
Enabled: false
|
58
|
-
Style/UnlessElse:
|
59
|
-
Enabled: false
|
60
|
-
BlockDelimiters:
|
61
|
-
Enabled: false
|
62
|
-
Style/SpaceAroundOperators:
|
63
|
-
Enabled: false
|
64
|
-
Style/IfUnlessModifier:
|
65
|
-
Enabled: false
|