abide_dev_utils 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/abide_dev_utils/cem/generate/reference.rb +7 -2
- data/lib/abide_dev_utils/cem/mapping/mapper.rb +5 -3
- data/lib/abide_dev_utils/cli/jira.rb +22 -0
- data/lib/abide_dev_utils/jira.rb +45 -0
- data/lib/abide_dev_utils/version.rb +1 -1
- data/lib/abide_dev_utils/xccdf.rb +4 -3
- 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: 1e93a77cf4142b06ee4d41863ef2d0b737d21d37306b57082aa316f2731de5e9
|
4
|
+
data.tar.gz: 9b49e05aa575884d54efed8fd70b5662712845c083a8b59caeccf406a19f5633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51316ad752020f3b2297acbdc4bb328c5275d03e499721ee12381aaac5da3a6e77ecb9efeb0ffa4b3b6bb512154dbb4b36bf249f4816944a0110d3ceeb871b2b
|
7
|
+
data.tar.gz: 40b83d7be09ccb1349650617548276f6f34e266fe2e590e8c1b28b8e9c44f4499c93652abf9e254d77469fec9c98e9394a1ae2f4b2d3f0921827c3ce302dfb7e
|
data/Gemfile.lock
CHANGED
@@ -120,7 +120,11 @@ module AbideDevUtils
|
|
120
120
|
private
|
121
121
|
|
122
122
|
def heading_builder
|
123
|
-
@
|
123
|
+
if @framework == 'stig'
|
124
|
+
@md.add_h2(@control.id)
|
125
|
+
else
|
126
|
+
@md.add_h2("#{@control.number} - #{@control.title}")
|
127
|
+
end
|
124
128
|
end
|
125
129
|
|
126
130
|
def control_has_valid_params?
|
@@ -216,12 +220,13 @@ module AbideDevUtils
|
|
216
220
|
end
|
217
221
|
return if out_str.empty?
|
218
222
|
|
219
|
-
out_str.unshift(" #{@control.title.dump}:")
|
223
|
+
@control.title.nil? ? out_str.unshift(" #{@control.id.dump}:") : out_str.unshift(" #{@control.title.dump}:")
|
220
224
|
out_str.unshift(' control_configs:')
|
221
225
|
out_str.unshift("#{@module_name}::config:")
|
222
226
|
@md.add_ul('Hiera Configuration Example:')
|
223
227
|
@md.add_code_block(out_str.join("\n"), language: 'yaml')
|
224
228
|
rescue StandardError => e
|
229
|
+
require 'pry'; binding.pry
|
225
230
|
err_msg = [
|
226
231
|
"Failed to generate config example for control #{@control.id}",
|
227
232
|
"Error: #{e.message}",
|
@@ -6,13 +6,13 @@ require 'abide_dev_utils/cem/hiera_data/mapping_data/mixins'
|
|
6
6
|
module AbideDevUtils
|
7
7
|
module CEM
|
8
8
|
module Mapping
|
9
|
-
ALL_TYPES = %w[hiera_title_num number hiera_title vulnid
|
9
|
+
ALL_TYPES = %w[hiera_title_num number hiera_title title vulnid ruleid].freeze
|
10
10
|
FRAMEWORK_TYPES = {
|
11
11
|
'cis' => %w[hiera_title_num number hiera_title title],
|
12
|
-
'stig' => %w[
|
12
|
+
'stig' => %w[vulnid ruleid],
|
13
13
|
}.freeze
|
14
14
|
CIS_TYPES = %w[hiera_title_num number hiera_title title].freeze
|
15
|
-
STIG_TYPES = %w[
|
15
|
+
STIG_TYPES = %w[vulnid ruleid].freeze
|
16
16
|
|
17
17
|
# Represents a single map data file
|
18
18
|
class MapData
|
@@ -168,6 +168,8 @@ module AbideDevUtils
|
|
168
168
|
'hiera_title'
|
169
169
|
when %r{^V-[0-9]{6}$}
|
170
170
|
'vulnid'
|
171
|
+
when %r{^SV-[0-9]+r[0-9]+_rule$}
|
172
|
+
'ruleid'
|
171
173
|
else
|
172
174
|
'title'
|
173
175
|
end
|
@@ -22,6 +22,7 @@ module Abide
|
|
22
22
|
add_command(JiraGetIssueCommand.new)
|
23
23
|
add_command(JiraNewIssueCommand.new)
|
24
24
|
add_command(JiraFromCoverageCommand.new)
|
25
|
+
add_command(JiraFromXccdfCommand.new)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -113,5 +114,26 @@ module Abide
|
|
113
114
|
end
|
114
115
|
end
|
115
116
|
end
|
117
|
+
|
118
|
+
class JiraFromXccdfCommand < CmdParse::Command
|
119
|
+
CMD_NAME = 'from_xccdf'
|
120
|
+
CMD_SHORT = 'Creates a parent issue with subtasks from a xccdf file'
|
121
|
+
CMD_LONG = 'Creates a parent issue with subtasks for a benchmark and any uncovered controls'
|
122
|
+
def initialize
|
123
|
+
super(CMD_NAME, takes_commands: false)
|
124
|
+
short_desc(CMD_SHORT)
|
125
|
+
long_desc(CMD_LONG)
|
126
|
+
argument_desc(PATH: 'An XCCDF file from the abide puppet ticket coverage command', PROJECT: 'A Jira project')
|
127
|
+
options.on('-d', '--dry-run', 'Print to console instead of saving objects') { |_| @data[:dry_run] = true }
|
128
|
+
end
|
129
|
+
|
130
|
+
def execute(path, project)
|
131
|
+
Abide::CLI::VALIDATE.file(path)
|
132
|
+
@data[:dry_run] = false if @data[:dry_run].nil?
|
133
|
+
client = JIRA.client(options: {})
|
134
|
+
proj = JIRA.project(client, project)
|
135
|
+
JIRA.new_issues_from_xccdf(client, proj, path, dry_run: @data[:dry_run])
|
136
|
+
end
|
137
|
+
end
|
116
138
|
end
|
117
139
|
end
|
data/lib/abide_dev_utils/jira.rb
CHANGED
@@ -135,6 +135,36 @@ module AbideDevUtils
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
def self.new_issues_from_xccdf(client, project, xccdf_path, dry_run: false)
|
139
|
+
dr_prefix = dry_run ? 'DRY RUN: ' : ''
|
140
|
+
i_attrs = all_project_issues_attrs(project)
|
141
|
+
|
142
|
+
xccdf = AbideDevUtils::XCCDF::Benchmark.new(xccdf_path)
|
143
|
+
|
144
|
+
summaries = summaries_from_xccdf(xccdf)
|
145
|
+
summaries.each do |profile_summary, control_summaries|
|
146
|
+
if summary_exist?(profile_summary, i_attrs)
|
147
|
+
AbideDevUtils::Output.simple("#{dr_prefix}Skipping #{profile_summary} as it already exists")
|
148
|
+
next
|
149
|
+
end
|
150
|
+
|
151
|
+
parent = new_issue(client, project.attrs['key'], profile_summary, dry_run: dry_run)
|
152
|
+
AbideDevUtils::Output.simple("#{dr_prefix}Created parent issue #{profile_summary}")
|
153
|
+
parent_issue = issue(client, parent.attrs['key']) unless parent.respond_to?(:dummy)
|
154
|
+
AbideDevUtils::Output.simple("#{dr_prefix}Creating subtasks, this can take a while...")
|
155
|
+
progress = AbideDevUtils::Output.progress(title: "#{dr_prefix}Creating Subtasks", total: nil)
|
156
|
+
control_summaries.each do |control_summary|
|
157
|
+
next if summary_exist?(control_summary, i_attrs)
|
158
|
+
|
159
|
+
progress.title = "#{dr_prefix}#{control_summary}"
|
160
|
+
new_subtask(client, parent_issue, control_summary, dry_run: dry_run)
|
161
|
+
progress.increment
|
162
|
+
end
|
163
|
+
final_text = "#{dr_prefix}Created #{control_summaries.count} subtasks for #{profile_summary}"
|
164
|
+
puts "\r\033[K#{final_text}\n"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
138
168
|
# def self.new_issues_from_comply_report(client, project, report, dry_run: false)
|
139
169
|
# dr_prefix = dry_run ? 'DRY RUN: ' : ''
|
140
170
|
# i_attrs = all_project_issues_attrs(project)
|
@@ -177,6 +207,21 @@ module AbideDevUtils
|
|
177
207
|
summaries.transform_keys { |k| "#{COV_PARENT_SUMMARY_PREFIX}#{benchmark}-#{k}"}
|
178
208
|
end
|
179
209
|
|
210
|
+
def self.summaries_from_xccdf(xccdf)
|
211
|
+
summaries = {}
|
212
|
+
facter_os = xccdf.facter_benchmark.join('-')
|
213
|
+
xccdf.profiles.each do |profile|
|
214
|
+
summaries["#{COV_PARENT_SUMMARY_PREFIX}#{facter_os} - #{profile.level} #{profile.title}"] = profile.controls.collect do |control|
|
215
|
+
summary = "#{COV_CHILD_SUMMARY_PREFIX}#{control.vulnid} - #{control.title}"
|
216
|
+
if summary.length > 255
|
217
|
+
summary = summary[0..251] + '...'
|
218
|
+
end
|
219
|
+
summary
|
220
|
+
end
|
221
|
+
end
|
222
|
+
summaries
|
223
|
+
end
|
224
|
+
|
180
225
|
# def self.summaries_from_comply_report(report)
|
181
226
|
# summaries = {}
|
182
227
|
# report.each do |_, v|
|
@@ -157,7 +157,8 @@ module AbideDevUtils
|
|
157
157
|
raise AbideDevUtils::Errors::ControlPartsError, control
|
158
158
|
end
|
159
159
|
rule_id = group.xpath('Rule/@id').first.value
|
160
|
-
|
160
|
+
title = group.xpath('Rule/title').text
|
161
|
+
return [vuln_id, rule_id, title]
|
161
162
|
else
|
162
163
|
raise AbideDevUtils::Errors::ControlPartsError, control
|
163
164
|
end
|
@@ -658,8 +659,8 @@ module AbideDevUtils
|
|
658
659
|
class StigControl < XccdfElement
|
659
660
|
def initialize(control, benchmark)
|
660
661
|
super(control, benchmark)
|
661
|
-
@vulnid, @ruleid = control_parts(control_profile_text(control))
|
662
|
-
properties :vulnid, :ruleid
|
662
|
+
@vulnid, @ruleid, @title = control_parts(control_profile_text(control))
|
663
|
+
properties :vulnid, :ruleid, :title
|
663
664
|
end
|
664
665
|
end
|
665
666
|
|
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.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abide-team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|