abide_dev_utils 0.5.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a27976b9f740b67261fa080eeba927bc6fc98e73ffb592fafdd91d4d612cc51f
4
- data.tar.gz: 64778a0d476e2f96d70a14ab318b517c597aa3c5e33afd8939173385b013fe6c
3
+ metadata.gz: '03743386fed00b094d759cb20a53d25d807492fd98097564d140aa0cacfecce0'
4
+ data.tar.gz: be8082a88120f30f2754f79194a818c7640fd5f104c0c57dc07cd84d8bbc460f
5
5
  SHA512:
6
- metadata.gz: e31df40e6dd34a57156ff517d39fcc036f5655ce2f31bf86b1ebb66754304575b7379e0a3751ae378bc81bc1520dbe095255012dc7e10b24e4f6c3f4a85e6551
7
- data.tar.gz: c9dd204d55a37d389c0c8a4d3d281310b87241cbbd149ca029a3fa6a38fd8414bcb350467cd348cdd330fe946e6ee75625bfe2828319ad25d9eb8ed5cc37a9a3
6
+ metadata.gz: 1bcd5add724cc85cc95915d778a6320de028b351ea19920b712efe228a4e01efdb36bb2840f5b566f5cf8a3d9ebe90236138fdd0bc0d83e90fbe1f4a0cf67763
7
+ data.tar.gz: 91f71049317153abafaa32fd9bacdfbfa26b1ba2145ddd902238f6cbc8e31417540eee0812b67ecdb5b5b0c500f1b0ce02ee43b028c37ffb3d87753c75e1729e
data/README.md CHANGED
@@ -88,6 +88,8 @@ Install the gem:
88
88
 
89
89
  ### Overview of Commands
90
90
 
91
+ * `abide comply` - Command namespace for Puppet Comply commands
92
+ * `abide comply report` - Creates a scan report in YAML format by scraping Puppet Comply
91
93
  * `abide jira` - Command namespace for Jira commands
92
94
  * `abide jira auth` - Authenticate with Jira. Only useful as a stand-alone command to test authentication
93
95
  * `abide jira from_coverage` - Creates a parent issue with subtasks from a Puppet coverage report
@@ -100,6 +102,34 @@ Install the gem:
100
102
  * `abide xccdf` - Command namespace for XCCDF commands
101
103
  * `abide xccdf to_hiera` - Converts a benchmark XCCDF file to a Hiera yaml file
102
104
 
105
+ ### Comply Command Reference
106
+
107
+ #### report
108
+
109
+ * Required positional parameters:
110
+ * `COMPLY_URL` - The URL of Puppet Comply
111
+ * `COMPLY_PASSWORD` - The password for the Puppet Comply user
112
+ * Options:
113
+ * `--out-file`, `-o` - The path to save the scan report. Defaults to `./comply_scan_report.yaml`
114
+ * `--username`, `-u` - The Puppet Comply username. Defaults to `comply`
115
+ * `--status`, `-s` - A comma-separated list of check statuses to ONLY include in the report. Valid statuses are: `pass`, `fail`, `error`, `notapplicable`, `notchecked`, `unknown`, `informational`
116
+ * `--only`, `-O` - A comma-separated list of node certnames to ONLY build reports for. No other nodes will have reports built for them except the ones specified. This option is mutually exclusive with `--ignore` and, if both are set, this options will take precedence over `--ignore`.
117
+ * `--ignore`, `-I` - A comma-separated list of node certnames to ignore building reports for. This options is mutually exclusive with `--only` and, if both are set, `--only` will take precedence over this option.
118
+
119
+ Examples:
120
+
121
+ Generating a report of all failed and err'd scan checks
122
+
123
+ ```sh
124
+ abide comply report https://comply.my.instance 'my_comply_password!' -s fail,error
125
+ ```
126
+
127
+ Generating a report for certain nodes only
128
+
129
+ ```sh
130
+ abide comply report https://comply.my.instance 'my_comply_password!' -O specific-node.my.instance
131
+ ```
132
+
103
133
  ### Jira Command Reference
104
134
 
105
135
  #### from_coverage
@@ -45,6 +45,7 @@ Gem::Specification.new do |spec|
45
45
  spec.add_development_dependency 'console'
46
46
  spec.add_development_dependency 'github_changelog_generator'
47
47
  spec.add_development_dependency 'gem-release'
48
+ spec.add_development_dependency 'pry'
48
49
  spec.add_development_dependency 'rspec', '~> 3.10'
