abide_dev_utils 0.15.0 → 0.16.1

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: a8f5dc40bfe8e447b1440435f020db1fb63decccaa405d52301251d9b5786af9
4
- data.tar.gz: 414c7c96cfb731b65ff942cac68cf078ac2d7e4bac01da3a567f0ace10599243
3
+ metadata.gz: 9ba88038da5800b45085201557c28a7d4096027230083e0c8d5a811a7fd1de5a
4
+ data.tar.gz: 78da6fd7887fdb50a7de4505b4dd95b6fa2e24400dc6b5419dcc44aaa1f15d24
5
5
  SHA512:
6
- metadata.gz: bee0317d5e0c9b745537771c5c9425fb74d8c3a1a745dbaf2b694d9e258730608bf1616404efb59380a6178e51308385f1c4d6bb120fc9f35dd953432569c518
7
- data.tar.gz: 47b08b70d6e148804606222ecd9a5d53740483f57c87613bead2fb8292d6f668a4a2507a046c5edb452a353d27ca6193d04f4736d347ac8c6f04291a1dbd61d0
6
+ metadata.gz: 3e1577583c8fcc597f75e02d3ef5edee126984f8daaea8fc98741c718c0254044767189acf24e0e21ba2b60607f4042c1f0c52be934dbc129d270008042f8bf5
7
+ data.tar.gz: eb8b1038e223efeec1f7a2b3d0d0ee0f04cba49f385b58c8de5e1dfe8c2d935dac0d760faf65d8ab45f0b539f4729ea9195926d0cce1d4fe294c19f6e426e879
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abide_dev_utils (0.15.0)
4
+ abide_dev_utils (0.16.1)
5
5
  cmdparse (~> 3.0)
6
6
  facterdb (>= 1.21)
7
7
  google-cloud-storage (~> 1.34)
@@ -17,7 +17,7 @@ GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
19
  CFPropertyList (2.3.6)
20
- activesupport (7.0.4.3)
20
+ activesupport (7.0.7.2)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 1.6, < 2)
23
23
  minitest (>= 5.1)
@@ -29,15 +29,15 @@ GEM
29
29
  console (~> 1.10)
30
30
  nio4r (~> 2.3)
31
31
  timers (~> 4.1)
32
- async-http (0.56.6)
32
+ async-http (0.60.2)
33
33
  async (>= 1.25)
34
34
  async-io (>= 1.28)
35
35
  async-pool (>= 0.2)
36
- protocol-http (~> 0.22.0)
37
- protocol-http1 (~> 0.14.0)
38
- protocol-http2 (~> 0.14.0)
39
- traces (~> 0.4.0)
40
- async-http-faraday (0.11.0)
36
+ protocol-http (~> 0.24.0)
37
+ protocol-http1 (~> 0.15.0)
38
+ protocol-http2 (~> 0.15.0)
39
+ traces (>= 0.10.0)
40
+ async-http-faraday (0.12.0)
41
41
  async-http (~> 0.42)
42
42
  faraday
43
43
  async-io (1.33.0)
@@ -120,7 +120,7 @@ GEM
120
120
  hiera (3.12.0)
121
121
  hocon (1.4.0)
122
122
  httpclient (2.8.3)
123
- i18n (1.12.0)
123
+ i18n (1.14.1)
124
124
  concurrent-ruby (~> 1.0)
125
125
  jgrep (1.5.4)
126
126
  jira-ruby (2.3.0)
@@ -133,12 +133,14 @@ GEM
133
133
  memoist (0.16.2)
134
134
  method_source (1.0.0)
135
135
  mini_mime (1.1.2)
136
- minitest (5.18.0)
136
+ minitest (5.19.0)
137
137
  multi_json (1.15.0)
138
138
  multipart-post (2.3.0)
139
139
  nio4r (2.5.8)
140
140
  nokogiri (1.15.2-x86_64-darwin)
141
141
  racc (~> 1.4)
142
+ nokogiri (1.15.2-x86_64-linux)
143
+ racc (~> 1.4)
142
144
  oauth (0.6.2)
143
145
  snaky_hash (~> 2.0)
144
146
  version_gem (~> 1.1)
@@ -150,16 +152,27 @@ GEM
150
152
  parser (3.1.2.0)
151
153
  ast (~> 2.4.1)
152
154
  protocol-hpack (1.4.2)
153
- protocol-http (0.22.6)
154
- protocol-http1 (0.14.4)
155
+ protocol-http (0.24.7)
156
+ protocol-http1 (0.15.1)
155
157
  protocol-http (~> 0.22)
156
- protocol-http2 (0.14.2)
158
+ protocol-http2 (0.15.1)
157
159
  protocol-hpack (~> 1.4)
158
160
  protocol-http (~> 0.18)
159
161
  pry (0.14.1)
160
162
  coderay (~> 1.1)
161
163
  method_source (~> 1.0)
162
164
  public_suffix (4.0.7)
