simp-beaker-helpers 1.16.2 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/simp/beaker_helpers/ssg.rb +58 -7
- data/lib/simp/beaker_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d2df234c2357c8763e82b9cabaf6b9da39736ca7fcedc4a16dd344a993c2c2d
|
4
|
+
data.tar.gz: eda59ab6e07fadc67fb31b0d5d5462b89a2f4290129f46d32fda963999b5bc99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbcabe0f22e139595747cde2afd378e8f7d4f35e1d4ce387fc2c09da3bc57d2099e8abfc0beb407cfff0a53aad13c4be032840d54a78f86a7c4f5f47a504628a
|
7
|
+
data.tar.gz: 84235e55f67ee2fefc02dce2221763e817876a22fb1bf6cfee7adfcbfd261913022a39bba804ad66643f0cc884c164f41e0ac3b239a8b339e1809c8b7e55b063
|
data/CHANGELOG.md
CHANGED
@@ -156,23 +156,45 @@ module Simp::BeakerHelpers
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
# Retrieve a subset of test results based on a match to
|
160
|
-
#
|
159
|
+
# Retrieve a subset of test results based on a match to filter
|
160
|
+
#
|
161
|
+
# @param filter [String, Array[String]]
|
162
|
+
# A 'short name' filter that will be matched against the rule ID name
|
163
|
+
#
|
164
|
+
# @param exclusions [String, Array[String]]
|
165
|
+
# A 'short name' filter of items that will be removed from the `filter`
|
166
|
+
# matches
|
167
|
+
#
|
168
|
+
# @return [Hash] A Hash of statistics and a formatted report
|
161
169
|
#
|
162
170
|
# FIXME:
|
163
171
|
# - This is a hack! Should be searching for rules based on a set
|
164
172
|
# set of STIG ids, but don't see those ids in the oscap results xml.
|
165
173
|
# Further mapping is required...
|
166
174
|
# - Create the same report structure as inspec
|
167
|
-
def process_ssg_results(filter=nil)
|
168
|
-
self.class.process_ssg_results(
|
175
|
+
def process_ssg_results(filter=nil, exclusions=nil)
|
176
|
+
self.class.process_ssg_results(
|
177
|
+
File.join(@output_dir, @result_file) + '.xml',
|
178
|
+
filter,
|
179
|
+
exclusions
|
180
|
+
)
|
169
181
|
end
|
170
182
|
|
171
183
|
# Process the results of an SSG run
|
172
184
|
#
|
185
|
+
# @param result_file [String]
|
186
|
+
# The oscap result XML file to process
|
187
|
+
#
|
188
|
+
# @param filter [String, Array[String]]
|
189
|
+
# A 'short name' filter that will be matched against the rule ID name
|
190
|
+
#
|
191
|
+
# @param exclusions [String, Array[String]]
|
192
|
+
# A 'short name' filter of items that will be removed from the `filter`
|
193
|
+
# matches
|
194
|
+
#
|
173
195
|
# @return [Hash] A Hash of statistics and a formatted report
|
174
196
|
#
|
175
|
-
def self.process_ssg_results(result_file, filter=nil)
|
197
|
+
def self.process_ssg_results(result_file, filter=nil, exclusions=nil)
|
176
198
|
require 'highline'
|
177
199
|
require 'nokogiri'
|
178
200
|
|
@@ -187,10 +209,39 @@ module Simp::BeakerHelpers
|
|
187
209
|
doc.remove_namespaces!
|
188
210
|
|
189
211
|
if filter
|
212
|
+
filter = Array(filter)
|
213
|
+
|
214
|
+
xpath_query = [
|
215
|
+
'//rule-result[(',
|
216
|
+
]
|
217
|
+
|
218
|
+
xpath_query << filter.map do |flt|
|
219
|
+
"contains(@idref,'#{flt}')"
|
220
|
+
end.join(' or ')
|
221
|
+
|
222
|
+
xpath_query << ')' if filter.size > 1
|
223
|
+
|
224
|
+
if exclusions
|
225
|
+
exclusions = Array(exclusions)
|
226
|
+
|
227
|
+
xpath_query << 'and not('
|
228
|
+
|
229
|
+
xpath_query << exclusions.map do |exl|
|
230
|
+
"contains(@idref,'#{exl}')"
|
231
|
+
end.join(' or ')
|
232
|
+
|
233
|
+
xpath_query << ')' if exclusions.size > 1
|
234
|
+
end
|
235
|
+
|
236
|
+
xpath_query << ')]'
|
237
|
+
|
238
|
+
xpath_query = xpath_query.join(' ')
|
239
|
+
|
190
240
|
# XPATH to get the pertinent test results:
|
191
241
|
# Any node named 'rule-result' for which the attribute 'idref'
|
192
|
-
# contains filter
|
193
|
-
|
242
|
+
# contains any of the `filter` Strings and does not contain any of the
|
243
|
+
# `exclusions` Strings
|
244
|
+
result_nodes = doc.xpath(xpath_query)
|
194
245
|
else
|
195
246
|
result_nodes = doc.xpath('//rule-result')
|
196
247
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simp-beaker-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Tessmer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-10-
|
12
|
+
date: 2019-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beaker
|