inspec-core 4.22.8 → 4.23.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -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 +11 -1
  6. data/lib/inspec/cli.rb +4 -2
  7. data/lib/inspec/config.rb +19 -1
  8. data/lib/inspec/input.rb +4 -3
  9. data/lib/inspec/input_registry.rb +7 -1
  10. data/lib/inspec/plugin/v2/plugin_types/reporter.rb +4 -31
  11. data/lib/inspec/reporters.rb +0 -3
  12. data/lib/inspec/reporters/automate.rb +3 -3
  13. data/lib/inspec/reporters/base.rb +7 -29
  14. data/lib/inspec/resources/apt.rb +5 -5
  15. data/lib/inspec/resources/bridge.rb +1 -1
  16. data/lib/inspec/resources/host.rb +1 -1
  17. data/lib/inspec/resources/mysql_session.rb +9 -5
  18. data/lib/inspec/resources/postgres.rb +1 -1
  19. data/lib/inspec/resources/postgres_session.rb +5 -3
  20. data/lib/inspec/resources/processes.rb +1 -1
  21. data/lib/inspec/resources/windows_firewall.rb +110 -0
  22. data/lib/inspec/resources/windows_firewall_rule.rb +137 -0
  23. data/lib/inspec/rule.rb +8 -8
  24. data/lib/inspec/run_data/profile.rb +3 -2
  25. data/lib/inspec/schema/exec_json.rb +1 -1
  26. data/lib/inspec/shell.rb +3 -3
  27. data/lib/inspec/utils/parser.rb +1 -1
  28. data/lib/inspec/utils/run_data_filters.rb +104 -0
  29. data/lib/inspec/version.rb +1 -1
  30. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +4 -4
  31. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +1 -1
  32. data/lib/plugins/inspec-init/templates/profiles/aws/README.md +1 -1
  33. data/lib/plugins/inspec-reporter-html2/README.md +1 -1
  34. data/lib/plugins/inspec-reporter-junit/README.md +17 -0
  35. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb +21 -0
  36. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb +155 -0
  37. data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/version.rb +5 -0
  38. data/lib/plugins/shared/core_plugin_test_helper.rb +0 -16
  39. metadata +17 -34
  40. data/README.md +0 -474
  41. data/lib/inspec/reporters/junit.rb +0 -77
@@ -1,77 +0,0 @@
1
- module Inspec::Reporters
2
- class Junit < Base
3
- def render
4
- require "rexml/document"
5
- xml_output = REXML::Document.new
6
- xml_output.add(REXML::XMLDecl.new)
7
-
8
- testsuites = REXML::Element.new("testsuites")
9
- xml_output.add(testsuites)
10
-
11
- run_data[:profiles].each do |profile|
12
- testsuites.add(build_profile_xml(profile))
13
- end
14
-
15
- formatter = REXML::Formatters::Pretty.new
16
- formatter.compact = true
17
- output(formatter.write(xml_output.xml_decl, ""))
18
- output(formatter.write(xml_output.root, ""))
19
- end
20
-
21
- private
22
-
23
- def build_profile_xml(profile)
24
- profile_xml = REXML::Element.new("testsuite")
25
- profile_xml.add_attribute("name", profile[:name])
26
- profile_xml.add_attribute("tests", count_profile_tests(profile))
27
- profile_xml.add_attribute("failed", count_profile_failed_tests(profile))
28
- profile_xml.add_attribute("failures", count_profile_failed_tests(profile))
29
-
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))
35
- end
36
- end
37
-
38
- profile_xml
39
- end
40
-
41
- def build_result_xml(profile_name, control, result)
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])
47
-
48
- if result[:status] == "failed"
49
- failure_element = REXML::Element.new("failure")
50
- failure_element.add_attribute("message", result[:message])
51
- result_xml.add(failure_element)
52
- elsif result[:status] == "skipped"
53
- result_xml.add_element("skipped")
54
- end
55
-
56
- result_xml
57
- end
58
-
59
- def count_profile_tests(profile)
60
- profile[:controls].reduce(0) do |acc, elem|
61
- acc + (elem[:results].nil? ? 0 : elem[:results].count)
62
- end
63
- end
64
-
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
73
- end
74
- end
75
- end
76
- end
77
- end