inspec-reporter-honeycomb 0.1.2 → 0.1.5
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.
- checksums.yaml +4 -4
- data/lib/inspec-reporter-honeycomb/reporter.rb +122 -32
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a8e894a1f5773a7dbfec2acf30dde30e556c46378f12a09e916a782a476588e
|
4
|
+
data.tar.gz: e6ad1c6e8c297b22f09aee6b03bfd864ea1f5956469f37a06bf88f1eb30dea97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4bfef6d8d1ab99b4cdbcf54d9049f99f6be89830784758136c7488d60c36a6cd13093c3b43fb570bbfc843dee1d9111d6df5e8028cbbcc22cf580b741773163
|
7
|
+
data.tar.gz: 4ab196b5290d34d8a8685426139467a8de1fe04489ad1aac536e2473e1b5679c3f0ee29fd7c9ab578f188e5244481cc6b186f9cc7a1e4841b9f0dee7a245ce7b
|
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
2
|
require 'inspec/plugin/v2'
|
3
3
|
require 'json'
|
4
|
-
require
|
4
|
+
require 'socket'
|
5
|
+
require 'securerandom' unless defined?(SecureRandom)
|
5
6
|
|
6
7
|
module InspecPlugins::HoneycombReporter
|
7
8
|
# Reporter Plugin Class
|
@@ -15,10 +16,14 @@ module InspecPlugins::HoneycombReporter
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def report
|
18
|
-
report = Inspec::Reporters::
|
19
|
+
report = Inspec::Reporters::JsonAutomate.new(@config).report
|
19
20
|
trace_id = SecureRandom.hex(16)
|
20
21
|
root_span_id = SecureRandom.hex(8)
|
21
22
|
trace_batch = []
|
23
|
+
ip_addresses = []
|
24
|
+
Socket.ip_address_list.each do |ipaddr|
|
25
|
+
ip_addresses << ipaddr.ip_address unless ipaddr.ip_address == '127.0.0.1'
|
26
|
+
end
|
22
27
|
root_span_data = Hash.new
|
23
28
|
root_span_data[:data] = {
|
24
29
|
'trace.trace_id' => trace_id,
|
@@ -26,48 +31,98 @@ module InspecPlugins::HoneycombReporter
|
|
26
31
|
'service.name' => 'compliance',
|
27
32
|
'name' => 'inspec-run',
|
28
33
|
'platform.name' => report[:platform][:name],
|
34
|
+
'platform.release' => report[:platform][:release],
|
29
35
|
'duration' => report[:statistics][:duration]*1000,
|
30
36
|
'version' => report[:version],
|
37
|
+
'hostname' => Socket.gethostname,
|
38
|
+
'arch' => ::RbConfig::CONFIG['arch'],
|
39
|
+
'os' => ::RbConfig::CONFIG['host_os'],
|
40
|
+
'ip_addresses' => ip_addresses,
|
31
41
|
}
|
32
42
|
|
33
43
|
trace_batch << root_span_data
|
34
44
|
|
35
45
|
report[:profiles].each do |profile|
|
36
46
|
profile_span_id = SecureRandom.hex(8)
|
47
|
+
profile_duration = 0.0
|
48
|
+
profile_statuses = []
|
49
|
+
profile_name = profile[:name]
|
50
|
+
profile_title = profile[:title]
|
51
|
+
profile_version = profile[:version]
|
52
|
+
profile_attributes = profile[:attributes]
|
37
53
|
profile[:controls].each do |control|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
duration: result[:run_time],
|
50
|
-
)
|
51
|
-
end
|
52
|
-
control.tap { |ct| ct.delete(:results) }
|
54
|
+
control_span_id = SecureRandom.hex(8)
|
55
|
+
control_duration = 0.0
|
56
|
+
control_statuses = []
|
57
|
+
control_name = control[:name]
|
58
|
+
control_id = control[:id]
|
59
|
+
control_desc = control[:desc]
|
60
|
+
control_impact = control[:impact]
|
61
|
+
control[:results].each do |result|
|
62
|
+
result_span_id = SecureRandom.hex(8)
|
63
|
+
control_duration += result[:run_time]
|
64
|
+
control_statuses << result[:status]
|
53
65
|
trace_batch << generate_span_data(
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
parent_id: control_span_id,
|
67
|
+
span_id: result_span_id,
|
68
|
+
trace_id: trace_id,
|
69
|
+
data: result,
|
70
|
+
platform: report[:platform][:name],
|
71
|
+
platform_release: report[:platform][:release],
|
72
|
+
type: 'result',
|
73
|
+
name: result[:code_desc],
|
74
|
+
duration: result[:run_time],
|
75
|
+
profile_name: profile_name,
|
76
|
+
profile_title: profile_title,
|
77
|
+
profile_version: profile_version,
|
78
|
+
profile_attributes: profile_attributes,
|
79
|
+
control_name: control_name,
|
80
|
+
control_id: control_id,
|
81
|
+
control_desc: control_desc,
|
82
|
+
control_impact: control_impact,
|
61
83
|
)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
84
|
+
end
|
85
|
+
control.tap { |ct| ct.delete(:results) }
|
86
|
+
profile_duration += control_duration
|
87
|
+
profile_statuses += control_statuses
|
88
|
+
control_status = get_status(control_statuses)
|
89
|
+
trace_batch << generate_span_data(
|
90
|
+
parent_id: profile_span_id,
|
91
|
+
span_id: control_span_id,
|
67
92
|
trace_id: trace_id,
|
68
|
-
data:
|
93
|
+
data: control,
|
94
|
+
status: control_status,
|
69
95
|
platform: report[:platform][:name],
|
70
|
-
|
96
|
+
platform_release: report[:platform][:release],
|
97
|
+
type: 'control',
|
98
|
+
duration: control_duration,
|
99
|
+
name: control[:title],
|
100
|
+
profile_name: profile_name,
|
101
|
+
profile_title: profile_title,
|
102
|
+
profile_version: profile_version,
|
103
|
+
profile_attributes: profile_attributes,
|
104
|
+
control_name: control_name,
|
105
|
+
control_id: control_id,
|
106
|
+
control_desc: control_desc,
|
107
|
+
control_impact: control_impact,
|
108
|
+
)
|
109
|
+
end
|
110
|
+
profile.tap { |pf| pf.delete(:controls); pf.delete(:status) }
|
111
|
+
profile_status = get_status(profile_statuses)
|
112
|
+
trace_batch << generate_span_data(
|
113
|
+
parent_id: root_span_id,
|
114
|
+
span_id: profile_span_id,
|
115
|
+
trace_id: trace_id,
|
116
|
+
data: profile,
|
117
|
+
status: profile_status,
|
118
|
+
platform: report[:platform][:name],
|
119
|
+
platform_release: report[:platform][:release],
|
120
|
+
duration: profile_duration,
|
121
|
+
type: 'profile',
|
122
|
+
profile_name: profile_name,
|
123
|
+
profile_title: profile_title,
|
124
|
+
profile_version: profile_version,
|
125
|
+
profile_attributes: profile_attributes,
|
71
126
|
)
|
72
127
|
end
|
73
128
|
|
@@ -91,7 +146,7 @@ module InspecPlugins::HoneycombReporter
|
|
91
146
|
|
92
147
|
res = http.request(req)
|
93
148
|
if res.is_a?(Net::HTTPSuccess)
|
94
|
-
|
149
|
+
Inspec::Log.debug "send_report: Honeycomb POST to #{uri.path} succeeded and returned: #{res.body} "
|
95
150
|
else
|
96
151
|
Inspec::Log.error "send_report: POST to #{uri.path} returned: #{res.body}"
|
97
152
|
false
|
@@ -100,10 +155,31 @@ module InspecPlugins::HoneycombReporter
|
|
100
155
|
Inspec::Log.error "send_report: POST to #{uri.path} returned: #{e.message}"
|
101
156
|
false
|
102
157
|
end
|
158
|
+
Inspec::Log.debug "Successfully sent report"
|
103
159
|
end
|
104
160
|
|
105
161
|
private
|
106
162
|
|
163
|
+
def safe_time(time)
|
164
|
+
if time.nil?
|
165
|
+
nil
|
166
|
+
else
|
167
|
+
time.iso8601(fraction_digits = 3)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def get_status(status_array)
|
172
|
+
if status_array.include?('failed')
|
173
|
+
'failed'
|
174
|
+
elsif status_array.include?('skipped') && !status_array.include?('passed')
|
175
|
+
'skipped'
|
176
|
+
elsif status_array.empty?
|
177
|
+
'skipped'
|
178
|
+
else
|
179
|
+
'passed'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
107
183
|
def generate_span_data(**args)
|
108
184
|
|
109
185
|
time_in_ms = args[:duration] ? args[:duration] * 1000 : 0
|
@@ -113,9 +189,23 @@ module InspecPlugins::HoneycombReporter
|
|
113
189
|
'service.name' => 'compliance',
|
114
190
|
'trace.parent_id' => args[:parent_id],
|
115
191
|
'platform.name' => args[:platform],
|
192
|
+
'platform.release' => args[:platform_release],
|
193
|
+
'status' => args[:status],
|
116
194
|
'type' => args[:type],
|
117
195
|
'name' => args[:name],
|
118
196
|
'duration' => time_in_ms,
|
197
|
+
'hostname' => Socket.gethostname,
|
198
|
+
'arch' => ::RbConfig::CONFIG['arch'],
|
199
|
+
'os' => ::RbConfig::CONFIG['host_os'],
|
200
|
+
'ip_addresses' => ip_addresses,
|
201
|
+
'profile.name' => args[:profile_name],
|
202
|
+
'profile.title' => args[:profile_title],
|
203
|
+
'profile.version' => args[:profile_version],
|
204
|
+
'profile.attributes' => args[:profile_attributes],
|
205
|
+
'control.name' => args[:control_name],
|
206
|
+
'control.id' => args[:control_id],
|
207
|
+
'control.desc' => args[:control_desc],
|
208
|
+
'control.impact' => args[:control_impact],
|
119
209
|
}
|
120
210
|
|
121
211
|
args[:data].each do |k,v|
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec-reporter-honeycomb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Dufour
|
8
|
+
- Davin Taddeo
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2022-
|
12
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: inspec
|
@@ -27,6 +28,7 @@ dependencies:
|
|
27
28
|
description: InSpec Reporter plugin to report Otel formatted traces to Honeycomb.
|
28
29
|
email:
|
29
30
|
- andy.k.dufour@gmail.com
|
31
|
+
- davin@davintaddeo.com
|
30
32
|
executables: []
|
31
33
|
extensions: []
|
32
34
|
extra_rdoc_files: []
|