Class: VulnerabilityMode

Inherits:
BaseMode show all
Defined in:
lib/nexpose_ticketing/modes/vulnerability_mode.rb

Instance Method Summary collapse

Methods inherited from BaseMode

#finalize_description, #get_assets, #get_discovery_info, #get_field_info, #get_header, #get_references, #get_short_summary, #get_solutions, #get_vuln_info, #load_queries, #method_missing, #set_solution_store, #truncate_title, #updates_supported?

Constructor Details

#initialize(options) ⇒ VulnerabilityMode

Initializes the mode



6
7
8
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 6

def initialize(options)
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BaseMode

Instance Method Details

#get_description(nexpose_id, row) ⇒ Object

Returns the base ticket description object



36
37
38
39
40
41
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 36

def get_description(nexpose_id, row)
  description = { nxid: "NXID: #{get_nxid(nexpose_id, row)}" }
  fields = ['header', 'references', 'solutions', 'assets', 'vuln_description']
  fields.each { |f| description[f.intern] = self.send("get_#{f}", row) }
  description
end

#get_matching_fieldsObject

Returns the fields used to identify individual tickets



11
12
13
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 11

def get_matching_fields
  ['vulnerability_id']
end

#get_nxid(nexpose_id, row) ⇒ Object

Generates a unique identifier for a ticket



21
22
23
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 21

def get_nxid(nexpose_id, row)
  "#{nexpose_id}v#{row['vulnerability_id']}"
end

#get_query_suffixObject

Returns the suffix used for query method names



26
27
28
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 26

def get_query_suffix
  '_by_vuln_id'
end

#get_title(row) ⇒ Object

Returns the ticket’s title



16
17
18
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 16

def get_title(row)
  truncate_title "Vulnerability: #{row['title']}"
end

#get_vuln_description(row) ⇒ Object



30
31
32
33
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 30

def get_vuln_description(row)
  return '' if row['description'].to_s == ''
  "\nVulnerability Description: #{row['description']}"
end

Converts the ticket description object into a formatted string



50
51
52
53
54
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 50

def print_description(description)
  fields = [:header, :assets, :references, :solutions, :vuln_description]
  finalize_description(fields.map { |f| description[f] }.join("\n"),
                       description[:nxid])
end

#update_description(description, row) ⇒ Object

Updates the ticket description based on row data



44
45
46
47
# File 'lib/nexpose_ticketing/modes/vulnerability_mode.rb', line 44

def update_description(description, row)
  description[:assets] += "\n#{get_assets(row)}"
  description
end