kitchen-inspec 0.15.2 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53beb1b80e8f4c8becb8d4a858a72e25a98b3f13
4
- data.tar.gz: a1e75646e0f5460d0060916120fb400634d37091
3
+ metadata.gz: 63e838bc0d2ff3a02dc378832b89ca238ef16c75
4
+ data.tar.gz: 931d2ff55d6d41bb3f0145d2c0d776046005007f
5
5
  SHA512:
6
- metadata.gz: 881cbbe5e02aa3dd985bed4090ea6ed100badbe1b1fea15fb5aad706db98ca9b3fda1689dd3fb0299d1c2aafde8fcbe49b9f3347ebef41502a564c111d04e88a
7
- data.tar.gz: c25af29e8f09ae4bde76714563c9d781ee9ccc21ec748d79be51568601a7835b5c165de1867bc25c4a85ec1799e09c07d0323aea57cbc4d82b2f4fffeb8ed5b5
6
+ metadata.gz: 60abb7285e5826d23e811dee7997477199ada4ee2a6fc33d6b6701659fc2483887c5f8cb872c75d570479ede90a4c87354fb70e8a50eeda0ba86b3efb9919fea
7
+ data.tar.gz: 9debf27c7213f623f4a0008c22073442932ed8d21aae7c89c07043ffbc77fbb8ea78c0057a1a29d3d8410c8514b0e0119ba1cc98a6b3f8242a477ea30382ba1c
@@ -29,14 +29,46 @@ suites:
29
29
  - recipe[os_prepare]
30
30
  verifier:
31
31
  inspec_tests:
32
- - https://github.com/nathenharvey/tmp_compliance_profile
32
+ - name: tmp
33
+ git: https://github.com/nathenharvey/tmp_compliance_profile.git
33
34
  - name: supermarket
34
35
  run_list:
35
36
  - recipe[apt]
36
37
  - recipe[ssh-hardening]
37
38
  verifier:
38
39
  inspec_tests:
39
- - supermarket://hardening/ssh-hardening
40
+ - name: hardening/ssh-hardening
41
+ - name: backwards
42
+ run_list:
43
+ - recipe[os_prepare]
44
+ verifier:
45
+ inspec_tests:
46
+ - https://github.com/nathenharvey/tmp_compliance_profile.git
47
+ - name: duplicates
48
+ run_list:
49
+ - recipe[os_prepare]
50
+ verifier:
51
+ inspec_tests:
52
+ - path: ./test/integration/duplicates
53
+ - path: ./test/integration/duplicates
54
+ - name: attributes_inline
55
+ run_list:
56
+ - recipe[os_prepare]
57
+ verifier:
58
+ inspec_tests:
59
+ - path: ./test/integration/attributes
60
+ attributes:
61
+ user: bob
62
+ password: secret
63
+ - name: attributes_file
64
+ run_list:
65
+ - recipe[os_prepare]
66
+ verifier:
67
+ inspec_tests:
68
+ - test/integration/attributes
69
+ # - path: ./test/integration/attributes
70
+ attrs:
71
+ - test/integration/profile-attribute.yml
40
72
  # before you are able to use the compliance plugin, you need to run
41
73
  # insecure is only required if you use self-signed certificates
42
74
  # $ inspec compliance login https://compliance.test --user admin --insecure --token ''
@@ -46,4 +78,5 @@ suites:
46
78
  - recipe[ssh-hardening]
47
79
  verifier:
48
80
  inspec_tests:
49
- - compliance://base/ssh
81
+ - name: ssh
82
+ compliance: base/ssh
@@ -1,4 +1,7 @@
1
1
  sudo: required
2
+ branches:
3
+ only:
4
+ - master
2
5
  language: ruby
3
6
  cache: bundler
4
7
  dist: trusty
@@ -14,16 +17,24 @@ matrix:
14
17
  - rvm: 2.2.5
15
18
  - rvm: 2.3.1
16
19
  bundler_args: "--without guard tools"
17
- script: bundle exec rake test:integration OS='default profile contains_inspec'
20
+ script: bundle exec rake $SUITE
21
+ env: SUITE="test:integration" OS='default profile contains_inspec'
18
22
  - rvm: 2.3.1
19
23
  bundler_args: "--without guard tools"
