inspec-core 4.21.3 → 4.23.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/inspec-core.gemspec +3 -5
  4. data/lib/bundles/inspec-supermarket/cli.rb +1 -1
  5. data/lib/inspec/base_cli.rb +5 -1
  6. data/lib/inspec/config.rb +19 -1
  7. data/lib/inspec/exceptions.rb +1 -0
  8. data/lib/inspec/input.rb +4 -3
  9. data/lib/inspec/input_registry.rb +9 -2
  10. data/lib/inspec/metadata.rb +6 -1
  11. data/lib/inspec/plugin/v2/plugin_types/reporter.rb +4 -25
  12. data/lib/inspec/profile.rb +30 -9
  13. data/lib/inspec/reporters.rb +0 -3
  14. data/lib/inspec/reporters/automate.rb +3 -3
  15. data/lib/inspec/reporters/base.rb +7 -23
  16. data/lib/inspec/reporters/cli.rb +1 -0
  17. data/lib/inspec/reporters/json.rb +9 -4
  18. data/lib/inspec/resources/apt.rb +2 -0
  19. data/lib/inspec/resources/bridge.rb +1 -1
  20. data/lib/inspec/resources/host.rb +1 -1
  21. data/lib/inspec/resources/mount.rb +1 -1
  22. data/lib/inspec/resources/mysql_session.rb +31 -8
  23. data/lib/inspec/resources/postgres.rb +1 -1
  24. data/lib/inspec/resources/postgres_session.rb +6 -4
  25. data/lib/inspec/resources/processes.rb +1 -1
  26. data/lib/inspec/resources/service.rb +2 -2
  27. data/lib/inspec/resources/users.rb +1 -1
  28. data/lib/inspec/resources/windows_firewall.rb +110 -0
  29. data/lib/inspec/resources/windows_firewall_rule.rb +137 -0
  30. data/lib/inspec/run_data.rb +1 -1
  31. data/lib/inspec/run_data/profile.rb +7 -6
  32. data/lib/inspec/runner.rb +8 -2
  33. data/lib/inspec/runner_rspec.rb +4 -1
  34. data/lib/inspec/schema.rb +2 -0
  35. data/lib/inspec/schema/exec_json.rb +4 -3
  36. data/lib/inspec/schema/primitives.rb +1 -1
  37. data/lib/inspec/utils/parser.rb +1 -1
  38. data/lib/inspec/utils/run_data_filters.rb +104 -0
  39. data/lib/inspec/version.rb +1 -1
  40. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +4 -4
  41. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +1 -1
  42. data/lib/plugins/inspec-reporter-html2/templates/profile.html.erb +5 -2
  43. data/lib/plugins/inspec-reporter-junit/README.md +15 -0
  44. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb +12 -0
  45. data/lib/{inspec/reporters/junit.rb → plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb} +22 -26
  46. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/version.rb +5 -0
  47. metadata +19 -36
  48. data/README.md +0 -474
