inspec-core 4.20.2 → 4.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/inspec-core.gemspec +1 -1
  4. data/lib/inspec/base_cli.rb +1 -1
  5. data/lib/inspec/cli.rb +6 -5
  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/profile.rb +30 -9
  11. data/lib/inspec/reporters.rb +12 -7
  12. data/lib/inspec/reporters/cli.rb +1 -0
  13. data/lib/inspec/reporters/json.rb +9 -4
  14. data/lib/inspec/resources/apt.rb +2 -0
  15. data/lib/inspec/resources/interface.rb +55 -0
  16. data/lib/inspec/resources/interfaces.rb +119 -0
  17. data/lib/inspec/resources/service.rb +1 -1
  18. data/lib/inspec/run_data.rb +10 -3
  19. data/lib/inspec/run_data/profile.rb +4 -4
  20. data/lib/inspec/runner.rb +8 -2
  21. data/lib/inspec/runner_rspec.rb +4 -1
  22. data/lib/inspec/schema.rb +2 -0
  23. data/lib/inspec/schema/exec_json.rb +4 -3
  24. data/lib/inspec/schema/primitives.rb +1 -1
  25. data/lib/inspec/utils/telemetry/run_context_probe.rb +48 -0
  26. data/lib/inspec/version.rb +1 -1
  27. data/lib/plugins/inspec-reporter-html2/README.md +53 -0
  28. data/lib/plugins/inspec-reporter-html2/lib/inspec-reporter-html2.rb +18 -0
  29. data/lib/plugins/inspec-reporter-html2/lib/inspec-reporter-html2/reporter.rb +24 -0
  30. data/lib/plugins/inspec-reporter-html2/lib/inspec-reporter-html2/version.rb +8 -0
  31. data/lib/plugins/inspec-reporter-html2/templates/body.html.erb +46 -0
  32. data/lib/plugins/inspec-reporter-html2/templates/control.html.erb +77 -0
  33. data/lib/plugins/inspec-reporter-html2/templates/default.css +107 -0
  34. data/lib/plugins/inspec-reporter-html2/templates/default.js +79 -0
  35. data/lib/plugins/inspec-reporter-html2/templates/profile.html.erb +23 -0
  36. data/lib/plugins/inspec-reporter-html2/templates/result.html.erb +15 -0
  37. data/lib/plugins/inspec-reporter-html2/templates/selector.html.erb +8 -0
  38. data/lib/plugins/inspec-reporter-json-min/README.md +10 -0
  39. data/lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min.rb +13 -0
  40. data/lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min/reporter.rb +50 -0
  41. data/lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min/version.rb +5 -0
  42. metadata +21 -5
  43. data/lib/inspec/reporters/json_min.rb +0 -48
