inspec-core 4.21.1 → 4.22.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/inspec-core.gemspec +2 -4
  4. data/lib/bundles/inspec-supermarket/cli.rb +1 -1
  5. data/lib/inspec/base_cli.rb +2 -2
  6. data/lib/inspec/config.rb +0 -1
  7. data/lib/inspec/exceptions.rb +1 -0
  8. data/lib/inspec/input_registry.rb +2 -1
  9. data/lib/inspec/metadata.rb +6 -1
  10. data/lib/inspec/plugin/v2/plugin_types/reporter.rb +11 -5
  11. data/lib/inspec/profile.rb +30 -9
  12. data/lib/inspec/reporters.rb +0 -3
  13. data/lib/inspec/reporters/automate.rb +3 -3
  14. data/lib/inspec/reporters/base.rb +11 -5
  15. data/lib/inspec/reporters/cli.rb +1 -0
  16. data/lib/inspec/reporters/json.rb +9 -4
  17. data/lib/inspec/resources/apt.rb +2 -0
  18. data/lib/inspec/resources/bridge.rb +1 -1
  19. data/lib/inspec/resources/host.rb +1 -1
  20. data/lib/inspec/resources/mount.rb +1 -1
  21. data/lib/inspec/resources/mysql_session.rb +31 -8
  22. data/lib/inspec/resources/postgres.rb +1 -1
  23. data/lib/inspec/resources/postgres_session.rb +1 -1
  24. data/lib/inspec/resources/service.rb +2 -2
  25. data/lib/inspec/resources/users.rb +1 -1
  26. data/lib/inspec/resources/windows_firewall.rb +110 -0
  27. data/lib/inspec/resources/windows_firewall_rule.rb +137 -0
  28. data/lib/inspec/run_data.rb +1 -1
  29. data/lib/inspec/run_data/profile.rb +4 -4
  30. data/lib/inspec/runner.rb +8 -2
  31. data/lib/inspec/runner_rspec.rb +4 -1
  32. data/lib/inspec/schema.rb +2 -0
  33. data/lib/inspec/schema/exec_json.rb +4 -3
  34. data/lib/inspec/schema/primitives.rb +1 -1
  35. data/lib/inspec/utils/parser.rb +1 -1
  36. data/lib/inspec/version.rb +1 -1
  37. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +4 -4
  38. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +1 -1
  39. data/lib/plugins/inspec-reporter-html2/templates/profile.html.erb +5 -2
  40. data/lib/plugins/inspec-reporter-junit/README.md +15 -0
  41. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb +12 -0
  42. data/lib/{inspec/reporters/junit.rb → plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb} +22 -26
  43. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/version.rb +5 -0
  44. metadata +16 -34
  45. data/README.md +0 -474
@@ -126,7 +126,7 @@ module InspecPlugins
126
126
  desc: "Overwrite existing profile on Server."
127
127
  option :owner, type: :string, required: false,
128
128
  desc: "Owner that should own the profile"
129
- def upload(path) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, PerceivedComplexity, Metrics/CyclomaticComplexity
129
+ def upload(path) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
130
130
  config = InspecPlugins::Compliance::Configuration.new
131
131
  return unless loggedin(config)
132
132
 
@@ -7,8 +7,11 @@
7
7
  <% if profile.summary %>
8
8
  <tr class="profile-summary"><th>Summary:</th><td><%= profile.summary %></td></tr>
9
9
  <% end %>
10
- <% if profile.skip_message %>
11
- <tr class="profile-skip-message"><th>Skip Message:</th><td><%= profile.skip_message %></td></tr>
10
+ <% if profile.status != "loaded" %>
11
+ <tr class="profile-status"><th>Status:</th><td><%= profile.status %></td></tr>
12
+ <% end %>
13
+ <% if profile.status_message && !profile.status_message.empty? %>
14
+ <tr class="profile-status-message"><th>Status Message:</th><td><%= profile.status_message %></td></tr>
12
15
  <% end %>
13
16
  </table>
14
17
 
