inspec-reporter-honeycomb 0.1.3 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inspec-reporter-honeycomb/reporter.rb +117 -30
- 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: 4c2f109b62e34e566f2876df594be1c94ba8092c336dc7fedd03f16c562b3da8
|
4
|
+
data.tar.gz: addc8b0b975c5178d14678213c94ed1c3dbef74866ece256c8ac9971f00394c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdf66219ba779b8c39629edd0c0c75e8ea766eda6a0194d14715b1887c77641efc68f33e7625f7a3738a2e3dd61762e371e0fe2ae9e08e26819d6c7bbaaccb8b
|
7
|
+
data.tar.gz: 1e467ab210fd5e219ccf595766e1dffea6dfe91d5731419be4b5dd09730994bbe7201c4403dba5509bc926c00bf6b8653cf94cec3c51ec9e5db6325edce65ca9
|
@@ -20,6 +20,10 @@ module InspecPlugins::HoneycombReporter
|
|
20
20
|
trace_id = SecureRandom.hex(16)
|
21
21
|
root_span_id = SecureRandom.hex(8)
|
22
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
|
23
27
|
root_span_data = Hash.new
|
24
28
|
root_span_data[:data] = {
|
25
29
|
'trace.trace_id' => trace_id,
|
@@ -27,49 +31,98 @@ module InspecPlugins::HoneycombReporter
|
|
27
31
|
'service.name' => 'compliance',
|
28
32
|
'name' => 'inspec-run',
|
29
33
|
'platform.name' => report[:platform][:name],
|
34
|
+
'platform.release' => report[:platform][:release],
|
30
35
|
'duration' => report[:statistics][:duration]*1000,
|
31
36
|
'version' => report[:version],
|
32
37
|
'hostname' => Socket.gethostname,
|
38
|
+
'arch' => ::RbConfig::CONFIG['arch'],
|
39
|
+
'os' => ::RbConfig::CONFIG['host_os'],
|
40
|
+
'ip_addresses' => ip_addresses,
|
33
41
|
}
|
34
42
|
|
35
43
|
trace_batch << root_span_data
|
36
44
|
|
37
45
|
report[:profiles].each do |profile|
|
38
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]
|
39
53
|
profile[:controls].each do |control|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
duration: result[:run_time],
|
52
|
-
)
|
53
|
-
end
|
54
|
-
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]
|
55
65
|
trace_batch << generate_span_data(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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,
|
63
83
|
)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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,
|
69
92
|
trace_id: trace_id,
|
70
|
-
data:
|
93
|
+
data: control,
|
94
|
+
status: control_status,
|
71
95
|
platform: report[:platform][:name],
|
72
|
-
|
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,
|
73
126
|
)
|
74
127
|
end
|
75
128
|
|
@@ -93,7 +146,7 @@ module InspecPlugins::HoneycombReporter
|
|
93
146
|
|
94
147
|
res = http.request(req)
|
95
148
|
if res.is_a?(Net::HTTPSuccess)
|
96
|
-
|
149
|
+
Inspec::Log.debug "send_report: Honeycomb POST to #{uri.path} succeeded and returned: #{res.body} "
|
97
150
|
else
|
98
151
|
Inspec::Log.error "send_report: POST to #{uri.path} returned: #{res.body}"
|
99
152
|
false
|
@@ -102,10 +155,31 @@ module InspecPlugins::HoneycombReporter
|
|
102
155
|
Inspec::Log.error "send_report: POST to #{uri.path} returned: #{e.message}"
|
103
156
|
false
|
104
157
|
end
|
158
|
+
Inspec::Log.debug "Successfully sent report"
|
105
159
|
end
|
106
160
|
|
107
161
|
private
|
108
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
|
+
|
109
183
|
def generate_span_data(**args)
|
110
184
|
|
111
185
|
time_in_ms = args[:duration] ? args[:duration] * 1000 : 0
|
@@ -115,10 +189,23 @@ module InspecPlugins::HoneycombReporter
|
|
115
189
|
'service.name' => 'compliance',
|
116
190
|
'trace.parent_id' => args[:parent_id],
|
117
191
|
'platform.name' => args[:platform],
|
192
|
+
'platform.release' => args[:platform_release],
|
193
|
+
'status' => args[:status],
|
118
194
|
'type' => args[:type],
|
119
195
|
'name' => args[:name],
|
120
196
|
'duration' => time_in_ms,
|
121
197
|
'hostname' => Socket.gethostname,
|
198
|
+
'arch' => ::RbConfig::CONFIG['arch'],
|
199
|
+
'os' => ::RbConfig::CONFIG['host_os'],
|
200
|
+
'ip_addresses' => args[: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],
|
122
209
|
}
|
123
210
|
|
124
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.6
|
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: []
|