@@ -0,0 +1,79 @@
1
+
2
+ /* CSS primitives */
3
+ function addCssClass(id, cls) {
4
+ document.getElementById(id).className += (" " + cls);
5
+ }
6
+
7
+ function removeCssClass(id, cls) {
8
+ var el = document.getElementById(id);
9
+ var classes = el.className.replace(cls,'');
10
+ el.className = classes;
11
+ }
12
+
13
+ function handleShowSource(evt) {
14
+ var control_id = evt.srcElement.id.replace("show-code-", "")
15
+ addCssClass(evt.srcElement.id, "hidden")
16
+ removeCssClass("hide-code-" + control_id, "hidden")
17
+ removeCssClass("source-code-" + control_id, "hidden")
18
+ }
19
+
20
+ function handleHideSource(evt) {
21
+ var control_id = evt.srcElement.id.replace("hide-code-", "")
22
+ addCssClass(evt.srcElement.id, "hidden")
23
+ addCssClass("source-code-" + control_id, "hidden")
24
+ removeCssClass("show-code-" + control_id, "hidden")
25
+ }
26
+
27
+ function handleSelectorChange(evt) {
28
+ var should_show = evt.srcElement.checked
29
+ var which_group = evt.srcElement.id.replace("-checkbox","")
30
+ var controls = document.getElementsByClassName("control-status-" + which_group)
31
+ var i;
32
+ if (should_show) {
33
+ for (i = 0; i < controls.length; i++) {
34
+ removeCssClass(controls[i].id, "hidden")
35
+ }
36
+ } else {
37
+ for (i = 0; i < controls.length; i++) {
38
+ addCssClass(controls[i].id, "hidden")
39
+ }
40
+ }
41
+ }
42
+
43
+ function handleChildProfileChange(evt) {
44
+ var should_show = evt.srcElement.checked
45
+ var child_profiles = document.getElementsByClassName("child-profile")
46
+ var i;
47
+ if (should_show) {
48
+ for (i = 0; i < child_profiles.length; i++) {
49
+ removeCssClass(child_profiles[i].id, "hidden")
50
+ }
51
+ } else {
52
+ for (i = 0; i < child_profiles.length; i++) {
53
+ addCssClass(child_profiles[i].id, "hidden")
54
+ }
55
+ }
56
+ }
57
+
58
+ /* Main entry point */
59
+ function pageLoaded() {
60
+ var i;
61
+
62
+ // wire up show source links
63
+ var show_links = document.getElementsByClassName("show-source-code");
64
+ for (i = 0; i < show_links.length; i++) {
65
+ show_links[i].onclick = handleShowSource;
66
+ }
67
+ // wire up hide source links
68
+ var hide_links = document.getElementsByClassName("hide-source-code");
69
+ for (i = 0; i < hide_links.length; i++) {
70
+ hide_links[i].onclick = handleHideSource;
71
+ }
72
+ // wire up selector checkboxes
73
+ var selectors = document.getElementsByClassName("selector-checkbox");
74
+ for (i = 0; i < selectors.length; i++) {
75
+ selectors[i].onchange = handleSelectorChange;
76
+ }
77
+ // wire up child profile checkbox
78
+ document.getElementById("child-profile-checkbox").onchange = handleChildProfileChange;
79
+ }
@@ -0,0 +1,23 @@
1
+ <div class="profile <%= profile.parent_profile ? "child-profile hidden" : "" %>" id="profile-<%= profile.name %>">
2
+ <% display_name = profile.title || profile.name %>
3
+ <h2 class="profile_title">Profile <%= display_name %> (<%= profile.name %>)</h2>
4
+
5
+ <table class="profile-metadata info" id="profile-metadata-<%= profile.name %>">
6
+ <tr class="profile-version"><th>Version:</th><td><%= profile.version %></td></tr>
7
+ <% if profile.summary %>
8
+ <tr class="profile-summary"><th>Summary:</th><td><%= profile.summary %></td></tr>
9
+ <% end %>
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>
15
+ <% end %>
16
+ </table>
17
+
18
+ <% if profile.status == "loaded" %>
19
+ <% profile.controls.each do |control| %>
20
+ <%= ERB.new(File.read(template_path + "/control.html.erb"), nil, nil, "_ctl").result(binding) %>
21
+ <% end %>
22
+ <% end %>
23
+ </div>
@@ -0,0 +1,15 @@
1
+ <% slugged_id = result.resource_title.to_s.gsub(/\W/, "_") %>
2
+ <div class="result" id="result-<%= slugged_id %>">
3
+ <h4 class="resource-title">Resource <code><%= result.resource_title.to_s %></code></h4>
4
+ <table class="result-metadata info">
5
+ <tr class="expectation_message"><th>Test:</th><td><code><%= result.expectation_message %></code></td></tr>
6
+ <tr class="status status-<%= result.status %>"><th>Status:</th><td><div><%= result.status.capitalize %></div></td></tr>
7
+ <% if result.status == "failed" %>
8
+ <tr class="fail_message"><th>Failure Message:</th><td><code><%= result.message %></code></td></tr>
9
+ <% end %>
10
+ <% if result.status == "skipped" %>
11
+ <tr class="skip_message"><th>Skip Message:</th><td><%= result.skip_message %></td></tr>
12
+ <% end %>
13
+ <tr class="duration"><th>Duration:</th><td><%= result.run_time %> seconds</td></tr>
14
+ </table>
15
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="selector-panel">
2
+ <p id="selector-instructions">Display controls that are:</p>
3
+ <input class="selector-checkbox" id="passed-checkbox" type="checkbox" checked="checked"/><label for="passed-checkbox">Passed</label>
4
+ <input class="selector-checkbox" id="skipped-checkbox" type="checkbox" checked="checked"/><label for="skipped-checkbox">Skipped</label>
5
+ <input class="selector-checkbox" id="failed-checkbox" type="checkbox" checked="checked"/><label for="failed-checkbox">Failed</label>
6
+ <p id="selector-instructions">Display profiles that are:</p>
7
+ <input class="profile-selector-checkbox" id="child-profile-checkbox" type="checkbox" /><label for="child-profile-checkbox">Dependent Profiles</label>
8
+ </div>
@@ -0,0 +1,10 @@
1
+ # JSON Minimal Reporter Plugin
2
+
3
+ ## To Install This Plugin
4
+
5
+ This plugin is included with InSpec. There is no need to install it.
6
+
7
+ ## What This Plugin Does
8
+
9
+ This plugin provides the `json-min` reporter, which produces test output in JSON format with less detail than the `json` reporter.
10
+
@@ -0,0 +1,13 @@
1
+ require_relative "inspec-reporter-json-min/version"
2
+
3
+ module InspecPlugins
4
+ module JsonMinReporter
5
+ class Plugin < ::Inspec.plugin(2)
6
+ plugin_name :"inspec-reporter-json-min"
7
+ reporter :"json-min" do
8
+ require_relative "inspec-reporter-json-min/reporter"
9
+ InspecPlugins::JsonMinReporter::Reporter
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,50 @@
1
+ require "json"
2
+
3
+ module InspecPlugins::JsonMinReporter
4
+ class Reporter < Inspec.plugin(2, :reporter)
5
+ def self.run_data_schema_constraints
6
+ "~> 0.0"
7
+ end
8
+
9
+ def render
10
+ output(report.to_json, false)
11
+ end
12
+
13
+ def report # rubocop:disable Metrics/AbcSize
14
+ report = {
15
+ controls: [],
16
+ statistics: { duration: run_data.statistics.duration },
17
+ version: run_data.version,
18
+ }
19
+
20
+ # collect all test results and add them to the report
21
+ run_data.profiles.each do |profile|
22
+ profile_id = profile.name
23
+
24
+ profile.controls.each do |control|
25
+ control_id = control.id
26
+
27
+ control.results.each do |result|
28
+ result_for_report = {
29
+ id: control_id,
30
+ profile_id: profile_id,
31
+ profile_sha256: profile.sha256,
32
+ status: result.status,
33
+ code_desc: result.code_desc,
34
+ }
35
+
36
+ result_for_report[:skip_message] = result.skip_message if result.non_nil?(:skip_message)
37
+ result_for_report[:resource] = result.resource if result.non_nil?(:resource)
38
+ result_for_report[:message] = result.message if result.non_nil?(:message)
39
+ result_for_report[:exception] = result.exception if result.non_nil?(:exception)
40
+ result_for_report[:backtrace] = result.backtrace if result.non_nil?(:backtrace)
41
+
42
+ report[:controls] << result_for_report
43
+ end
44
+ end
45
+ end
46
+
47
+ report
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ module InspecPlugins
2
+ module JsonMinReporter
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.20.2
4
+ version: 4.22.0
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-09 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry
@@ -264,14 +264,14 @@ dependencies:
264
264
  requirements:
