inspec 0.9.1 → 0.9.2

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: f3f314957d073c6d9b4b319b99d73d9f382a7e4f
4
- data.tar.gz: 661cb6f06494734459b528907a79bcd31c3bfd8b
3
+ metadata.gz: 796b3693c709761d312fc3dfab640ef38db11fd0
4
+ data.tar.gz: 16dc279d4819409321ceb5606b681ed8116b02ee
5
5
  SHA512:
6
- metadata.gz: bf8d732cfb3d8459b5bf5d768bf295ac5f5c0e29f49f5c267b27fdb82b839fce9fbc24ede68b874736009382ff0f4243912ba570d02811af8c1b2b4ce16bd578
7
- data.tar.gz: 444802539e79df6bad242d0604faa7da17c368fa46ff3153c560a71b47d3b2575240b67265a9b62848c423741f751cf831755dc45170db6da973c3d4daa22b3a
6
+ metadata.gz: ed72213ed8506323107724ea42f235349c28e0736ddfe8fbd2b31d62dd4580342b1f1799b8ab08111ef688572b125c157ec24b40c999505aa6ef276ca536de51
7
+ data.tar.gz: 1c75ca6acf92c2bab41f281baec8bb763ff3eba373424da026986bd345d101d84bf6fccf429e51815176e63ee62e683d909039376cd3f233b5ac251b57e88855
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.2
4
+
5
+ * #219 bugfix: fix add_content to make `inspec shell` work again
6
+ * #218 add version to resource declaration
7
+ * #217 specify gemspec files directly (without git)
8
+ * #216 update gemfile grouped dependencies
9
+ * #214 fix legacy `should contain` in docs
10
+ * #213 fix typos in readme
11
+ * #212 add test-kitchen example to readme
12
+ * #208 improved readme
13
+
3
14
  ## 0.8.0
4
15
 
5
16
  * #105 add to_s methods to resources, fixes #98
data/Gemfile CHANGED
@@ -6,16 +6,16 @@ group :test do
6
6
  gem 'bundler', '~> 1.5'
7
7
  gem 'minitest', '~> 5.5'
8
8
  gem 'rake', '~> 10'
9
- gem 'rubocop', '~> 0.33.0'
9
+ gem 'rubocop', '~> 0.32'
10
10
  gem 'simplecov', '~> 0.10'
11
11
  gem 'concurrent-ruby', '~> 0.9'
12
12
  end
13
13
 
14
14
  group :integration do
15
15
  gem 'berkshelf', '~> 4.0'
16
- gem 'test-kitchen', git: 'https://github.com/chris-rock/test-kitchen', branch: 'test-path'
16
+ gem 'test-kitchen'
17
17
  gem 'kitchen-vagrant'
18
- gem 'kitchen-inspec', git: 'git@github.com:chef/kitchen-inspec.git'
18
+ gem 'kitchen-inspec'
19
19
  end
20
20
 
21
21
  group :tools do
data/LICENSE CHANGED
@@ -1,201 +1,14 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ Copyright (c) 2015 Chef Software Inc.
2
+ Copyright (c) 2015 Vulcano Security GmbH.
4
3
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
6
7
 
7
- 1. Definitions.
8
+ http://www.apache.org/licenses/LICENSE-2.0
8
9
 
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
data/README.md CHANGED
@@ -1,16 +1,10 @@
1
- # InSpec
1
+ # InSpec: Inspect Your Infrastructure
2
2
 
3
- ## What is InSpec?
4
-
5
- InSpec is an open-source testing framework for infrastructure with an easy language for specifying compliance, security, and policy requirements. The project name stands for "infrastructure specification" and can be thought of as an abbreviation of "inspect".
6
-
7
- You can use InSpec to examine any node in your infrastructure. The InSpec framework runs locally or remotely on the node being inspected. It uses test rules written in the InSpec language as input. Detected security, compliance, or policy issues are flagged in a log.
8
-
9
- The InSpec project includes many resources that help you write audit rules quickly and easily. Here are some examples.
10
-
11
- * Disallow insecure protocols - In this example, the package and inetd_conf resources ensure that insecure services and protocols, such as telnet, are not used.
3
+ InSpec is open-source testing framework for infrastructure with a human- and machine-readable language for specifying compliance, security and policy requirements.
12
4
 