20
- script: bundle exec rake test:integration OS='supermarket'
24
+ script: bundle exec rake $SUITE
25
+ env: SUITE="test:integration" OS='backwards'
26
+ - rvm: 2.3.1
27
+ bundler_args: "--without guard tools"
28
+ script: bundle exec rake $SUITE
29
+ env: SUITE="test:integration" OS='duplicates'
30
+ - rvm: 2.3.1
31
+ bundler_args: "--without guard tools"
32
+ script: bundle exec rake $SUITE
33
+ env: SUITE="test:integration" OS='supermarket'
34
+ - rvm: 2.3.1
35
+ bundler_args: "--without guard tools"
36
+ script: bundle exec rake $SUITE
37
+ env: SUITE="test:integration" OS='attributes-inline attributes-file'
21
38
  - rvm: ruby-head
22
39
  allow_failures:
23
40
  - rvm: ruby-head
24
- deploy:
25
- provider: rubygems
26
- on:
27
- tags: true
28
- api_key:
29
- secure: lfOpkVSc5+O6mSc1JXEBRuJtNrQm2WxDyClovsV1tfKb54doutDD4fOoogQFUwu3Yq9kujer8KuqZaxzRd/DwQGkTFBGt3KgMEpCUZlRLCD1v81/xnc61DU37PeZMbfdQt0OeioTcyNoBrmjCggu3nmb4dIMZgRMi69qR/OGejz1FVun1d5PmdJ8jckU/wzwttISkHzkAaY55NBEZc8oLA7ekUo+1gnKM4+0YskP6lKg7Wf3r//neTvd0qXG9iHdc1laHnSEevrMrzzcsN4oWn+MXiT7cWB1Xh/MUc4wFCy1CJnw9rmX2YT20994avApJJRu3WVZ+gt0cxVPy7sux1qCG3KcMI0ei6jJuy8akRraYwFt4/CWAZXh41SNMGkvZEQU9J/3sxhCUeS5bGm6IYYWNczFPEgWRXAGOXgFflLE6+NaCT3KtCG3G994aPCFiiz5cc/n9nrsncLsXmL+4MlF+foA2UkT44/VwQTJK1UIBKqXscghR1FzD0It/Y3Gqe+fcKb2Wq77v3dC4IBmWncXDk3LjT36+T4C0hctsaaSjopSc7CyI4HE3MkwqPqJ8PPjlz36/d+42MkNFHE6dd2wPMtWVSfC1AsNf9k79GCSU+f3lYgZK1mjvR3Hx1MZGEfgvJHpZH2S4eOqiV+c9C+PPNUXRaYRyapIa+H4qow=
@@ -1,7 +1,47 @@
1
1
  # Change Log
2
2
 