265
265
  - - "~>"
266
266
  - !ruby/object:Gem::Version
267
- version: '1.2'
267
+ version: 1.2.0
268
268
  type: :runtime
269
269
  prerelease: false
270
270
  version_requirements: !ruby/object:Gem::Requirement
271
271
  requirements:
272
272
  - - "~>"
273
273
  - !ruby/object:Gem::Version
274
- version: '1.2'
274
+ version: 1.2.0
275
275
  - !ruby/object:Gem::Dependency
276
276
  name: addressable
277
277
  requirement: !ruby/object:Gem::Requirement
@@ -483,7 +483,6 @@ files:
483
483
  - lib/inspec/reporters/cli.rb
484
484
  - lib/inspec/reporters/json.rb
485
485
  - lib/inspec/reporters/json_automate.rb
486
- - lib/inspec/reporters/json_min.rb
487
486
  - lib/inspec/reporters/junit.rb
488
487
  - lib/inspec/reporters/yaml.rb
489
488
  - lib/inspec/require_loader.rb
@@ -537,6 +536,7 @@ files:
537
536
  - lib/inspec/resources/inetd_conf.rb
538
537
  - lib/inspec/resources/ini.rb
539
538
  - lib/inspec/resources/interface.rb
539
+ - lib/inspec/resources/interfaces.rb
540
540
  - lib/inspec/resources/ip6tables.rb
