lib/inspec_tools/pdf.rb in inspec_tools-2.3.5 vs lib/inspec_tools/pdf.rb in inspec_tools-2.3.6
- old
+ new
@@ -4,14 +4,10 @@
require_relative '../utilities/extract_pdf_text'
require_relative '../utilities/parser'
require_relative '../utilities/text_cleaner'
require_relative '../utilities/cis_to_nist'
-# rubocop:disable Metrics/AbcSize
-# rubocop:disable Metrics/PerceivedComplexity
-# rubocop:disable Metrics/CyclomaticComplexity
-
module InspecTools
class PDF
def initialize(pdf, profile_name, debug = false)
raise ArgumentError if pdf.nil?
@@ -57,19 +53,19 @@
def parse_controls
controls = []
@transformed_data.each do |contr|
nist = find_nist(contr[:cis]) unless contr[:cis] == 'No CIS Control'
control = {}
- control['id'] = 'M-' + contr[:title].split(' ')[0]
+ control['id'] = "M-#{contr[:title].split[0]}"
control['title'] = contr[:title]
control['desc'] = contr[:descr]
control['impact'] = Utils::InspecUtil.get_impact('medium')
control['tags'] = {}
control['tags']['severity'] = Utils::InspecUtil.get_impact_string(control['impact'])
control['tags']['ref'] = contr[:ref] unless contr[:ref].nil?
control['tags']['applicability'] = contr[:applicability] unless contr[:applicability].nil?
- control['tags']['cis_id'] = contr[:title].split(' ')[0] unless contr[:title].nil?
+ control['tags']['cis_id'] = contr[:title].split[0] unless contr[:title].nil?
control['tags']['cis_control'] = [contr[:cis], @nist_mapping[0][:cis_ver]] unless contr[:cis].nil? # tag cis_control: [5, 6.1] ##6.1 is the version
control['tags']['cis_level'] = contr[:level] unless contr[:level].nil?
control['tags']['nist'] = nist unless nist.nil? # tag nist: [AC-3, 4] ##4 is the version
control['tags']['check'] = contr[:check] unless contr[:check].nil?
control['tags']['fix'] = contr[:fix] unless contr[:fix].nil?
@@ -89,11 +85,11 @@
@profile['summary'] = 'An InSpec Compliance Profile'
@profile['version'] = '0.1.0'
@profile['supports'] = []
@profile['attributes'] = []
@profile['generator'] = {
- 'name': 'inspec_tools',
- 'version': VERSION
+ name: 'inspec_tools',
+ version: VERSION
}
end
def extract_title
@pdf_text.match(/([^\n]*)\n/).captures[0]