inspec-reporter-honeycomb 0.1.4 → 0.1.5
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 +115 -29
- 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
|
@@ -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
|
|
@@ -107,6 +160,26 @@ module InspecPlugins::HoneycombReporter
|
|
107
160
|
|
108
161
|
private
|
109
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
|
+
|
110
183
|
def generate_span_data(**args)
|
111
184
|
|
112
185
|
time_in_ms = args[:duration] ? args[:duration] * 1000 : 0
|
@@ -116,10 +189,23 @@ module InspecPlugins::HoneycombReporter
|
|
116
189
|
'service.name' => 'compliance',
|
117
190
|
'trace.parent_id' => args[:parent_id],
|
118
191
|
'platform.name' => args[:platform],
|
192
|
+
'platform.release' => args[:platform_release],
|
193
|
+
'status' => args[:status],
|
119
194
|
'type' => args[:type],
|
120
195
|
'name' => args[:name],
|
121
196
|
'duration' => time_in_ms,
|
122
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],
|
123
209
|
}
|
124
210
|
|
125
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: []
|