inspec-core 4.23.4 → 4.23.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/inspec-core.gemspec +1 -1
- data/lib/inspec/resources/apt.rb +5 -5
- data/lib/inspec/schema/exec_json.rb +1 -1
- data/lib/inspec/shell.rb +3 -3
- data/lib/inspec/version.rb +1 -1
- data/lib/plugins/inspec-init/templates/profiles/aws/README.md +1 -1
- data/lib/plugins/inspec-reporter-html2/README.md +1 -1
- data/lib/plugins/inspec-reporter-junit/README.md +9 -7
- data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb +10 -1
- data/lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb +93 -11
- data/lib/plugins/shared/core_plugin_test_helper.rb +0 -16
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79519a204dd8255bc903a9f3c47fc50342fca2cf6d0b443dddbdbe2e2ecbb0f8
|
4
|
+
data.tar.gz: 143120b4ad5168d123f7e74933857e72a38df54684df5871b6bad094c12e50d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d800448760f522785b01eb15a8cbc28d5d81adc3a99b8588d7e89337e29b5c3e1130e6b59e6236271ec38d57b7f6c3bcf363f6333a692b5e7f0efad36642a94
|
7
|
+
data.tar.gz: 8cc2972c7e77cca96ef0d70872583f2ce39cc945e579e9b36d1b635d646f213cdbd91bd642b7631dce92b263e33c304516a882ef5e31bc24f1254090b9805611
|
data/Gemfile
CHANGED
data/inspec-core.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "mixlib-log", "~> 3.0"
|
37
37
|
spec.add_dependency "sslshake", "~> 1.2"
|
38
38
|
spec.add_dependency "parallel", "~> 1.9"
|
39
|
-
spec.add_dependency "faraday", ">= 0.9.0"
|
39
|
+
spec.add_dependency "faraday", ">= 0.9.0", "< 1.1"
|
40
40
|
spec.add_dependency "tty-table", "~> 0.10"
|
41
41
|
spec.add_dependency "tty-prompt", "~> 0.17"
|
42
42
|
spec.add_dependency "tomlrb", "~> 1.2.0"
|
data/lib/inspec/resources/apt.rb
CHANGED
@@ -87,13 +87,13 @@ module Inspec::Resources
|
|
87
87
|
active = raw_line == line
|
88
88
|
|
89
89
|
# formats:
|
90
|
-
# deb
|
91
|
-
# deb
|
92
|
-
# deb [trusted=yes]
|
90
|
+
# deb "http://archive.ubuntu.com/ubuntu/" wily main restricted ...
|
91
|
+
# deb http://archive.ubuntu.com/ubuntu/ wily main restricted ...
|
92
|
+
# deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted ...
|
93
|
+
# deb [arch=amd64 trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted ...
|
93
94
|
# deb cdrom:[Ubuntu 15.10 _Wily Werewolf_ - Release amd64 (20151021)]/ wily main restricted ...
|
94
95
|
|
95
|
-
words = line.split
|
96
|
-
words.delete_at 1 if words[1] && words[1].start_with?("[")
|
96
|
+
words = line.sub(/^(deb|deb-src)\s+\[.+?\]/, '\1').split
|
97
97
|
type, url, distro, *components = words
|
98
98
|
url = url.delete('"') if url
|
99
99
|
|
@@ -74,7 +74,7 @@ module Inspec
|
|
74
74
|
},
|
75
75
|
}, [CONTROL_DESCRIPTION, Primitives::REFERENCE, Primitives::SOURCE_LOCATION, CONTROL_RESULT])
|
76
76
|
|
77
|
-
# Based loosely on https://
|
77
|
+
# Based loosely on https://docs.chef.io/inspec/profiles/ as of July 3, 2019
|
78
78
|
# However, concessions were made to the reality of current reporters, specifically
|
79
79
|
# with how description is omitted and version/inspec_version aren't as advertised online
|
80
80
|
PROFILE = Primitives::SchemaType.new("Exec JSON Profile", {
|
data/lib/inspec/shell.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
autoload :Pry, "pry"
|
2
2
|
|
3
3
|
module Inspec
|
4
4
|
# A pry based shell for inspec. Given a runner (with a configured backend and
|
@@ -137,7 +137,7 @@ module Inspec
|
|
137
137
|
end
|
138
138
|
|
139
139
|
info += "#{mark "Web Reference:"}\n\n"
|
140
|
-
info += "https://
|
140
|
+
info += "https://docs.chef.io/inspec/resources/#{topic}\n\n"
|
141
141
|
puts info
|
142
142
|
else
|
143
143
|
begin
|
@@ -208,7 +208,7 @@ module Inspec
|
|
208
208
|
|
209
209
|
its('content') { should_not match /^MyKey:\\s+some value/ }
|
210
210
|
|
211
|
-
For more examples, see: https://
|
211
|
+
For more examples, see: https://docs.chef.io/inspec/matchers/
|
212
212
|
|
213
213
|
EOL
|
214
214
|
end
|
data/lib/inspec/version.rb
CHANGED
@@ -26,7 +26,7 @@ Creating new profile at /Users/spaterson/my-profile
|
|
26
26
|
aws_vpc_id: 'custom-vpc-id'
|
27
27
|
```
|
28
28
|
|
29
|
-
The related control will simply be skipped if this is not provided. See the [InSpec DSL documentation](https://
|
29
|
+
The related control will simply be skipped if this is not provided. See the [InSpec DSL documentation](https://docs.chef.io/inspec/dsl_inspec/) for more details on conditional execution using `only_if`.
|
30
30
|
|
31
31
|
## Run the tests
|
32
32
|
|
@@ -24,7 +24,7 @@ Note the `2` in the reporter name. If you omit it and run `--reporter html` inst
|
|
24
24
|
|
25
25
|
## Configuring the Plugin
|
26
26
|
|
27
|
-
The `html2` reporter requires no configuration to function. However, two options--`alternate_css_file` and `alternate_js_file`--are available for customization. The options are set in the JSON-formatted configuration file that Chef InSpec consumes. For details, see [our configuration file documentation](https://
|
27
|
+
The `html2` reporter requires no configuration to function. However, two options--`alternate_css_file` and `alternate_js_file`--are available for customization. The options are set in the JSON-formatted configuration file that Chef InSpec consumes. For details, see [our configuration file documentation](https://docs.chef.io/inspec/config/).
|
28
28
|
|
29
29
|
For example:
|
30
30
|
|
@@ -1,15 +1,17 @@
|
|
1
|
-
# junit
|
1
|
+
# junit and junit2 reporters
|
2
2
|
|
3
|
-
This is the implementation of the junit XML
|
3
|
+
This is the implementation of the junit and junit2 XML reporters.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Installation
|
6
6
|
|
7
|
-
This plugin
|
7
|
+
This plugin ships with Chef InSpec and requires no additional installation.
|
8
8
|
|
9
|
-
## What
|
9
|
+
## What These Plugins Do
|
10
10
|
|
11
|
-
|
11
|
+
`junit` is the legacy Chef InSpec JUnit reporter, which is retained for backwards compatibility. It generates an XML report in Apache Ant JUnit format. The output format is considered nonstandard in several ways. New users are advised to use `junit2`.
|
12
|
+
|
13
|
+
`junit2` is an updated reporter that provides JUnit output according to the schema published by [Windy Road](https://github.com/windyroad/JUnit-Schema).
|
12
14
|
|
13
15
|
## Implementation Note
|
14
16
|
|
15
|
-
This reporter uses the REXML XML generator, but
|
17
|
+
This reporter uses the REXML XML generator at runtime, but uses Nokogiri, a more heavyweight XML library, for testing. This design keeps packaging requirements lightweight and free of compiled dependencies.
|
@@ -3,10 +3,19 @@ module InspecPlugins
|
|
3
3
|
module JUnitReporter
|
4
4
|
class Plugin < ::Inspec.plugin(2)
|
5
5
|
plugin_name :'inspec-reporter-junit'
|
6
|
+
|
7
|
+
# Legacy JUnit reporter, which generates subtly incorrect XML.
|
6
8
|
reporter :junit do
|
7
9
|
require_relative "inspec-reporter-junit/reporter"
|
8
|
-
InspecPlugins::JUnitReporter::
|
10
|
+
InspecPlugins::JUnitReporter::ReporterV1
|
9
11
|
end
|
12
|
+
|
13
|
+
# v2 reporter, which generates valid JUnit XML.
|
14
|
+
reporter :junit2 do
|
15
|
+
require_relative "inspec-reporter-junit/reporter"
|
16
|
+
InspecPlugins::JUnitReporter::ReporterV2
|
17
|
+
end
|
18
|
+
|
10
19
|
end
|
11
20
|
end
|
12
21
|
end
|
@@ -12,8 +12,8 @@ module InspecPlugins::JUnitReporter
|
|
12
12
|
testsuites = REXML::Element.new("testsuites")
|
13
13
|
xml_output.add(testsuites)
|
14
14
|
|
15
|
-
run_data.profiles.
|
16
|
-
testsuites.add(build_profile_xml(profile))
|
15
|
+
run_data.profiles.each_with_index do |profile, idx|
|
16
|
+
testsuites.add(build_profile_xml(profile, idx))
|
17
17
|
end
|
18
18
|
|
19
19
|
formatter = REXML::Formatters::Pretty.new
|
@@ -22,7 +22,42 @@ module InspecPlugins::JUnitReporter
|
|
22
22
|
output(formatter.write(xml_output.root, ""))
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def count_profile_tests(profile)
|
26
|
+
profile.controls.reduce(0) do |acc, elem|
|
27
|
+
acc + elem.results.count
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def count_profile_failed_tests(profile)
|
32
|
+
profile.controls.reduce(0) do |acc, elem|
|
33
|
+
acc + elem.results.reduce(0) do |fail_test_total, test_case|
|
34
|
+
test_case.status == "failed" ? fail_test_total + 1 : fail_test_total
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def count_profile_skipped_tests(profile)
|
40
|
+
profile.controls.reduce(0) do |acc, elem|
|
41
|
+
acc + elem.results.reduce(0) do |skip_test_total, test_case|
|
42
|
+
test_case.status == "skipped" ? skip_test_total + 1 : skip_test_total
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def count_profile_errored_tests(profile)
|
48
|
+
profile.controls.reduce(0) do |acc, elem|
|
49
|
+
acc + elem.results.reduce(0) do |err_test_total, test_case|
|
50
|
+
test_case.backtrace.nil? ? err_test_total : err_test_total + 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# This is the "Legacy" JUnit reporter. It produces XML which is not
|
57
|
+
# correct according to the JUnit standard. It is retained for backwards
|
58
|
+
# compatibility.
|
59
|
+
class ReporterV1 < Reporter
|
60
|
+
def build_profile_xml(profile, _idx)
|
26
61
|
profile_xml = REXML::Element.new("testsuite")
|
27
62
|
profile_xml.add_attribute("name", profile.name)
|
28
63
|
profile_xml.add_attribute("tests", count_profile_tests(profile))
|
@@ -55,19 +90,66 @@ module InspecPlugins::JUnitReporter
|
|
55
90
|
|
56
91
|
result_xml
|
57
92
|
end
|
93
|
+
end
|
58
94
|
|
59
|
-
|
60
|
-
|
61
|
-
|
95
|
+
# This is the "Corrected" JUnit reporter. It produces XML which is intended
|
96
|
+
# to be valid. It should be used whenever possible.
|
97
|
+
class ReporterV2 < Reporter
|
98
|
+
def build_profile_xml(profile, idx)
|
99
|
+
profile_xml = REXML::Element.new("testsuite")
|
100
|
+
profile_xml.add_attribute("name", profile.name)
|
101
|
+
profile_xml.add_attribute("tests", count_profile_tests(profile))
|
102
|
+
profile_xml.add_attribute("id", idx + 1)
|
103
|
+
|
104
|
+
# junit2 counts failures and errors separately
|
105
|
+
errors = count_profile_errored_tests(profile)
|
106
|
+
profile_xml.add_attribute("errors", errors)
|
107
|
+
profile_xml.add_attribute("failures", count_profile_failed_tests(profile) - errors)
|
108
|
+
profile_xml.add_attribute("skipped", count_profile_skipped_tests(profile))
|
109
|
+
|
110
|
+
profile_xml.add_attribute("hostname", run_data.platform.target.nil? ? "" : run_data.platform.target.to_s)
|
111
|
+
# Author of the schema specified 8601, then went on to add
|
112
|
+
# a regex that requires no TZ
|
113
|
+
profile_xml.add_attribute("timestamp", Time.now.iso8601.slice(0, 19))
|
114
|
+
|
115
|
+
# These are empty but are just here to satisfy the schema
|
116
|
+
profile_xml.add_attribute("package", "")
|
117
|
+
profile_xml.add(REXML::Element.new("properties"))
|
118
|
+
|
119
|
+
profile_time = 0.0
|
120
|
+
profile.controls.each do |control|
|
121
|
+
control.results.each do |result|
|
122
|
+
profile_time += result.run_time
|
123
|
+
profile_xml.add(build_result_xml(profile.name, control, result))
|
124
|
+
end
|
62
125
|
end
|
126
|
+
profile_xml.add_attribute("time", "%.6f" % profile_time)
|
127
|
+
|
128
|
+
profile_xml.add(REXML::Element.new("system-out"))
|
129
|
+
profile_xml.add(REXML::Element.new("system-err"))
|
130
|
+
|
131
|
+
profile_xml
|
63
132
|
end
|
64
133
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
134
|
+
def build_result_xml(profile_name, control, result)
|
135
|
+
result_xml = REXML::Element.new("testcase")
|
136
|
+
result_xml.add_attribute("name", result.code_desc)
|
137
|
+
result_xml.add_attribute("classname", control.title.nil? ? "#{profile_name}.Anonymous" : "#{profile_name}.#{control.id}")
|
138
|
+
|
139
|
+
# <Nokogiri::XML::SyntaxError: 20:0: ERROR: Element 'testcase', attribute 'time': '4.9e-05' is not a valid value of the atomic type 'xs:decimal'.
|
140
|
+
# So, we format it.
|
141
|
+
result_xml.add_attribute("time", "%.6f" % result.run_time)
|
142
|
+
|
143
|
+
if result.status == "failed"
|
144
|
+
failure_element = REXML::Element.new("failure")
|
145
|
+
failure_element.add_attribute("message", result.message)
|
146
|
+
failure_element.add_attribute("type", result.resource_title&.to_s || "")
|
147
|
+
result_xml.add(failure_element)
|
148
|
+
elsif result.status == "skipped"
|
149
|
+
result_xml.add_element("skipped")
|
70
150
|
end
|
151
|
+
|
152
|
+
result_xml
|
71
153
|
end
|
72
154
|
end
|
73
155
|
end
|
@@ -50,22 +50,6 @@ module CorePluginFunctionalHelper
|
|
50
50
|
include CorePluginBaseHelper
|
51
51
|
include FunctionalHelper
|
52
52
|
|
53
|
-
# TODO: so much duplication! Remove everything we can!
|
54
|
-
require "train"
|
55
|
-
TRAIN_CONNECTION = Train.create("local", command_runner: :generic).connection
|
56
|
-
|
57
|
-
# TODO: remove me! it's in test/functional/helper.rb
|
58
|
-
def run_inspec_process(command_line, opts = {})
|
59
|
-
prefix = ""
|
60
|
-
if opts.key?(:prefix)
|
61
|
-
prefix = opts[:prefix]
|
62
|
-
elsif opts.key?(:env)
|
63
|
-
prefix = assemble_env_prefix opts[:env]
|
64
|
-
end
|
65
|
-
|
66
|
-
TRAIN_CONNECTION.run_command("#{prefix} #{exec_inspec} #{command_line}")
|
67
|
-
end
|
68
|
-
|
69
53
|
# This helper does some fancy footwork to make InSpec think a plugin
|
70
54
|
# under development is temporarily installed.
|
71
55
|
# @param String command_line Invocation, without the word 'inspec'
|
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.23.
|
4
|
+
version: 4.23.10
|
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-09-
|
11
|
+
date: 2020-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-telemetry
|
@@ -229,6 +229,9 @@ dependencies:
|
|
229
229
|
- - ">="
|
230
230
|
- !ruby/object:Gem::Version
|
231
231
|
version: 0.9.0
|
232
|
+
- - "<"
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '1.1'
|
232
235
|
type: :runtime
|
233
236
|
prerelease: false
|
234
237
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -236,6 +239,9 @@ dependencies:
|
|
236
239
|
- - ">="
|
237
240
|
- !ruby/object:Gem::Version
|
238
241
|
version: 0.9.0
|
242
|
+
- - "<"
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '1.1'
|
239
245
|
- !ruby/object:Gem::Dependency
|
240
246
|
name: tty-table
|
241
247
|
requirement: !ruby/object:Gem::Requirement
|