165
+ puppet (7.24.0)
166
+ concurrent-ruby (~> 1.0, < 1.2.0)
167
+ deep_merge (~> 1.0)
168
+ facter (> 2.0.1, < 5)
169
+ fast_gettext (>= 1.1, < 3)
170
+ hiera (>= 3.2.1, < 4)
171
+ locale (~> 2.1)
172
+ multi_json (~> 1.10)
173
+ puppet-resource_api (~> 1.5)
174
+ scanf (~> 1.0)
175
+ semantic_puppet (~> 1.0)
163
176
  puppet (7.24.0-universal-darwin)
164
177
  CFPropertyList (~> 2.2)
165
178
  concurrent-ruby (~> 1.0, < 1.2.0)
@@ -241,7 +254,7 @@ GEM
241
254
  version_gem (~> 1.1, >= 1.1.1)
242
255
  thor (1.2.2)
243
256
  timers (4.3.3)
244
- traces (0.4.1)
257
+ traces (0.11.1)
245
258
  trailblazer-option (0.1.2)
246
259
  tzinfo (2.0.6)
247
260
  concurrent-ruby (~> 1.0)
@@ -273,4 +286,4 @@ DEPENDENCIES
273
286
  rubocop-rspec (~> 2.1)
274
287
 
275
288
  BUNDLED WITH
276
- 2.3.9
289
+ 2.4.19
@@ -85,7 +85,7 @@ module AbideDevUtils
85
85
  next if benchmark.framework == 'stig' && control.id_map_type != 'vulnid'
86
86
 
87
87
  control_md = ControlMarkdown.new(control, @md, @strings, @module_name, benchmark.framework, opts: @opts)
88
- control_md.generate!
88
+ control_md.generate! if control_md.verify_profile_and_level_selections
89
89
  progress_bar.increment unless @opts[:quiet]
90
90
  rescue StandardError => e
91
91
  raise "Failed to generate markdown for control #{control.id}. Original message: #{e.message}"
@@ -248,6 +248,8 @@ module AbideDevUtils
248
248
  @framework = framework
249
249
  @formatter = formatter.nil? ? TypeExprValueFormatter : formatter
250
250
  @opts = opts
251
+ @valid_level = []
252
+ @valid_profile = []
251
253
  @control_data = {}
252
254
  end
253
255
 
@@ -262,6 +264,43 @@ module AbideDevUtils
262
264
  resource_reference_builder
263
265
  end
264
266
 
267
+ # This function act as a filter for controls based on the profile and level selections.
268
+ # There are few scanarios that can happen:
269
+ # 1. If no selections are made for profile or level, then all profiles and levels of control will be selected.
270
+ # 2. If selections are made for profile, then only the selected profile and all levels of control will be selected.
271
+ # 3. If selections are made for level, then only the selected level and all profiles of control will be selected.
272
+ # This function adds in some runtime overhead because we're checking each control's level and profile which is
273
+ # what we're going to be doing later when building the level and profile markdown, but this is
274
+ # necessary to ensure that the reference.md is generated the way we want it to be.
275
+ def verify_profile_and_level_selections
276
+ return true if @opts[:select_profile].nil? && @opts[:select_level].nil?
277
+
278
+ if @opts[:select_profile].nil? && !@opts[:select_level].nil?
279
+ @control.levels.each do |level|
280
+ @valid_level << level if select_control_level(level)
281
+ end
282
+
283
+ return true unless @valid_level.empty?
284
+ elsif !@opts[:select_profile].nil? && @opts[:select_level].nil?
285
+ @control.profiles.each do |profile|
286
+ @valid_profile << profile if select_control_profile(profile)
287
+ end
288
+
289
+ return true unless @valid_profile.empty?
290
+ elsif !@opts[:select_profile].nil? && !@opts[:select_level].nil?
291
+ @control.levels.each do |level|
292
+ @valid_level << level if select_control_level(level)
293
+ end
294
+
295
+ @control.profiles.each do |profile|
296
+ @valid_profile << profile if select_control_profile(profile)
297
+ end
298
+
299
+ # As long as there are valid profiles and levels for the control at this stage, all is good
300
+ !@valid_level.empty? && !@valid_profile.empty?
301
+ end
302
+ end
303
+
265
304
  private
266
305
 
267
306
  def heading_builder
@@ -340,18 +379,36 @@ module AbideDevUtils
340
379
  def control_levels_builder
341
380
  return unless @control.levels
342
381
 
382
+ # @valid_level is populated in verify_profile_and_level_selections from the fact that we've given
383
+ # the generator a list of levels we want to use. If we didn't give it a list of levels, then we
384
+ # want to use all of the levels that the control supports from @control.
343
385
  @md.add_ul('Supported Levels:')
344
- @control.levels.each do |l|
345
- @md.add_ul(@md.code(l), indent: 1)
386
+ if @valid_level.empty?
387
+ @control.levels.each do |l|
388
+ @md.add_ul(@md.code(l), indent: 1)
389
+ end
390
+ else
391
+ @valid_level.each do |l|
392
+ @md.add_ul(@md.code(l), indent: 1)
393
+ end
346
394
  end
347
395
  end
348
396
 