@@ -0,0 +1,15 @@
1
+ # junit reporter
2
+
3
+ This is the implementation of the junit XML reporter.
4
+
5
+ ## To Install This Plugin
6
+
7
+ This plugin is included with inspec. There is no need to install it separately.
8
+
9
+ ## What This Plugin Does
10
+
11
+ This reporter generates an XML report in Apache Ant JUnit format.
12
+
13
+ ## Implementation Note
14
+
15
+ This reporter uses the REXML XML generator, but may use more advanced XML systems for testing. This is to keep packaging requirements for CHef InSpec lightweight and free of compiled dependencies.
@@ -0,0 +1,12 @@
1
+ require_relative "inspec-reporter-junit/version"
2
+ module InspecPlugins
3
+ module JUnitReporter
4
+ class Plugin < ::Inspec.plugin(2)
5
+ plugin_name :'inspec-reporter-junit'
6
+ reporter :junit do
7
+ require_relative "inspec-reporter-junit/reporter"
8
+ InspecPlugins::JUnitReporter::Reporter
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,9 @@
1
- module Inspec::Reporters
2
- class Junit < Base
1
+ module InspecPlugins::JUnitReporter
2
+ class Reporter < Inspec.plugin(2, :reporter)
3
+ def self.run_data_schema_constraints
4
+ "~> 0.0"
5
+ end
6
+
3
7
  def render
4
8
  require "rexml/document"
5
9
  xml_output = REXML::Document.new
@@ -8,7 +12,7 @@ module Inspec::Reporters
8
12
  testsuites = REXML::Element.new("testsuites")
9
13
  xml_output.add(testsuites)
10
14
 
11
- run_data[:profiles].each do |profile|
15
+ run_data.profiles.each do |profile|
12
16
  testsuites.add(build_profile_xml(profile))
13
17
  end
14
18
 
@@ -18,20 +22,16 @@ module Inspec::Reporters
18
22
  output(formatter.write(xml_output.root, ""))
19
23
  end
20
24
 
21
- private
22
-
23
25
  def build_profile_xml(profile)
24
26
  profile_xml = REXML::Element.new("testsuite")
25
- profile_xml.add_attribute("name", profile[:name])
27
+ profile_xml.add_attribute("name", profile.name)
26
28
  profile_xml.add_attribute("tests", count_profile_tests(profile))
27
29
  profile_xml.add_attribute("failed", count_profile_failed_tests(profile))
28
30
  profile_xml.add_attribute("failures", count_profile_failed_tests(profile))
29
31
 
30
- profile[:controls].each do |control|
31
- next if control[:results].nil?
32
-
33
- control[:results].each do |result|
34
- profile_xml.add(build_result_xml(profile[:name], control, result))
32
+ profile.controls.each do |control|
33
+ control.results.each do |result|
34
+ profile_xml.add(build_result_xml(profile.name, control, result))
35
35
  end
36
36
  end
37
37
 
@@ -40,16 +40,16 @@ module Inspec::Reporters
40
40
 
41
41
  def build_result_xml(profile_name, control, result)
42
42
  result_xml = REXML::Element.new("testcase")
43
- result_xml.add_attribute("name", result[:code_desc])
44
- result_xml.add_attribute("classname", control[:title].nil? ? "#{profile_name}.Anonymous" : "#{profile_name}.#{control[:id]}")
45
- result_xml.add_attribute("target", run_data[:platform][:target].nil? ? "" : run_data[:platform][:target].to_s)
46
- result_xml.add_attribute("time", result[:run_time])
43
+ result_xml.add_attribute("name", result.code_desc)
44
+ result_xml.add_attribute("classname", control.title.nil? ? "#{profile_name}.Anonymous" : "#{profile_name}.#{control.id}")
45
+ result_xml.add_attribute("target", run_data.platform.target.nil? ? "" : run_data.platform.target.to_s)
46
+ result_xml.add_attribute("time", result.run_time)
47
47
 
48
- if result[:status] == "failed"
48
+ if result.status == "failed"
49
49
  failure_element = REXML::Element.new("failure")
50
50
  failure_element.add_attribute("message", result[:message])
51
51
  result_xml.add(failure_element)
52
- elsif result[:status] == "skipped"
52
+ elsif result.status == "skipped"
53
53
  result_xml.add_element("skipped")
54
54
  end
55
55
 
@@ -57,19 +57,15 @@ module Inspec::Reporters
57
57
  end
58
58
 
59
59
  def count_profile_tests(profile)
60
- profile[:controls].reduce(0) do |acc, elem|
61
- acc + (elem[:results].nil? ? 0 : elem[:results].count)
60
+ profile.controls.reduce(0) do |acc, elem|
61
+ acc + elem.results.count
62
62
  end
63
63
  end
64
64
 
65
65
  def count_profile_failed_tests(profile)