3
- ## [0.15.2](https://github.com/chef/kitchen-inspec/tree/0.15.2) (2016-09-26)
4
- [Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.15.1...0.15.2)
3
+ ## [0.16.1](https://github.com/chef/kitchen-inspec/tree/0.16.1) (2016-11-11)
4
+ [Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.16.0...0.16.1)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Support InSpec attributes [\#108](https://github.com/chef/kitchen-inspec/issues/108)
9
+
10
+ **Closed issues:**
11
+
12
+ - Incorrect dependencies on 0.16 release [\#117](https://github.com/chef/kitchen-inspec/issues/117)
13
+
14
+ **Merged pull requests:**
15
+
16
+ - fix \#117 [\#118](https://github.com/chef/kitchen-inspec/pull/118) ([chris-rock](https://github.com/chris-rock))
17
+
18
+ ## [v0.16.0](https://github.com/chef/kitchen-inspec/tree/v0.16.0) (2016-11-04)
19
+ [Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.15.2...v0.16.0)
20
+
21
+ **Implemented enhancements:**
22
+
23
+ - Harmonize profile location targets [\#111](https://github.com/chef/kitchen-inspec/issues/111)
24
+ - Add host and port config options [\#110](https://github.com/chef/kitchen-inspec/pull/110) ([alexpop](https://github.com/alexpop))
25
+
26
+ **Fixed bugs:**
27
+
28
+ - Duplicate testing when verifier specified in suite definition [\#109](https://github.com/chef/kitchen-inspec/issues/109)
29
+ - OS detection 2nd time with unknown value? [\#92](https://github.com/chef/kitchen-inspec/issues/92)
30
+
31
+ **Closed issues:**
32
+
33
+ - Message: Could not load the 'inspec' verifier from the load path. Please ensure that your transport is installed as a gem or included in your Gemfile if using Bundler. [\#105](https://github.com/chef/kitchen-inspec/issues/105)
34
+
35
+ **Merged pull requests:**
36
+
37
+ - add attributes support in kitchen-inspec [\#116](https://github.com/chef/kitchen-inspec/pull/116) ([chris-rock](https://github.com/chris-rock))
38
+ - use suite names and only test master branch + PRs [\#115](https://github.com/chef/kitchen-inspec/pull/115) ([chris-rock](https://github.com/chris-rock))
39
+ - fix duplicate testing when unique suite name [\#114](https://github.com/chef/kitchen-inspec/pull/114) ([vjeffrey](https://github.com/vjeffrey))
40
+ - update readme to reflect harmonization of profile location targets [\#113](https://github.com/chef/kitchen-inspec/pull/113) ([vjeffrey](https://github.com/vjeffrey))
41
+ - Make the info message clearer [\#112](https://github.com/chef/kitchen-inspec/pull/112) ([chilicheech](https://github.com/chilicheech))
42
+
43
+ ## [v0.15.2](https://github.com/chef/kitchen-inspec/tree/v0.15.2) (2016-09-26)
44
+ [Full Changelog](https://github.com/chef/kitchen-inspec/compare/v0.15.1...v0.15.2)
5
45
 
6
46
  **Merged pull requests:**
7
47
 
data/README.md CHANGED
@@ -46,6 +46,15 @@ verifier:
46
46
  sudo_command: 'skittles'
47
47
  ```
48
48
 
49
+ You can also specify the host and port to be used by InSpec when targeting the node. Otherwise, it defaults to the hostname and port used by kitchen for converging.
50
+
51
+ ```yaml
52
+ verifier:
53
+ name: inspec
54
+ host: 192.168.56.40
55
+ port: 22
56
+ ```
57
+
49
58
  ### Directory Structure
50
59
 
51
60
  By default `kitchen-inspec` expects test to be in `test/integration/%suite%` directory structure (we use Chef as provisioner here):
@@ -117,15 +126,16 @@ suites:
117
126
  - name: default
118
127
  verifier:
119
128
  inspec_tests:
120
- - https://github.com/dev-sec/tests-ssh-hardening
129
+ - name: ssh-hardening
130
+ url: https://github.com/dev-sec/tests-ssh-hardening
121
131
  ```
122
132
 
123
133
  `inspec_tests` accepts all values that `inspec exec profile` would expect. We support:
124
134
 
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`
135
+ - local directory eg. `path: /path/to/profile`
136
+ - github url `git: https://github.com/dev-sec/tests-ssh-hardening.git`
137
+ - Chef Supermarket `name: hardening/ssh-hardening` # defaults to supermarket (list all available profiles with `inspec supermarket profiles`)
138
+ - Chef Compliance `name: ssh` `compliance: base/ssh`
129
139
 
130
140
  The following example illustrates the usage in a `.kitchen.yml`
131
141
 
@@ -139,8 +149,11 @@ suites:
139
149
  - recipe[os-hardening]
140
150
  verifier:
141
151
  inspec_tests:
142
- - https://github.com/dev-sec/tests-ssh-hardening
143
- - https://github.com/dev-sec/tests-os-hardening
152
+ - path: path/to/some/local/tests
153
+ - name: ssh-hardening
154
+ url: https://github.com/dev-sec/tests-ssh-hardening/archive/master.zip
155
+ - name: os-hardening
156
+ git: https://github.com/dev-sec/tests-os-hardening.git
144
157
  - name: supermarket
145
158
  run_list:
146
159
  - recipe[apt]
@@ -148,7 +161,9 @@ suites:
148
161
  - recipe[ssh-hardening]
149
162
  verifier:
150
163
  inspec_tests:
151
- - supermarket://hardening/ssh-hardening
164
+ - name: hardening/ssh-hardening # name only defaults to supermarket
165
+ - name: ssh-supermarket # alternatively, you can explicitly specify that the profile is from supermarket in this way
166
+ supermarket: hardening/ssh-hardening
152
167
  # before you are able to use the compliance plugin, you need to run
153
168
  # insecure is only required if you use self-signed certificates
154
169
  # $ inspec compliance login https://compliance.test --user admin --insecure --token ''
@@ -159,9 +174,33 @@ suites:
159
174
  - recipe[ssh-hardening]
160
175
  verifier:
161
176
  inspec_tests:
162
- - compliance://base/ssh
177
+ - name: ssh
178
+ compliance: base/ssh
179
+ ```
180
+
181
+ ### Use attributes with your inspec profiles
182
+
183
+ To run a profile with attributes defined inline, you can adapt your `.kitchen.yml`:
184
+
185
+ ```yaml
186
+ verifier:
187
+ inspec_tests:
188
+ - path: test/integration/attributes
189
+ attributes:
190
+ user: bob
191
+ password: secret
163
192
  ```
164
193
 
194
+ You can also define your attributes in an external file. Adapt your `.kitchen.yml` to point to that file:
195
+
196
+ ```yaml
197
+ verifier:
198
+ inspec_tests:
199
+ - path: test/integration/attributes
200
+ attrs:
201
+ - test/integration/profile-attribute.yml
202
+ ```
203
+
165
204
  ## Development
166
205
 
167
206
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
  spec.required_ruby_version = ">= 2.1.0"
24
- spec.add_dependency "inspec", ">=0.22.0", "<2.0.0"
24
+ spec.add_dependency "inspec", ">=0.34.0", "<2.0.0"
25
25
  spec.add_dependency "test-kitchen", "~> 1.6"
26
+ spec.add_dependency "hashie", "~> 3.4"
26
27
  end
@@ -64,7 +64,15 @@ module Kitchen
64
64
  # (see Base#call)
65
65
  def call(state)
66
66
  logger.debug("Initialize InSpec")
67
+
68
+ # gather connection options
67
69
  opts = runner_options(instance.transport, state)
70
+
71
+ # add attributes
72
+ opts[:attrs] = config[:attrs]
73
+ opts[:attributes] = Hashie.stringify_keys config[:attributes] unless config[:attributes].nil?
74
+
75
+ # initialize runner
68
76
  runner = ::Inspec::Runner.new(opts)
69
77
 
70
78
  # add each profile to runner
@@ -119,10 +127,24 @@ module Kitchen
119
127
  end
120
128
 
121
129
  base = File.join(base, "inspec") if legacy_mode
122
- logger.info("Use `#{base}` for testing")
130
+ logger.info("Using `#{base}` for testing")
123
131
 
124
132
  # only return the directory if it exists
125
- Pathname.new(base).exist? ? [base] : []
133
+ Pathname.new(base).exist? ? [{ :path => base }] : []
134
+ end
135
+
136
+ # Takes config[:inspec_tests] and modifies any value with a key of :path by adding the full path
137
+ # @return [Array] array of modified hashes
138
+ # @api private
139
+ def resolve_config_inspec_tests
140
+ config[:inspec_tests].map do |test_hash|
141
+ if test_hash.is_a? Hash
142
+ test_hash = { :path => config[:kitchen_root] + "/" + test_hash[:path] } if test_hash.has_key?(:path)
143
+ test_hash
144
+ else
145
+ test_hash # if it's not a hash, just return it as is
146
+ end
147
+ end
126
148
  end
127
149
 
128
150
  # Returns an array of test profiles
@@ -130,7 +152,7 @@ module Kitchen
130
152
  # @api private
131
153
  def collect_tests
132
154
  # get local tests and get run list of profiles
133
- (local_suite_files + config[:inspec_tests]).compact
155
+ (local_suite_files + resolve_config_inspec_tests).compact.uniq
134
156
  end
135
157
 
136
158
  # Returns a configuration Hash that can be passed to a `Inspec::Runner`.
@@ -169,8 +191,8 @@ module Kitchen
169
191
  # pass-in sudo config from kitchen verifier
170
192
  "sudo" => config[:sudo],
171
193
  "sudo_command" => config[:sudo_command],
172
- "host" => kitchen[:hostname],
173
- "port" => kitchen[:port],
194
+ "host" => config[:host] || kitchen[:hostname],
195
+ "port" => config[:port] || kitchen[:port],
174
196
  "user" => kitchen[:username],
175
197
  "keepalive" => kitchen[:keepalive],
176
198
  "keepalive_interval" => kitchen[:keepalive_interval],
@@ -196,8 +218,8 @@ module Kitchen
196
218
  opts = {
197
219
  "backend" => "winrm",
198
220
  "logger" => logger,
199
- "host" => URI(kitchen[:endpoint]).hostname,
200
- "port" => URI(kitchen[:endpoint]).port,
221
+ "host" => config[:host] || URI(kitchen[:endpoint]).hostname,
222
+ "port" => config[:port] || URI(kitchen[:endpoint]).port,
201
223
  "user" => kitchen[:user],
202
224
  "password" => kitchen[:password] || kitchen[:pass],
203
225
  "connection_retries" => kitchen[:connection_retries],
@@ -20,6 +20,6 @@
20
20
  module Kitchen
21
21
  module Verifier
22
22
  # Version string for InSpec Kitchen verifier
23
- INSPEC_VERSION = "0.15.2"
23
+ INSPEC_VERSION = "0.16.1"
24
24
  end
25
25
  end
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.2
4
+ version: 0.16.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-09-26 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inspec
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.22.0
19
+ version: 0.34.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.22.0
29
+ version: 0.34.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.0.0
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: hashie
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.4'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.4'
47
61
  description: A Test Kitchen Verifier for InSpec
48
62
  email:
49
63
  - fnichol@chef.io