349
397
  def control_profiles_builder
350
398
  return unless @control.profiles
351
399
 
400
+ # @valid_profile is populated in verify_profile_and_level_selections from the fact that we've given
401
+ # the generator a list of profiles we want to use. If we didn't give it a list of profiles, then we
402
+ # want to use all of the profiles that the control supports from @control.
352
403
  @md.add_ul('Supported Profiles:')
353
- @control.profiles.each do |l|
354
- @md.add_ul(@md.code(l), indent: 1)
404
+ if @valid_profile.empty?
405
+ @control.profiles.each do |l|
406
+ @md.add_ul(@md.code(l), indent: 1)
407
+ end
408
+ else
409
+ @valid_profile.each do |l|
410
+ @md.add_ul(@md.code(l), indent: 1)
411
+ end
355
412
  end
356
413
  end
357
414
 
@@ -364,6 +421,18 @@ module AbideDevUtils
364
421
  end
365
422
  end
366
423
 
424
+ # Function that returns true if the profile is in the list of profiles that we want to use.
425
+ # @param profile [String] the profile to filter
426
+ def select_control_profile(profile)
427
+ @opts[:select_profile].include? profile
428
+ end
429
+
430
+ # Function that returns true if the level is in the list of levels that we want to use.
431
+ # @param level [String] the level to filter
432
+ def select_control_level(level)
433
+ @opts[:select_level].include? level
434
+ end
435
+
367
436
  def dependent_controls_builder
368
437
  dep_ctrls = @control.resource.dependent_controls
369
438
  return if dep_ctrls.nil? || dep_ctrls.empty?
@@ -390,7 +459,7 @@ module AbideDevUtils
390
459
 
391
460
  @control.title.nil? ? out_str.unshift(" #{@control.id.dump}:") : out_str.unshift(" #{@control.title.dump}:")
392
461
  out_str.unshift(' control_configs:')
393
- out_str.unshift("#{@module_name}::config:")
462
+ out_str.unshift("#{@module_name.split('-').last}::config:")
394
463
  @md.add_ul('Hiera Configuration Example:')
395
464
  @md.add_code_block(out_str.join("\n"), language: 'yaml')
396
465
  rescue StandardError => e
@@ -113,6 +113,12 @@ module Abide
113
113
  options.on('-s', '--strict', 'Fails if there are any errors') do
114
114
  @data[:strict] = true
115
115
  end
116
+ options.on('-p [PROFILE]', '--select-profile [PROFILE]', 'The list of profiles that the reference.md will use separated by commas') do |pr|
117
+ @data[:select_profile] = pr.split(',')
118
+ end
119
+ options.on('-l [LEVEL]', '--select-level [LEVEL]', 'The list of level that the reference.md will use separated by commas') do |l|
120
+ @data[:select_level] = l.split(',')
121
+ end
116
122
  end
117
123
 
118
124
  def execute
@@ -40,7 +40,7 @@ module Abide
40
40
  def execute
41
41
  client = JIRA.client
42
42
  myself = JIRA.myself(client)
43
- return if myself.attrs['name'].empty?
43
+ return if myself.attrs['displayName'].empty?
44
44
 
45
45
  Abide::CLI::OUTPUT.simple("Successfully authenticated user #{myself.attrs['name']}!")
46
46
  end
@@ -67,9 +67,8 @@ module AbideDevUtils
67
67
  fields = {}
68
68
  fields['summary'] = summary
69
69
  fields['project'] = project(client, project)
70
- fields['reporter'] = myself(client)
71
70
  fields['issuetype'] = issuetype(client, 'Task')
72
- fields['priority'] = priority(client, '6')
71
+ fields['priority'] = priority(client, '3')
73
72
  fields['description'] = description if description
74
73
  fields['labels'] = labels
75
74
  epic = issue(client, epic) if epic && !epic.is_a?(JIRA::Resource::Issue)
@@ -89,7 +88,6 @@ module AbideDevUtils
89
88
  fields = {
90
89
  'summary' => summary,
91
90
  'project' => project(client, project),
92
- 'reporter' => myself(client),
93
91
  'issuetype' => issuetype(client, 'Epic'),
94
92
  'customfield_10007' => summary, # Epic Name
95
93
  }
@@ -114,7 +112,6 @@ module AbideDevUtils
114
112
  fields['parent'] = issue
115
113
  fields['summary'] = summary
116
114
  fields['project'] = issue_fields['project']
117
- fields['reporter'] = myself(client)
118
115
  fields['issuetype'] = issuetype(client, '5')
119
116
  fields['priority'] = issue_fields['priority']
120
117
  subtask = client.Issue.build
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbideDevUtils
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.1"
5
5
  end
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.15.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - abide-team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -463,7 +463,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
463
463
  - !ruby/object:Gem::Version
464
464
  version: '0'
465
465
  requirements: []
466
- rubygems_version: 3.4.6
466
+ rubygems_version: 3.4.19
467
467
  signing_key:
468
468
  specification_version: 4
469
469
  summary: Helper utilities for developing compliance Puppet code