data/README.md DELETED
@@ -1,474 +0,0 @@
1
- # Chef InSpec: Inspect Your Infrastructure
2
-
3
- * **Project State: Active**
4
- * **Issues Response SLA: 14 business days**
5
- * **Pull Request Response SLA: 14 business days**
6
-
7
- For more information on project states and SLAs, see [this documentation](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md).
8
-
9
- [![Slack](https://community-slack.chef.io/badge.svg)](https://community-slack.chef.io/)
10
- [![Build status](https://badge.buildkite.com/bf4c5fdc3858cc9f8c8bab8376e8e40d625ad046df9d4d8619.svg?branch=master)](https://buildkite.com/chef-oss/inspec-inspec-master-verify)
11
- [![Coverage Status](https://coveralls.io/repos/github/inspec/inspec/badge.svg?branch=master)](https://coveralls.io/github/inspec/inspec?branch=master)
12
-
13
- Chef InSpec is an open-source testing framework for infrastructure with a human- and machine-readable language for specifying compliance, security and policy requirements.
14
-
15
- ```ruby
16
- # Disallow insecure protocols by testing
17
-
18
- describe package('telnetd') do
19
-   it { should_not be_installed }
20
- end
21
-
22
- describe inetd_conf do
23
-   its("telnet") { should eq nil }
24
- end
25
- ```
26
-
27
- Chef InSpec makes it easy to run your tests wherever you need. More options are found in our [CLI docs](https://www.inspec.io/docs/reference/cli/).
28
-
29
- ```bash
30
- # run test locally
31
- inspec exec test.rb
32
-
33
- # run test on remote host via SSH
34
- inspec exec test.rb -t ssh://user@hostname -i /path/to/key
35
-
36
- # run test on remote host using SSH agent private key authentication. Requires Chef InSpec 1.7.1
37
- inspec exec test.rb -t ssh://user@hostname
38
-
39
- # run test on remote windows host via WinRM
40
- inspec exec test.rb -t winrm://Administrator@windowshost --password 'your-password'
41
-
42
- # run test on remote windows host via WinRM as a domain user
43
- inspec exec test.rb -t winrm://windowshost --user 'UserName@domain' --password 'your-password'
44
-
45
- # run test on docker container
46
- inspec exec test.rb -t docker://container_id
47
- ```
48
-
49
- # Features
50
-
51
- - Built-in Compliance: Compliance no longer occurs at the end of the release cycle
52
- - Targeted Tests: Chef InSpec writes tests that specifically target compliance issues
53
- - Metadata: Includes the metadata required by security and compliance pros
54
- - Easy Testing: Includes a command-line interface to run tests quickly
55
-
56
- ## Installation
57
-
58
- Chef InSpec requires Ruby ( >= 2.4 ).
59
-
60
- Note: Versions of Chef InSpec 4.0 and later require accepting the EULA to use. Please visit the [license acceptance page](https://docs.chef.io/chef_license_accept.html) on the Chef docs site for more information.
61
-
62
- ### Install as package
63
-
64
- The Chef InSpec package is available for MacOS, RedHat, Ubuntu and Windows. Download the latest package at [Chef InSpec Downloads](https://downloads.chef.io/inspec) or install Chef InSpec via script:
65
-
66
- ```
67
- # RedHat, Ubuntu, and macOS
68
- curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P inspec
69
-
70
- # Windows
71
- . { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -project inspec
72
- ```
73
-
74
- ### Install it via rubygems.org
75
-
76
- When installing from source, gem dependencies may require ruby build tools to be installed.
77
-
78
- For CentOS/RedHat/Fedora:
79
-
80
- ```bash
81
- yum -y install ruby ruby-devel make gcc gcc-c++
82
- ```
83
-
84
- For Ubuntu:
85
-
86
- ```bash
87
- apt-get -y install ruby ruby-dev gcc g++ make
88
- ```
89
-
90
- To install the `inspec` executable, which requires accepting the [Chef License](https://docs.chef.io/chef_license_accept.html), run:
91
-
92
- ```bash
93
- gem install inspec-bin
94
- ```
95
-
96
- You may also use `inspec` as a library, with no executable. This does not require accepting the license. To install the library as a gem, run:
97
-
98
- ```bash
99
- gem install inspec
100
- ```
101
-
102
-
103
- ### Usage via Docker
104
-
105
- Download the image and define a function for convenience:
106
-
107
- For Linux:
108
-
109
- ```
110
- docker pull chef/inspec
111
- function inspec { docker run -it --rm -v $(pwd):/share chef/inspec "$@"; }
112
- ```
113
-
114
- For Windows (PowerShell):
115
-
116
- ```
117
- docker pull chef/inspec
118
- function inspec { docker run -it --rm -v "$(pwd):/share" chef/inspec $args; }
119
- ```
120
-
121
- If you call `inspec` from your shell, it automatically mounts the current directory into the Docker container. Therefore you can easily use local tests and key files. Note: Only files in the current directory and sub-directories are available within the container.
122
-
123
- ```
124
- $ ls -1
125
- vagrant
126
- test.rb
127
-
128
- $ inspec exec test.rb -t ssh://root@192.168.64.2:11022 -i vagrant
129
- ..
130
-
131
- Finished in 0.04321 seconds (files took 0.54917 seconds to load)
132
- 2 examples, 0 failures
133
- ```
134
-
135
-
136
- ### Install it from source
137
-
138
- Note that installing from OS packages from [the download page](https://downloads.chef.io) is the preferred method.
139
-
140
- That requires [bundler](http://bundler.io/):
141
-
142
- ```bash
143
- bundle install
144
- bundle exec inspec help
145
- ```
146
-
147
- To install it as a gem locally, run:
148
-
149
- ```bash
150
- gem build inspec.gemspec
151
- gem install inspec-*.gem
152
- ```
153
-
154
- On Windows, you need to install [Ruby](http://rubyinstaller.org/downloads/) with [Ruby Development Kit](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit) to build dependencies with its native extensions.
155
-
156
- ### Install via Chef Habitat
157
-
158
- Currently, this method of installation only supports Linux. See the [Chef Habitat site](https://www.habitat.sh/) for more information.
159
-
160
- Download the `hab` binary from the [Chef Habitat](https://www.habitat.sh/docs/get-habitat/) site.
161
-
162
- ```bash
163
- hab pkg install chef/inspec --binlink
164
-
165
- inspec
166
- ```
167
-
168
- ### Run Chef InSpec
169
-
170
- You should now be able to run:
171
-
172
- ```bash
173
- $ inspec --help
174
- Commands:
175
- inspec archive PATH # archive a profile to tar.gz (default) ...
176
- inspec check PATH # verify all tests at the specified PATH
177
- inspec compliance SUBCOMMAND ... # Chef Compliance commands
178
- inspec detect # detect the target OS
179
- inspec exec PATH(S) # run all test files at the specified PATH.
180
- inspec help [COMMAND] # Describe available commands or one spe...
181
- inspec init TEMPLATE ... # Scaffolds a new project
182
- inspec json PATH # read all tests in PATH and generate a ...
183
- inspec shell # open an interactive debugging shell
184
- inspec supermarket SUBCOMMAND ... # Supermarket commands
185
- inspec version # prints the version of this tool
186
-
187
- Options:
188
- [--diagnose], [--no-diagnose] # Show diagnostics (versions, configurations)
189
- ```
190
-
191
- # Examples
192
-
193
- * Only accept requests on secure ports - This test ensures that a web server is only listening on well-secured ports.
194
-
195
- ```ruby
196
- describe port(80) do
197
-   it { should_not be_listening }
198
- end
199
-
200
- describe port(443) do
201
-   it { should be_listening }
202
-   its('protocols') {should include 'tcp'}
203
- end
204
- ```
205
-
206
- * Use approved strong ciphers - This test ensures that only enterprise-compliant ciphers are used for SSH servers.
207
-
208
- ```ruby
209
- describe sshd_config do
210
-    its('Ciphers') { should eq('chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr') }
211
- end
212
- ```
213
-
214
- * Test your `kitchen.yml` file to verify that only Vagrant is configured as the driver. The %w() formatting will
215
- pass rubocop linting and allow you to access nested mappings.
216
-
217
- ```ruby
218
- describe yaml('.kitchen.yml') do
219
- its(%w(driver name)) { should eq('vagrant') }
220
- end
221
- ```
222
-
223
- Also have a look at our examples for:
224
- - [Using Chef InSpec with Test Kitchen & Chef Infra](https://github.com/chef/inspec/tree/master/examples/kitchen-chef)
225
- - [Using Chef InSpec with Test Kitchen & Puppet](https://github.com/chef/inspec/tree/master/examples/kitchen-puppet)
226
- - [Using Chef InSpec with Test Kitchen & Ansible](https://github.com/chef/inspec/tree/master/examples/kitchen-ansible)
227
- - [Implementing an Chef InSpec profile](https://github.com/chef/inspec/tree/master/examples/profile)
228
-
229
- ## Or tests: Testing for a OR b
230
-
231
- * Using describe.one, you can test for a or b. The control will be marked as passing if EITHER condition is met.
232
-
233
- ```ruby
234
- control 'or-test' do
235
- impact 1.0
236
- title 'This is a OR test'
237
- describe.one do
238
- describe ssh_config do
239
- its('Protocol') { should eq('3') }
240
- end
241
- describe ssh_config do
242
- its('Protocol') { should eq('2') }
243
- end
244
- end
245
- end
246
- ```
247
-
248
- ## Command Line Usage
249
-
250
- ### exec
251
-
252
- Run tests against different targets:
253
-
254
- ```bash
255
- # run test locally
256
- inspec exec test.rb
257
-
258
- # run test on remote host on SSH
259
- inspec exec test.rb -t ssh://user@hostname
260
-
261
- # run test on remote windows host on WinRM
262
- inspec exec test.rb -t winrm://Administrator@windowshost --password 'your-password'
263
-
264
- # run test on docker container
265
- inspec exec test.rb -t docker://container_id
266
-
267
- # run with sudo
268
- inspec exec test.rb --sudo [--sudo-password ...] [--sudo-options ...] [--sudo_command ...]
269
-
270
- # run in a subshell
271
- inspec exec test.rb --shell [--shell-options ...] [--shell-command ...]
272
-
273
- # run a profile targeting AWS using env vars
274
- inspec exec test.rb -t aws://
275
-
276
- # or store your AWS credentials in your ~/.aws/credentials profiles file
277
- inspec exec test.rb -t aws://us-east-2/my-profile
278
-
279
- # run a profile targeting Azure using env vars
280
- inspec exec test.rb -t azure://
281
-
282
- # or store your Azure credentials in your ~/.azure/credentials profiles file
283
- inspec exec test.rb -t azure://subscription_id
284
- ```
285
-
286
- ### detect
287
-
288
- Verify your configuration and detect
289
-
290
- ```bash
291
- id=$( docker run -dti ubuntu:14.04 /bin/bash )
292
- inspec detect -t docker://$id
293
- ```
294
-
295
- Which will provide you with:
296
-
297
- ```
298
- {"family":"ubuntu","release":"14.04","arch":null}
299
- ```
300
-
301
- ## Supported OS
302
-
303
- Remote Targets
304
-
305
- | Platform | Versions | Architectures |
306
- | ---------------------------- | ------------------------------------------------ | ------------- |
307
- | AIX | 6.1, 7.1, 7.2 | ppc64 |
308
- | CentOS | 5, 6, 7 | i386, x86_64 |
309
- | Debian | 7, 8, 9 | i386, x86_64 |
310
- | FreeBSD | 9, 10, 11 | i386, amd64 |
311
- | Mac OS X | 10.9, 10.10, 10.11, 10.12, 10.13, 10.14 | x86_64 |
312
- | Oracle Enterprise Linux | 5, 6, 7 | i386, x86_64 |
313
- | Red Hat Enterprise Linux | 5, 6, 7 | i386, x86_64 |
314
- | Solaris | 10, 11 | sparc, x86 |
315
- | Windows\* | 8, 8.1, 10, 2012, 2012R2, 2016 | x86, x86_64 |
316
- | Ubuntu Linux | | x86, x86_64 |
317
- | SUSE Linux Enterprise Server | 11, 12 | x86_64 |
318
- | Scientific Linux | 5.x, 6.x and 7.x | i386, x86_64 |
319
- | Fedora | | x86_64 |
320
- | OpenSUSE | 13, 42 | x86_64 |
321
- | OmniOS | | x86_64 |
322
- | Gentoo Linux | | x86_64 |
323
- | Arch Linux | | x86_64 |
324
- | HP-UX | 11.31 | ia64 |
325
-
326
- \**For Windows, PowerShell 5.0 or above is required.*
327
-
328
- In addition, runtime support is provided for:
329
-
330
- | Platform | Versions | Arch |
331
- | -------- | -------- | ------ |
332
- | Debian | 8, 9 | x86_64 |
333
- | RHEL | 6, 7 | x86_64 |
334
- | Ubuntu | 12.04+ | x86_64 |
335
- | Windows | 8+ | x86_64 |
336
- | Windows | 2012+ | x86_64 |
337
-
338
- ## Documentation
339
-
340
- Documentation
341
-
342
- * https://www.inspec.io/docs/
343
- * https://www.inspec.io/docs/reference/resources/
344
- * https://github.com/chef/inspec/tree/master/docs
345
-
346
- Tutorials/Blogs/Podcasts:
347
-
348
- * https://www.inspec.io/tutorials/
349
-
350
- Relationship to other tools (RSpec, Serverspec):
351
-
352
- * https://www.inspec.io/docs/reference/inspec_and_friends/
353
-
354
- ## Share your Profiles
355
-
356
- You may share your Chef InSpec Profiles in the [Tools & Plugins section](https://supermarket.chef.io/tools-directory) of the [Chef Supermarket](https://supermarket.chef.io/). [Sign in](https://supermarket.chef.io/sign-in) and [add the details of your profile](https://supermarket.chef.io/tools/new).
357
-
358
- You may also [browse the Supermarket for shared Compliance Profiles](https://supermarket.chef.io/tools?type=compliance_profile).
359
-
360
- ## Kudos
361
-
362
- Chef 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)!
363
-
364
- The AWS resources were inspired by [inspec-aws](https://github.com/arothian/inspec-aws) from [arothian](https://github.com/arothian).
365
-
366
- ## Contribute
367
-
368
- 1. Fork it
369
- 1. Create your feature branch (git checkout -b my-new-feature)
370
- 1. Commit your changes (git commit -am 'Add some feature')
371
- 1. Push to the branch (git push origin my-new-feature)
372
- 1. Create new Pull Request
373
-
374
- The Chef InSpec community and maintainers are very active and helpful. This project benefits greatly from this activity.
375
-
376
- If you'd like to chat with the community and maintainers directly join us in the `#inspec` channel on the [Chef Community Slack](http://community-slack.chef.io/).
377
-
378
- As a reminder, all participants are expected to follow the [Code of Conduct](https://github.com/inspec/inspec/blob/master/CODE_OF_CONDUCT.md).
379
-
380
- [![Slack](https://community-slack.chef.io/badge.svg)](https://community-slack.chef.io/)
381
-
382
- ## Testing Chef InSpec
383
-
384
- We offer `unit`, `integration`, and `aws` tests.
385
-
386
- - `unit` tests ensure the intended behaviour of the implementation
387
- - `integration` tests run against Docker-based VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
388
- - `aws` tests exercise the AWS resources against real AWS accounts
389
-
390
- ### Unit tests
391
-
392
- ```bash
393
- bundle exec rake test
394
- ```
395
-
396
- If you like to run only one test file:
397
-
398
- ```bash
399
- bundle exec m test/unit/resources/user_test.rb
400
- ```
401
-
402
- You may also run a single test within a file by line number:
403
-
404
- ```bash
405
- bundle exec m test/unit/resources/user_test.rb -l 123
406
- ```
407
-
408
- ### Integration tests
409
-
410
- These tests download various virtual machines, to ensure Chef InSpec is working as expected across different operating systems.
411
-
412
- These tests require the following gems:
413
-
414
- - test-kitchen
415
- - kitchen-dokken
416
- - kitchen-inspec
417
-
418
- These gems are provided via the `integration` group in the project's Gemfile.
419
-
420
- In addition, these test require Docker to be available on your machine or a remote Docker machine configured via the standard Docker environment variables.
421
-
422
- #### Running Integration tests
423
-
424
- List the various test instances available:
425
-
426
- ```bash
427
- bundle exec kitchen list
428
- ```
429
-
430
- The platforms and test suites are configured in the `.kitchen.yml` file. Once you know which instance you wish to test, test that instance:
431
-
432
- ```bash
433
- bundle exec kitchen test <INSTANCE_NAME>
434
- ```
435
-
436
- You may test all instances in parallel with:
437
-
438
- ```bash
439
- bundle exec kitchen test -c
440
- ```
441
-
442
- ### AWS Tests
443
-
444
- Use the rake task `bundle exec rake test:aws` to test the AWS resources against a pair of real AWS accounts.
445
-
446
- Please see [TESTING_AGAINST_AWS.md](./test/integration/aws/TESTING_AGAINST_AWS.md) for details on how to setup the needed AWS accounts to perform testing.
447
-
448
- ### Azure Tests
449
-
450
- Use the rake task `bundle exec rake test:azure` to test the Azure resources against an Azure account.
451
-
452
- Please see [TESTING_AGAINST_AZURE.md](./test/integration/azure/TESTING_AGAINST_AZURE.md) for details on how to setup the needed Azure accounts to perform testing.
453
-
454
- ## License
455
-
456
- | | |
457
- | -------------- | ----------------------------------------- |
458
- | **Author:** | Dominik Richter (<drichter@chef.io>) |
459
- | **Author:** | Christoph Hartmann (<chartmann@chef.io>) |
460
- | **Copyright:** | Copyright (c) 2015 Vulcano Security GmbH. |
461
- | **Copyright:** | Copyright (c) 2017-2018 Chef Software Inc.|
462
- | **License:** | Apache License, Version 2.0 |
463
-
464
- Licensed under the Apache License, Version 2.0 (the "License");
465
- you may not use this file except in compliance with the License.
466
- You may obtain a copy of the License at
467
-
468
- http://www.apache.org/licenses/LICENSE-2.0
469
-
470
- Unless required by applicable law or agreed to in writing, software
471
- distributed under the License is distributed on an "AS IS" BASIS,
472
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
473
- See the License for the specific language governing permissions and
474
- limitations under the License.