49
50
  spec.add_development_dependency 'rubocop', '~> 1.8'
50
51
  spec.add_development_dependency 'rubocop-rspec', '~> 2.1'
@@ -80,7 +80,7 @@ module Abide
80
80
  comply_url = conf.fetch(:url) if comply_url.nil?
81
81
  comply_password = comply_password.nil? ? conf.fetch(:password, Abide::CLI::PROMPT.password) : comply_password
82
82
  username = @data.fetch(:username, nil).nil? ? conf.fetch(:username, 'comply') : @data[:username]
83
- status = @data.fetch(:status, nil).nil? ? conf.fecth(:status, nil) : @data[:status]
83
+ status = @data.fetch(:status, nil).nil? ? conf.fetch(:status, nil) : @data[:status]
84
84
  ignorelist = @data.fetch(:ignore, nil).nil? ? conf.fetch(:ignore, nil) : @data[:ignore]
85
85
  onlylist = @data.fetch(:only, nil).nil? ? conf.fetch(:only, nil) : @data[:only]
86
86
  report = AbideDevUtils::Comply.scan_report(comply_url,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbideDevUtils
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.2"
5
5
  end
@@ -41,7 +41,7 @@ module AbideDevUtils
41
41
  @version = xpath(XPATHS[:benchmark][:version]).children.to_s
42
42
  @profiles = xpath(XPATHS[:profiles][:all])
43
43
  @parent_key = make_parent_key(@doc, parent_key_prefix)
44
- @hash = make_hash(@doc, @parent_key, num)
44
+ @hash = make_hash(@doc, num)
45
45
  end
46
46
 
47
47
  def yaml_title
@@ -63,8 +63,8 @@ module AbideDevUtils
63
63
  # Convert the Hiera object to YAML string
64
64
  # @return [String] YAML-formatted string
65
65
  def to_yaml
66
- yh = @hash[@parent_key.to_sym].transform_keys do |k|
67
- "#{@parent_key}::#{k}"
66
+ yh = @hash.transform_keys do |k|
67
+ [@parent_key, k].join('::').strip
68
68
  end
69
69
  yh.to_yaml
70
70
  end
@@ -101,15 +101,15 @@ module AbideDevUtils
101
101
  Nokogiri.XML(File.open(xccdf_file))
102
102
  end
103
103
 
104
- def make_hash(doc, parent_key, num)
105
- hash = { parent_key.to_sym => { title: @title, version: @version } }
104
+ def make_hash(doc, num)
105
+ hash = { 'title' => @title, 'version' => @version }
106
106
  profiles = doc.xpath('xccdf:Benchmark/xccdf:Profile')
107
107
  profiles.each do |p|
108
108
  title = normalize_profile_name(p.xpath('./xccdf:title').children.to_s)
109
- hash[parent_key.to_sym][title.to_sym] = []
109
+ hash[title.to_s] = []
110
110
  selects = p.xpath('./xccdf:select')
111
111
  selects.each do |s|
112
- hash[parent_key.to_sym][title.to_sym] << normalize_ctrl_name(s['idref'].to_s, num)
112
+ hash[title.to_s] << normalize_ctrl_name(s['idref'].to_s, num)
113
113
  end
114
114
  end
115
115
  hash
@@ -120,14 +120,16 @@ module AbideDevUtils
120
120
  nstr.gsub!(/[^a-z0-9]$/, '')
121
121
  nstr.gsub!(/^[^a-z]/, '')
122
122
  nstr.gsub!(/^(l1_|l2_|ng_)/, '')
123
- nstr.delete!('(/|\\)')
123
+ nstr.delete!('(/|\\|\+)')
124
124
  nstr.gsub!(UNDERSCORED, '_')
125
+ nstr.strip!
125
126
  nstr
126
127
  end
127
128
 
128
129
  def normalize_profile_name(prof)
129
130
  prof_name = normalize_str("profile_#{prof}")
130
131
  prof_name.gsub!(NEXT_GEN_WINDOWS, 'ngws')
132
+ prof_name.strip!
131
133
  prof_name
132
134
  end
133
135
 
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.5.0
4
+ version: 0.5.2
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-06-16 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rspec
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -339,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
353
  - !ruby/object:Gem::Version
340
354
  version: '0'
341
355
  requirements: []
342
- rubygems_version: 3.0.9
356
+ rubygems_version: 3.1.4
343
357
  signing_key:
344
358
  specification_version: 4
345
359
  summary: Helper utilities for developing Abide