13
5
  ```ruby
6
+ # Disallow insecure protocols by testing
7
+
14
8
  describe package('telnetd') do
15
9
    it { should_not be_installed }
16
10
  end
@@ -20,54 +14,28 @@ describe inetd_conf do
20
14
  end
21
15
  ```
22
16
 
23
- * Only accept requests on secure ports - This test ensures, that a web server is only listening on well-secured ports.
24
-
25
- ```ruby
26
- describe port(80) do
27
-   it { should_not be_listening }
28
- end
29
-
30
- describe port(443) do
31
-   it { should be_listening }
32
-   its('protocol') {should eq 'tcp'}
33
- end
34
- ```
35
-
36
- * Use approved strong ciphers - This test ensures, that only enterprise-compliant ciphers are used for SSH servers.
17
+ InSpec makes it easy to run your tests wherever you need.
37
18
 
38
- ```ruby
39
- describe sshd_config do
40
-    its('Ciphers') { should eq('chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr') }
41
- end
42
- ```
43
-
44
- * Test your `kitchen.yml` file, to verify that only Vagrant is configured as the driver.
45
-
46
- ```ruby
47
- describe yaml('.kitchen.yml') do
48
- its('driver.name') { should eq('vagrant') }
49
- end
50
- ```
51
-
52
- ## Test your Server, VM, or workstation.
19
+ ```bash
20
+ # run test locally
21
+ inspec exec test.rb
53
22
 
54
- Small example: Write a your checks in `test.rb`:
23
+ # run test on remote host on SSH
24
+ inspec exec test.rb -t ssh://user@hostname
55
25
 
56
- ```ruby
57
- describe file('/proc/cpuinfo') do
58
- it { should be_file }
59
- end
26
+ # run test on remote windows host on WinRM
27
+ inspec exec test.rb -t winrm://Administrator@windowshost --password 'your-password'
60
28
 
61
- describe ssh_config do
62
- its('Protocol') { should eq('2') }
63
- end
29
+ # run test on docker container
30
+ inspec exec test.rb -t docker://container_id
64
31
  ```
65
32
 
66
- Run this file locally:
33
+ # Features
67
34
 
68
- ```bash
69
- inspec exec test.rb
70
- ```
35
+ - Built-in Compliance: Compliance no longer occurs at the end of the release cycle
36
+ - Targeted Tests: InSpec writes tests that specifically target compliance issues
37
+ - Metadata: Includes the metadata required by security and compliance pros
38
+ - Easy Testing: Includes a command-line interface to run tests quickly
71
39
 
72
40
  ## Installation
73
41
 
@@ -93,7 +61,40 @@ You should now be able to run:
93
61
  inspec --help
94
62
  ```
95
63
 
