inspec-reporter-honeycomb 0.1.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fce8b6e1f7d373eec1f8d5a5a09833af7351b6749a087fd5ecd90e302f6c003a
4
- data.tar.gz: dd5acfdabd033bd5a0132193a403f7d289e440e6ec2df3ce9530b07f3f123271
3
+ metadata.gz: 6a8e894a1f5773a7dbfec2acf30dde30e556c46378f12a09e916a782a476588e
4
+ data.tar.gz: e6ad1c6e8c297b22f09aee6b03bfd864ea1f5956469f37a06bf88f1eb30dea97
5
5
  SHA512:
6
- metadata.gz: 0d03a4e73814455ea93baafe24114542794c0c19bc372697d1b544a0694f523f2fc468786b46bcadbbb708b61e6b0e78c31409f9bac8d6702acafa061e6094aa
7
- data.tar.gz: 558a4cef121266c38b8ff5251b3f8ba813d084a7efd99c76487e722b4a1de9ec2934b3e9586d0ae9be5af10f5fe93ea5c52b2062de14c84d2869f30b868154bc
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
- control_span_id = SecureRandom.hex(8)
41
- control[:results].each do |result|
42
- result_span_id = SecureRandom.hex(8)
43
- trace_batch << generate_span_data(
44
- parent_id: control_span_id,
45
- span_id: result_span_id,
46
- trace_id: trace_id,
47
- data: result,
48
- platform: report[:platform][:name],
49
- type: 'result',
50
- name: result[:code_desc],
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
- parent_id: profile_span_id,
57
- span_id: control_span_id,
58
- trace_id: trace_id,
59
- data: control,
60
- platform: report[:platform][:name],
61
- type: 'control',
62
- name: control[:title],
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
- end
65
- profile.tap { |pf| pf.delete(:controls) }
66
- trace_batch << generate_span_data(
67
- parent_id: root_span_id,
68
- span_id: profile_span_id,
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: profile,
93
+ data: control,
94
+ status: control_status,
71
95
  platform: report[:platform][:name],
72
- type: 'profile',
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
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-08-31 00:00:00.000000000 Z
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: []