541
541
  - lib/inspec/resources/iptables.rb
542
542
  - lib/inspec/resources/json.rb
@@ -667,6 +667,7 @@ files:
667
667
  - lib/inspec/utils/telemetry/collector.rb
668
668
  - lib/inspec/utils/telemetry/data_series.rb
669
669
  - lib/inspec/utils/telemetry/global_methods.rb
670
+ - lib/inspec/utils/telemetry/run_context_probe.rb
670
671
  - lib/inspec/version.rb
671
672
  - lib/matchers/matchers.rb
672
673
  - lib/plugins/README.md
@@ -724,6 +725,21 @@ files:
724
725
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb
725
726
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb
726
727
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb
728
+ - lib/plugins/inspec-reporter-html2/README.md
729
+ - lib/plugins/inspec-reporter-html2/lib/inspec-reporter-html2.rb
730
+ - lib/plugins/inspec-reporter-html2/lib/inspec-reporter-html2/reporter.rb
731
+ - lib/plugins/inspec-reporter-html2/lib/inspec-reporter-html2/version.rb
732
+ - lib/plugins/inspec-reporter-html2/templates/body.html.erb
733
+ - lib/plugins/inspec-reporter-html2/templates/control.html.erb
734
+ - lib/plugins/inspec-reporter-html2/templates/default.css
735
+ - lib/plugins/inspec-reporter-html2/templates/default.js
736
+ - lib/plugins/inspec-reporter-html2/templates/profile.html.erb
737
+ - lib/plugins/inspec-reporter-html2/templates/result.html.erb
738
+ - lib/plugins/inspec-reporter-html2/templates/selector.html.erb
739
+ - lib/plugins/inspec-reporter-json-min/README.md
740
+ - lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min.rb
741
+ - lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min/reporter.rb
742
+ - lib/plugins/inspec-reporter-json-min/lib/inspec-reporter-json-min/version.rb
727
743
  - lib/plugins/shared/core_plugin_test_helper.rb
728
744
  - lib/plugins/things-for-train-integration.rb
729
745
  - lib/source_readers/flat.rb
@@ -1,48 +0,0 @@
1
- require "json"
2
-
3
- module Inspec::Reporters
4
- class JsonMin < Base
5
- def render
6
- output(report.to_json, false)
7
- end
8
-
9
- def report # rubocop:disable Metrics/AbcSize
10
- report = {
11
- controls: [],
12
- statistics: { duration: run_data[:statistics][:duration] },
13
- version: run_data[:version],
14
- }
15
-
16
- # collect all test results and add them to the report
17
- run_data[:profiles].each do |profile|
18
- profile_id = profile[:name]
19
- next unless profile[:controls]
20
-
21
- profile[:controls].each do |control|
22
- control_id = control[:id]
23
- next unless control[:results]
24
-
25
- control[:results].each do |result|
26
- result_for_report = {
27
- id: control_id,
28
- profile_id: profile_id,
29
- profile_sha256: profile[:sha256],
30
- status: result[:status],
31
- code_desc: result[:code_desc],
32
- }
33
-
34
- result_for_report[:skip_message] = result[:skip_message] if result.key?(:skip_message)
35
- result_for_report[:resource] = result[:resource] if result.key?(:resource)
36
- result_for_report[:message] = result[:message] if result.key?(:message)
37
- result_for_report[:exception] = result[:exception] if result.key?(:exception)
38
- result_for_report[:backtrace] = result[:backtrace] if result.key?(:backtrace)
39
-
40
- report[:controls] << result_for_report
41
- end
42
- end
43
- end
44
-
45
- report
46
- end
47
- end
48
- end