66
- profile[:controls].reduce(0) do |acc, elem|
67
- if elem[:results].nil?
68
- acc
69
- else
70
- acc + elem[:results].reduce(0) do |fail_test_total, test_case|
71
- test_case[:status] == "failed" ? fail_test_total + 1 : fail_test_total
72
- end
66
+ profile.controls.reduce(0) do |acc, elem|
67
+ acc + elem.results.reduce(0) do |fail_test_total, test_case|
68
+ test_case.status == "failed" ? fail_test_total + 1 : fail_test_total
73
69
  end
74
70
  end
75
71
  end
@@ -0,0 +1,5 @@
1
+ module InspecPlugins
2
+ module JUnitReporter
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.21.1
4
+ version: 4.22.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry
@@ -68,16 +68,22 @@ dependencies:
68
68
  name: json_schemer
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 0.2.1
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.2.12
74
77
  type: :runtime
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
77
80
  requirements:
78
- - - "~>"
81
+ - - ">="
79
82
  - !ruby/object:Gem::Version
80
83
  version: 0.2.1
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: 0.2.12
81
87
  - !ruby/object:Gem::Dependency
82
88
  name: method_source
83
89
  requirement: !ruby/object:Gem::Requirement
@@ -314,20 +320,6 @@ dependencies:
314
320
  - - "~>"
315
321
  - !ruby/object:Gem::Version
316
322
  version: '3.0'
317
- - !ruby/object:Gem::Dependency
318
- name: htmlentities
319
- requirement: !ruby/object:Gem::Requirement
320
- requirements:
321
- - - "~>"
322
- - !ruby/object:Gem::Version
323
- version: '4.3'
324
- type: :runtime
325
- prerelease: false
326
- version_requirements: !ruby/object:Gem::Requirement
327
- requirements:
328
- - - "~>"
329
- - !ruby/object:Gem::Version
330
- version: '4.3'
331
323
  - !ruby/object:Gem::Dependency
332
324
  name: multipart-post
333
325
  requirement: !ruby/object:Gem::Requirement
@@ -342,20 +334,6 @@ dependencies:
342
334
  - - "~>"
343
335
  - !ruby/object:Gem::Version
344
336
  version: '2.0'
345
- - !ruby/object:Gem::Dependency
346
- name: term-ansicolor
347
- requirement: !ruby/object:Gem::Requirement
348
- requirements:
349
- - - "~>"
350
- - !ruby/object:Gem::Version
351
- version: '1.7'
352
- type: :runtime
353
- prerelease: false
354
- version_requirements: !ruby/object:Gem::Requirement
355
- requirements:
356
- - - "~>"
357
- - !ruby/object:Gem::Version
358
- version: '1.7'
359
337
  - !ruby/object:Gem::Dependency
360
338
  name: train-core
361
339
  requirement: !ruby/object:Gem::Requirement
@@ -383,7 +361,6 @@ extra_rdoc_files: []
383
361
  files:
384
362
  - Gemfile
385
363
  - LICENSE
386
- - README.md
387
364
  - etc/deprecations.json
388
365
  - etc/plugin_filters.json
389
366
  - inspec-core.gemspec
@@ -483,7 +460,6 @@ files:
483
460
  - lib/inspec/reporters/cli.rb
484
461
  - lib/inspec/reporters/json.rb
485
462
  - lib/inspec/reporters/json_automate.rb
486
- - lib/inspec/reporters/junit.rb
487
463
  - lib/inspec/reporters/yaml.rb
488
464
  - lib/inspec/require_loader.rb
489
465
  - lib/inspec/resource.rb
@@ -601,6 +577,8 @@ files:
601
577
  - lib/inspec/resources/vbscript.rb
602
578
  - lib/inspec/resources/virtualization.rb
603
579
  - lib/inspec/resources/windows_feature.rb
580
+ - lib/inspec/resources/windows_firewall.rb
581
+ - lib/inspec/resources/windows_firewall_rule.rb
604
582
  - lib/inspec/resources/windows_hotfix.rb
605
583
  - lib/inspec/resources/windows_registry_key.rb
606
584
  - lib/inspec/resources/windows_task.rb
@@ -740,6 +718,10 @@ files:
740
718
  - lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min.rb
741
719
  - lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min/reporter.rb
742
720
  - lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min/version.rb
721
+ - lib/plugins/inspec-reporter-junit/README.md
722
+ - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb
723
+ - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb
724
+ - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/version.rb
743
725
  - lib/plugins/shared/core_plugin_test_helper.rb
744
726
  - lib/plugins/things-for-train-integration.rb
745
727
  - lib/source_readers/flat.rb
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 &amp; 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.