96
- ## Usage
64
+ # Examples
65
+
66
+ * Only accept requests on secure ports - This test ensures that a web server is only listening on well-secured ports.
67
+
68
+ ```ruby
69
+ describe port(80) do
70
+   it { should_not be_listening }
71
+ end
72
+
73
+ describe port(443) do
74
+   it { should be_listening }
75
+   its('protocol') {should eq 'tcp'}
76
+ end
77
+ ```
78
+
79
+ * Use approved strong ciphers - This test ensures that only enterprise-compliant ciphers are used for SSH servers.
80
+
81
+ ```ruby
82
+ describe sshd_config do
83
+    its('Ciphers') { should eq('chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr') }
84
+ end
85
+ ```
86
+
87
+ * Test your `kitchen.yml` file to verify that only Vagrant is configured as the driver.
88
+
89
+ ```ruby
90
+ describe yaml('.kitchen.yml') do
91
+ its('driver.name') { should eq('vagrant') }
92
+ end
93
+ ```
94
+
95
+ Also have a look at our [example](https://github.com/chef/inspec/tree/master/examples/test-kitchen) that uses `inspec` in combination with `test-kitchen`
96
+
97
+ ## Command Line Usage
97
98
 
98
99
  ### exec
99
100
 
@@ -128,15 +129,15 @@ Which will provide you with:
128
129
  {"family":"ubuntu","release":"14.04","arch":null}
129
130
  ```
130
131
 
131
- ## Custom resources
132
+ ## Custom InSpec resources
132
133
 
133
134
  You can easily create your own resources. Here is a custom resource for an
134
- application called Gordon and save it in `gordon_config.rb`:
135
+ application called Gordon. It is saved as `gordon_config.rb`.
135
136
 
136
137
  ```ruby
137
138
  require 'yaml'
138
139
 
139
- class GordonConfig < Inspec.resource
140
+ class GordonConfig < Inspec.resource(1)
140
141
  name 'gordon_config'
141
142
 
142
143
  def initialize
@@ -165,7 +166,25 @@ describe gordon_config do
165
166
  end
166
167
  ```
167
168
 
168
- ## Tests
169
+ ## Documentation
170
+
171
+ Documentation is available: https://github.com/chef/inspec/tree/master/docs
172
+
173
+ ## Kudos
174
+
175
+ InSpec is inspired by the wonderful [Serverspec](http://serverspec.org) project. Kudos to [mizzy](https://github.com/mizzy) and [all contributors](https://github.com/mizzy/serverspec/graphs/contributors)!
176
+
177
+
178
+ ## Contribute
179
+
180
+ 1. Fork it
181
+ 1. Create your feature branch (git checkout -b my-new-feature)
182
+ 1. Commit your changes (git commit -am 'Add some feature')
183
+ 1. Push to the branch (git push origin my-new-feature)
184
+ 1. Create new Pull Request
185
+
186
+
187
+ ## Testing InSpec
169
188
 
170
189
  We perform `unit`, `resource` and `integration` tests.
171
190
 
@@ -175,15 +194,13 @@ We perform `unit`, `resource` and `integration` tests.
175
194
 
176
195
  ### Unit tests
177
196
 
178
- Just
179
197
  ```bash
180
198
  bundle exec rake test
181
199
  ```
182
- as usual.
183
200
 
184
201
  ### Resource tests
185
202
 
186
- Make sure the backend execution layer behaves as expected. These tests will take a while, as a lot of different operating systems and configurations are being tested.
203
+ Resource tests make sure the backend execution layer behaves as expected. These tests will take a while, as a lot of different operating systems and configurations are being tested.
187
204
 
188
205
  You will require:
189
206
 
@@ -216,22 +233,6 @@ bundle exec kitchen test -t .
216
233
 
217
234
  It may be informative to look at what [tests Chef Delivery](https://github.com/chef/inspec/blob/master/.delivery/build-cookbook/recipes/unit.rb) is running for CI.
218
235
 
219
- ## Learn More
220
-
221
- For more information see the InSpec documentation: https://github.com/chef/inspec/tree/master/docs
222
-
223
- ## Kudos
224
-
225
- InSpec is inspired by the wonderful [Serverspec](http://serverspec.org) project. Kudos to [mizzy](https://github.com/mizzy) and [all contributors](https://github.com/mizzy/serverspec/graphs/contributors)!
226
-
227
- ## Contributing
228
-
229
- 1. Fork it
230
- 1. Create your feature branch (git checkout -b my-new-feature)
231
- 1. Commit your changes (git commit -am 'Add some feature')
232
- 1. Push to the branch (git push origin my-new-feature)
233
- 1. Create new Pull Request
234
-
235
236
  ## License
236
237
 
237
238
  | **Author:** | Dominik Richter (<drichter@chef.io>)
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env rake
2
2
  # encoding: utf-8
3
3
 
4
+ require 'bundler'
5
+ require 'bundler/gem_tasks'
4
6
  require 'rake/testtask'
5
7
  require 'rubocop/rake_task'
6
8
  require_relative 'tasks/maintainers'
data/bin/inspec.orig ADDED
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Copyright 2015 Dominik Richter. All rights reserved.
4
+ # author: Dominik Richter
5
+ # author: Christoph Hartmann
6
+
7
+ require 'thor'
8
+ require 'json'
9
+ require_relative '../lib/inspec'
10
+
11
+ class InspecCLI < Thor
12
+ def self.target_options
13
+ option :target, aliases: :t, type: :string, default: nil,
14
+ desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
15
+ option :backend, aliases: :b, type: :string, default: nil,
16
+ desc: 'Choose a backend: local, ssh, winrm, docker.'
17
+ option :host, type: :string,
18
+ desc: 'Specify a remote host which is tested.'
19
+ option :port, type: :numeric,
20
+ desc: 'Specify the login port for a remote scan.'
21
+ option :user, type: :string, default: nil,
22
+ desc: 'The login user for a remote scan.'
23
+ option :password, type: :string, default: nil,
24
+ desc: 'Login password for a remote scan, if required.'
25
+ option :key_files, type: :array, default: nil,
26
+ desc: 'Login key or certificate file for a remote scan.'
27
+ option :path, type: :string, default: nil,
28
+ <<<<<<< HEAD
29
+ desc: 'Login path to use when connecting to the target.'
30
+ option :sudo, type: :boolean, default: false,
31
+ desc: 'Run scans with sudo. Only activates on Unix and non-root user.'
32
+ =======
33
+ desc: 'Login path to use when connecting to the target (WinRM).'
34
+ option :disable_sudo, type: :boolean, default: false,
35
+ desc: 'To not run remote scans via sudo.'
36
+ >>>>>>> update cli description of --path
37
+ option :sudo_password, type: :string, default: nil,
38
+ desc: 'Specify a sudo password, if it is required.'
39
+ option :sudo_options, type: :string, default: '',
40
+ desc: 'Additional sudo options for a remote scan.'
41
+ option :ssl, type: :boolean, default: false,
42
+ desc: 'Use SSL for transport layer encryption (WinRM).'
43
+ option :self_signed, type: :boolean, default: false,
44
+ desc: 'Allow remote scans with self-signed certificates (WinRM).'
45
+ end
46
+
47
+ desc 'json PATH', 'read all tests in PATH and generate a JSON profile'
48
+ option :id, type: :string,
49
+ desc: 'Attach a profile ID to all test results'
50
+ option :output, aliases: :o, type: :string,
51
+ desc: 'Save the created profile to a path'
52
+ def json(path)
53
+ profile = Inspec::Profile.from_path(path, options)
54
+ dst = options[:output].to_s
55
+ if dst.empty?
56
+ puts JSON.pretty_generate(profile.info)
57
+ else
58
+ if File.exist? dst
59
+ puts "----> updating #{dst}"
60
+ else
61
+ puts "----> creating #{dst}"
62
+ end
63
+ fdst = File.expand_path(dst)
64
+ File.write(fdst, JSON.dump(profile.info))
65
+ end
66
+ end
67
+
68
+ desc 'check PATH', 'verify test structure in PATH'
69
+ def check(path)
70
+ o = options.dup
71
+ o[:logger] = Logger.new(STDOUT)
72
+ profile = Inspec::Profile.from_path(path, o)
73
+ exit 1 unless profile.check
74
+ end
75
+
76
+ desc 'exec PATHS', 'run all test files'
77
+ option :id, type: :string,
78
+ desc: 'Attach a profile ID to all test results'
79
+ target_options
80
+ option :format, type: :string, default: 'progress'
81
+ def exec(*tests)
82
+ runner = Inspec::Runner.new(options)
83
+ runner.add_tests(tests)
84
+ runner.run
85
+ rescue RuntimeError => e
86
+ puts e.message
87
+ end
88
+
89
+ desc 'detect', 'detect the target OS'
90
+ target_options
91
+ def detect
92
+ runner = Inspec::Runner.new(options)
93
+ rel = File.join(File.dirname(__FILE__), *%w{.. lib utils detect.rb})
94
+ detect_util = File.expand_path(rel)
95
+ runner.add_tests([detect_util])
96
+ runner.run
97
+ rescue RuntimeError => e
98
+ puts e.message
99
+ end
100
+
101
+ desc 'shell', 'open an interactive debugging shell'
102
+ target_options
103
+ def shell_func
104
+ runner = Inspec::Runner.new(options)
105
+ Inspec::Shell.new(runner).start
106
+ rescue RuntimeError => e
107
+ puts e.message
108
+ end
109
+
110
+ desc 'version', 'prints the version of this tool'
111
+ def version
112
+ puts Inspec::VERSION
113
+ end
114
+ end
115
+ InspecCLI.start(ARGV)
@@ -0,0 +1,81 @@
1
+ =====================================================
2
+ InSpec and friends
3
+ =====================================================
4
+
5
+ RSpec
6
+ =====================================================
7
+
8
+ RSpec is an awesome framework that is widely used to test Ruby code. It enables test-driven development (TDD) and helps developers to write better code every day.
9
+
10
+ InSpec is built on top of RSpec and uses it as the underlying foundation to execute tests. It uses the key strengths of RSpec, easily execute tests and a DSL to write tests, but extends the functionality for use as compliance audits. InSpec ships with custom audit resources that make it easy to write audit checks and with the ability to run those checks on remote servers. These audit resources provided know the differences between operating systems and help you abstract from the local operating system, similar to other resources you might use in your Chef recipes.
11
+
12
+ A complete InSpec rule looks like:
13
+
14
+ .. code-block:: ruby
15
+
16
+ control "sshd-11" do
17
+ impact 1.0
18
+ title "Server: Set protocol version to SSHv2"
19
+ desc "
20
+ Set the SSH protocol version to 2. Don't use legacy
21
+ insecure SSHv1 connections anymore.
22
+ "
23
+ describe sshd_config do
24
+ its('Protocol') { should eq('2') }
25
+ end
26
+ end
27
+
28
+
29
+
30
+ Serverspec
31
+ =====================================================
32
+
33
+ Serverspec can be credited as the first extension of RSpec that enabled users to run RSpec tests on servers to verify deployed artifacts. It was created in March 2013 by Gosuke Miyashita and has been widely adopted. It is also one of the core test frameworks within test-kitchen and has been widely used within the Chef ecosystem. InSpec takes lessons learned implementing and using Serverspec and builds on them to make auditing and compliance easier.
34
+
35
+ Lessons learned from Serverspec include:
36
+
37
+ * IT, compliance, and security professional require metadata beyond what Serverspec offers, such as criticality, to fully describe controls.
38
+
39
+ * Setting up and running the same tests across multiple machines must be easy.
40
+
41
+ * It must be easy to locate, debug, and extend operating system-dependent code.
42
+
43
+ * It must be easy to extend the language and create custom resources.
44
+
45
+ * It must run multiple tests simultaneously.
46
+
47
+ * Support for Windows is a first-class requirement.
48
+
49
+ * A command line interface (CLI) is required for faster iteration of test code.
50
+
51
+
52
+ How is InSpec different than Serverspec
53
+ -----------------------------------------------------
54
+
55
+ One of the key differences is that InSpec targets more user groups. It is optimized for DevOps, Security, and Compliance professionals. Additional metadata, such as impact, title, and description, make it easier to fully describe the controls which makes it easier to share the controls with other departments. This enables Security departments to prioritize rules. DevOps teams use this information to focus on the most critical issues to remediate.
56
+
57
+ .. code-block:: ruby
58
+
59
+ control "sshd-11" do
60
+ impact 1.0
61
+ title "Server: Set protocol version to SSHv2"
62
+ desc "
63
+ Set the SSH protocol version to 2. Don't use legacy
64
+ insecure SSHv1 connections anymore.
65
+ "
66
+ describe sshd_config do
67
+ its('Protocol') { should eq('2') }
68
+ end
69
+ end
70
+
71
+ **Why not fork Serverspec?**
72
+
73
+ InSpec started as an extension of Serverspec. As the extension grew, it became clear that a new library was required. Creating and maintaining a fork was not practical so a new project was born.
74
+
75
+ **Will InSpec only work on machines managed by Chef?**
76
+
77
+ No, InSpec can be used on any machine. It doesn’t matter if that machine was configured by Chef or configured lovingly by the hands of your local System Administrator.
78
+
79
+ **Is InSpec a replacement of Serverspec?**
80
+
81
+ InSpec is intended to be a drop-in replacement of Serverspec. Popular Serverspec resources have been ported to InSpec. It changed some behaviour as documented in our migration guide.
data/docs/resources.rst CHANGED
@@ -1067,7 +1067,7 @@ The ``content`` matcher tests if contents in the file match the value specified
1067
1067
 
1068
1068
  .. code-block:: ruby
1069
1069
 
1070
- its('content') { should contain 'value' }
1070
+ its('content') { should match 'value' }
1071
1071
 
1072
1072
  The following complete example tests the ``pg_hba.conf`` file in |postgresql| for |md5| requirements. The tests look at all ``host`` and ``local`` settings in that file, and then compare the |md5| checksums against the values in the test:
1073
1073
 
@@ -2602,7 +2602,7 @@ The ``version`` matcher tests if the named package version is on the system:
2602
2602
 
2603
2603
  .. code-block:: ruby
2604
2604
 
2605
- its('version) { should eq '1.2.3' }
2605
+ its('version') { should eq '1.2.3' }
2606
2606
 
2607
2607
  Examples
2608
2608
  -----------------------------------------------------
@@ -2,7 +2,7 @@
2
2
  source 'https://rubygems.org'
3
3
 
4
4
  gem 'inspec', path: '../../.'
5
- gem 'train', git: 'git@github.com:chef/train.git'
5
+ gem 'r-train', git: 'git@github.com:chef/train.git'
6
6
 
7
7
  group :test do
8
8
  gem 'bundler', '~> 1.5'
data/inspec.gemspec CHANGED
@@ -13,8 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/chef/inspec'
14
14
  spec.license = 'Apache 2.0'
15
15
 
16
- spec.files = `hash git 2>/dev/null && git ls-files -z`.split("\x0").find_all { |x| x !~ /^\.delivery/ }
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.files = %w(README.md Rakefile MAINTAINERS.toml MAINTAINERS.md LICENSE inspec.gemspec Gemfile CHANGELOG.md .rubocop.yml) +
17
+ Dir.glob("{bin,docs,examples,lib,tasks,test}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
18
+ spec.executables = %w( inspec )
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
20
  spec.require_paths = ['lib']
20
21
 
data/lib/inspec/shell.rb CHANGED
@@ -13,7 +13,8 @@ module Inspec
13
13
 
14
14
  def start
15
15
  # store context to run commands in this context
16
- @runner.add_content('binding.pry', __FILE__, __LINE__)
16
+ @runner.add_content({
17
+ content: 'binding.pry', ref: __FILE__, line: __LINE__}, [])
17
18
  @runner.run
18
19
  end
19
20
 
@@ -3,5 +3,5 @@
3
3
  # author: Christoph Hartmann
4
4
 
5
5
  module Inspec
6
- VERSION = '0.9.1'
6
+ VERSION = '0.9.2'
7
7
  end
Binary file
@@ -0,0 +1,2 @@
1
+ name 'metadata profile'
2
+
@@ -0,0 +1,6 @@
1
+ rule 'id-1' do
2
+ title 'hello title'
3
+ desc 'hello desc'
4
+ impact 0.0
5
+ expect(file '/dev/zero').to be_file
6
+ end
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.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r-train
@@ -144,9 +144,7 @@ executables:
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - ".gitignore"
148
147
  - ".rubocop.yml"
149
- - ".travis.yml"
150
148
  - CHANGELOG.md
151
149
  - Gemfile
152
150
  - LICENSE
@@ -155,8 +153,10 @@ files:
155
153
  - README.md
156
154
  - Rakefile
157
155
  - bin/inspec
156
+ - bin/inspec.orig
158
157
  - docs/ctl_inspec.rst
159
158
  - docs/dsl_inspec.rst
159
+ - docs/inspec_and_friends.rst
160
160
  - docs/readme.rst
161
161
  - docs/resources.rst
162
162
  - docs/template.rst
@@ -193,6 +193,7 @@ files:
193
193
  - lib/inspec/targets/zip.rb
194
194
  - lib/inspec/version.rb
195
195
  - lib/matchers/matchers.rb
196
+ - lib/resources/.service.rb.swp
196
197
  - lib/resources/apache.rb
197
198
  - lib/resources/apache_conf.rb
198
199
  - lib/resources/apt.rb
@@ -347,6 +348,8 @@ files:
347
348
  - test/unit/mock/files/sshd_config
348
349
  - test/unit/mock/profiles/empty/metadata.rb
349
350
  - test/unit/mock/profiles/metadata/metadata.rb
351
+ - test/unit/mock/profiles/rules/metadata.rb
352
+ - test/unit/mock/profiles/rules/test/test.rb
350
353
  - test/unit/profile_context_test.rb
351
354
  - test/unit/profile_test.rb
352
355
  - test/unit/resources/apt_test.rb
@@ -510,6 +513,8 @@ test_files:
510
513
  - test/unit/mock/files/sshd_config
511
514
  - test/unit/mock/profiles/empty/metadata.rb
512
515
  - test/unit/mock/profiles/metadata/metadata.rb
516
+ - test/unit/mock/profiles/rules/metadata.rb
517
+ - test/unit/mock/profiles/rules/test/test.rb
513
518
  - test/unit/profile_context_test.rb
514
519
  - test/unit/profile_test.rb
515
520
  - test/unit/resources/apt_test.rb
@@ -552,4 +557,3 @@ test_files:
552
557
  - test/unit/resources/yum_test.rb
553
558
  - test/unit/simpleconfig_test.rb
554
559
  - test/unit/utils/content_parser_test.rb
555
- has_rdoc:
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- Gemfile.lock
2
- coverage
3
- *.gem
4
- .gallery
5
- .kitchen
6
- .delivery/cli.toml
7
- Berksfile.lock
8
- .bundle
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- ---
2
- sudo: required
3
- language: ruby
4
- cache: bundler
5
-
6
- bundler_args: --without integration tools maintenance
7
-
8
- matrix:
9
- include:
10
- - rvm: 1.9.3
11
- gemfile: Gemfile
12
- - rvm: 2.0
13
- gemfile: Gemfile
14
- - rvm: 2.2
15
- gemfile: Gemfile
16
- script: bundle exec rake lint test test:resources config=test/test.yaml
17
- before_script:
18
- - source <(curl -sL https://raw.githubusercontent.com/zuazo/kitchen-in-travis/0.3.0/scripts/start_docker.sh)
19
- - rvm: 2.2
20
- gemfile: Gemfile
21
- script: bundle exec rake test:resources config=test/test-extra.yaml
22
- before_script:
23
- - source <(curl -sL https://raw.githubusercontent.com/zuazo/kitchen-in-travis/0.3.0/scripts/start_docker.sh)