inspec-reporter-json-hdf 1.1.0.beta1 → 1.1.1
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-json-hdf/reporter.rb +54 -67
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8da7e4c1184a9e40b656eae008bb8543953f15e5434f34573879b6954d78127d
|
4
|
+
data.tar.gz: cfefb74fbb00461b676e8a66813304c2e8bc91b032f0d7f91b68a59746788478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98c3b8e63c00d6781611860254975a9df39b2e75e0974549d191bcf6ccf5eaceda8edc9bede018af9e7a76fa82d99940b82a00c1a582f15f4a3dbac43eafdc9c
|
7
|
+
data.tar.gz: ca7da3c2ff919a93b505ffa087edcd62b5f347a0296494bd41a7971e6004ed2708fb97976c239362962b8c47c8092f431db452766638070ed98fbed2d56e66ab
|
@@ -9,6 +9,8 @@ VALID_STATUSES = %w[passed failed].freeze
|
|
9
9
|
|
10
10
|
DATE_FORMAT = '%Y-%m-%d'.freeze
|
11
11
|
|
12
|
+
SUPPORTED_INCLUDE_TYPES = %w[csv xlsx].freeze
|
13
|
+
|
12
14
|
module InspecPlugins::HdfReporter
|
13
15
|
# Reporter Plugin Class
|
14
16
|
class Reporter < Inspec.plugin(2, :reporter)
|
@@ -42,40 +44,24 @@ module InspecPlugins::HdfReporter
|
|
42
44
|
private
|
43
45
|
|
44
46
|
def apply_attestation(results, attestation)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}]
|
53
|
-
else
|
54
|
-
results.each do |result|
|
55
|
-
result[:message] = 'Automated test returned as passed.' if result[:status].eql?('passed')
|
56
|
-
result[:message] = result[:skip_message] if result[:status].eql?('skipped')
|
57
|
-
|
58
|
-
result[:status] = attestation['status']
|
59
|
-
result[:message] = result[:message] + attestation_message(attestation)
|
60
|
-
|
61
|
-
if result[:backtrace]
|
62
|
-
result[:message] = result[:message] + "\nbacktrace: #{result[:backtrace]}"
|
63
|
-
result[:backtrace] = nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
results
|
47
|
+
results << {
|
48
|
+
"code_desc": 'Manually verified Status provided through attestation',
|
49
|
+
"run_time": 0.0,
|
50
|
+
"start_time": DateTime.now.to_s,
|
51
|
+
"status": attestation['status'],
|
52
|
+
"message": attestation_message(attestation)
|
53
|
+
}
|
68
54
|
end
|
69
55
|
|
70
56
|
def attestation_message(attestation)
|
71
|
-
|
72
|
-
Attestation:
|
73
|
-
Status: #{attestation['status']}
|
74
|
-
Explanation: #{attestation['explanation']}
|
75
|
-
Updated: #{attestation['updated']}
|
76
|
-
Updated By: #{attestation['updated_by']}
|
77
|
-
Frequency: #{attestation['frequency']}
|
78
|
-
"
|
57
|
+
[
|
58
|
+
'Attestation:',
|
59
|
+
"Status: #{attestation['status']}",
|
60
|
+
"Explanation: #{attestation['explanation']}",
|
61
|
+
"Updated: #{attestation['updated']}",
|
62
|
+
"Updated By: #{attestation['updated_by']}",
|
63
|
+
"Frequency: #{attestation['frequency']}",
|
64
|
+
].join("\n")
|
79
65
|
end
|
80
66
|
|
81
67
|
def attestation_expired?(date, frequency)
|
@@ -89,9 +75,9 @@ module InspecPlugins::HdfReporter
|
|
89
75
|
when 'annually'
|
90
76
|
parsed_date.next_year(1)
|
91
77
|
when 'semiannually'
|
92
|
-
parsed_date.
|
78
|
+
parsed_date.next_month(6)
|
93
79
|
when 'quarterly'
|
94
|
-
parsed_date.
|
80
|
+
parsed_date.next_month(3)
|
95
81
|
when 'monthly'
|
96
82
|
parsed_date.next_month(1)
|
97
83
|
when 'every2weeks'
|
@@ -122,45 +108,46 @@ module InspecPlugins::HdfReporter
|
|
122
108
|
status.is_a?(String) && VALID_STATUSES.include?(status.downcase)
|
123
109
|
end
|
124
110
|
|
125
|
-
def
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
elsif plugin_config['include-attestations-file']['type'].eql?('xlsx')
|
142
|
-
sheet = Roo::Spreadsheet.open(plugin_config['include-attestations-file']['path'], extension: :xlsx).sheet(0)
|
143
|
-
|
144
|
-
attestations = sheet.parse(control_id: "Control_ID",
|
145
|
-
explanation: "Explanation",
|
146
|
-
frequency: "Frequency",
|
147
|
-
status: "Status",
|
148
|
-
updated: "Updated",
|
149
|
-
updated_by: "Updated_By",
|
150
|
-
clean:true
|
151
|
-
)
|
152
|
-
attestations.map do |h|
|
153
|
-
h[:updated] = h[:updated].to_s
|
154
|
-
end
|
155
|
-
else
|
156
|
-
puts 'Warning: Invalid `include-attestations-file` type provided. Supported types: csv, xlsx'
|
111
|
+
def parse_include_file(include_file)
|
112
|
+
if File.exist?(include_file['path'])
|
113
|
+
if SUPPORTED_INCLUDE_TYPES.include?(include_file['type'])
|
114
|
+
sheet = Roo::Spreadsheet.open(include_file['path'], extension: include_file['type'].to_sym ).sheet(0)
|
115
|
+
|
116
|
+
attestations = sheet.parse(control_id: "Control_ID",
|
117
|
+
explanation: "Explanation",
|
118
|
+
frequency: "Frequency",
|
119
|
+
status: "Status",
|
120
|
+
updated: "Updated",
|
121
|
+
updated_by: "Updated_By",
|
122
|
+
clean:true
|
123
|
+
)
|
124
|
+
# Following is required to convert Datetime field returned by xlsx parser to string
|
125
|
+
attestations.map do |h|
|
126
|
+
h[:updated] = h[:updated].to_s
|
157
127
|
end
|
158
128
|
else
|
159
|
-
puts "Warning:
|
129
|
+
puts "Warning: Invalid `include-attestations-file` type provided. Supported types: #{SUPPORTED_INCLUDE_TYPES.to_s}"
|
160
130
|
end
|
131
|
+
else
|
132
|
+
puts "Warning: Include Attestation File provided '#{include_file['path']}' not found."
|
161
133
|
end
|
134
|
+
attestations || []
|
135
|
+
end
|
136
|
+
|
137
|
+
def collect_attestations
|
138
|
+
plugin_config = Inspec::Config.cached.fetch_plugin_config('inspec-reporter-json-hdf')
|
139
|
+
attestations = []
|
140
|
+
|
141
|
+
# Parse Attestations from include file.
|
142
|
+
attestations = parse_include_file(plugin_config['include-attestations-file']) if plugin_config['include-attestations-file']
|
143
|
+
|
162
144
|
attestations.map!{ |x| x.transform_keys(&:to_s) }
|
163
|
-
|
145
|
+
|
146
|
+
# Merge inline Attestations from config file and `include file` with precedence to inline definitions.
|
147
|
+
attestations = (plugin_config['attestations'] || []) + attestations
|
148
|
+
attestations.uniq! {|e| e['control_id'] }
|
149
|
+
|
150
|
+
# Remove Attestations records without status provided.
|
164
151
|
attestations.reject! { |x| x['status'].eql?("") || x['status'].nil? }
|
165
152
|
|
166
153
|
if attestations.empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec-reporter-json-hdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rony Xavier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git-lite-version-bump
|
@@ -197,9 +197,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '2.5'
|
198
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- - "
|
200
|
+
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
202
|
+
version: '0'
|
203
203
|
requirements: []
|
204
204
|
rubygems_version: 3.2.3
|
205
205
|
signing_key:
|