abide_dev_utils 0.2.2 → 0.2.3
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/README.md +11 -0
- data/lib/abide_dev_utils/version.rb +1 -1
- data/lib/abide_dev_utils/xccdf/cis/hiera.rb +5 -4
- 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: 5e19e043b233c6842331d4c4883a74d8557b163739e041d910b60b953acddc85
|
4
|
+
data.tar.gz: cf425a2b3a0c83ecd5e41cbee5d476fc7444e8984f4f03df12f91b36ad8aeee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e685b3d446b7c6256fd0e45d0542dccc77490b75ccc6408e2ba66e8edbc49d76267446940b997a0e3ab6a7449e1c5a03323c98cc66dd34ca58fa87178d4602
|
7
|
+
data.tar.gz: 558295f45b37110781fcd22bc4cac8a450c520f706933ddc0fe908c4f2ef863b63029603ab3e1df09142a17c6238f3f5514f20e4fefcc1ed6e2a5531abc5a479
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Helper library and CLI app for Abide development.
|
4
4
|
|
5
|
+
Issues and pull requests are welcome!
|
6
|
+
|
5
7
|
## Features
|
6
8
|
|
7
9
|
### CLI
|
@@ -206,6 +208,15 @@ class test_module::utils::test_new_util (
|
|
206
208
|
|
207
209
|
#### to_hiera
|
208
210
|
|
211
|
+
NOTE: When converting XCCDF files to Hiera, control names are sanitized. This means that some characters will be changed to ensure the resulting control names in the Hiera file are valid for both YAML and Puppet class names. Here's what gets changed:
|
212
|
+
|
213
|
+
* All letters are coverted to lower case
|
214
|
+
* The first and last characters of the control name is dropped if they are not letters (a-z)
|
215
|
+
* If a control name has a prefix of `l1_`, `l2_`, or `ng_`, that prefix is dropped
|
216
|
+
* Differentiation between profile level occurs outside of control names
|
217
|
+
* The characters `/` and `\` are deleted. This means that paths are smashed together
|
218
|
+
* Whitespace and the characters `(`, `)`, `.`, and `-` are substituted with underscores (`_`)
|
219
|
+
|
209
220
|
* Required positional parameters:
|
210
221
|
* `XCCDF_FILE` - Path to an XCCDF XML file
|
211
222
|
* Options:
|
@@ -13,6 +13,7 @@ module AbideDevUtils
|
|
13
13
|
# @!attribute [r] yaml_title
|
14
14
|
class Hiera
|
15
15
|
CONTROL_PREFIX = /^[\d.]+_/.freeze
|
16
|
+
UNDERSCORED = /(\s|\(|\)|-|\.)/.freeze
|
16
17
|
XPATHS = {
|
17
18
|
benchmark: {
|
18
19
|
all: 'xccdf:Benchmark',
|
@@ -89,7 +90,7 @@ module AbideDevUtils
|
|
89
90
|
|
90
91
|
private
|
91
92
|
|
92
|
-
attr_accessor :doc, :
|
93
|
+
attr_accessor :doc, :hash, :parent_key, :profiles
|
93
94
|
|
94
95
|
def parse(xccdf_file)
|
95
96
|
raise AbideDevUtils::Errors::FileNotFoundError, xccdf_file unless File.file?(xccdf_file)
|
@@ -116,8 +117,8 @@ module AbideDevUtils
|
|
116
117
|
nstr.gsub!(/[^a-z]$/, '')
|
117
118
|
nstr.gsub!(/^[^a-z]/, '')
|
118
119
|
nstr.gsub!(/^(l1_|l2_|ng_)/, '')
|
119
|
-
nstr.delete!('
|
120
|
-
nstr.gsub!(
|
120
|
+
nstr.delete!('(/|\\)')
|
121
|
+
nstr.gsub!(UNDERSCORED, '_')
|
121
122
|
nstr
|
122
123
|
end
|
123
124
|
|
@@ -129,7 +130,7 @@ module AbideDevUtils
|
|
129
130
|
|
130
131
|
def normalize_ctrl_name(ctrl)
|
131
132
|
new_ctrl = ctrl.split('_rule_')[-1].gsub(CONTROL_PREFIX, '')
|
132
|
-
normalize_str(new_ctrl
|
133
|
+
normalize_str(new_ctrl)
|
133
134
|
end
|
134
135
|
|
135
136
|
def make_parent_key(doc, prefix)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abide_dev_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heston Snodgrass
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|