Class: RubyNessus::Version2::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-nessus/version2/event.rb

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Event

Returns a new instance of Event.



8
9
10
# File 'lib/ruby-nessus/version2/event.rb', line 8

def initialize(event)
  @event = event
end

Instance Method Details

#bidArray<String>?

Return the event bid.

Returns:

  • (Array<String>, nil)

    Return the event bid.



286
287
288
289
290
291
292
293
294
295
# File 'lib/ruby-nessus/version2/event.rb', line 286

def bid
  unless @bid
    @bid = []
    @event.xpath('bid').each do |bid|
      @bid << bid.inner_text
    end
    @bid = nil if @bid.empty?
  end
  @bid
end

#canvas_packageString?

Return the name of the CANVAS exploit package

Returns:

  • (String, nil)

    Return the canvas_package.



375
376
377
# File 'lib/ruby-nessus/version2/event.rb', line 375

def canvas_package
  @canvas_package ||= @event.at('canvas_package')&.inner_text
end

#cpeArray<String>

Return the event cpe.

Returns:

  • (Array<String>)

    Return the event cpe.



329
330
331
332
333
334
335
336
337
# File 'lib/ruby-nessus/version2/event.rb', line 329

def cpe
  unless @cpe
    @cpe = []
    @event.xpath('cpe').each do |cpe|
      @cpe << cpe.inner_text
    end
  end
  @cpe
end

#critical?Boolean

Return true if the event is of critical severity.

Returns:

  • (Boolean)

    Return true if the event is critical severity.



87
88
89
# File 'lib/ruby-nessus/version2/event.rb', line 87

def critical?
  severity == 4
end

#cveArray<String>?

Return the event cve.

Returns:

  • (Array<String>, nil)

    Return the event cvss base score.



269
270
271
272
273
274
275
276
277
278
# File 'lib/ruby-nessus/version2/event.rb', line 269

def cve
  unless @cve
    @cve = []
    @event.xpath('cve').each do |cve|
      @cve << cve.inner_text
    end
    @cve = nil if @cve.empty?
  end
  @cve
end

#cvss_base_scorefloat?

Return the event cvss base score.

Returns:

  • (float, nil)

    Return the event cvss base score.



249
250
251
# File 'lib/ruby-nessus/version2/event.rb', line 249

def cvss_base_score
  @cvss_base_score ||= @event.at('cvss_base_score')&.inner_text.to_f
end

#cvss_temporal_scorefloat?

Return the event cvss temporal score.

Returns:

  • (float, nil)

    Return the event cvss temporal score.



259
260
261
# File 'lib/ruby-nessus/version2/event.rb', line 259

def cvss_temporal_score
  @cvss_temporal_score ||= @event.at('cvss_temporal_score')&.inner_text.to_f
end

#cvss_vectorString?

Return other event cvss vector.

Returns:

  • (String, nil)

    Return the event cvss vector.



319
320
321
# File 'lib/ruby-nessus/version2/event.rb', line 319

def cvss_vector
  @cvss_vector ||= @event.at('cvss_vector')&.inner_text
end

#descriptionString?

Return the event description.

Returns:

  • (String, nil)

    Return the event description.



163
164
165
# File 'lib/ruby-nessus/version2/event.rb', line 163

def description
  @description ||= @event.at('description')&.inner_text
end

#exploit_availableBoolean

Return event exploit available.

Returns:

  • (Boolean)

    Return the event exploit available.



355
356
357
# File 'lib/ruby-nessus/version2/event.rb', line 355

def exploit_available
  @exploit_available ||= @event.at('exploit_available')&.inner_text == "true"
end

#exploit_framework_canvasBoolean

Return if an exploit exists in the Immunity CANVAS framework.

Returns:

  • (Boolean)

    Return the event exploit framework canvas.



365
366
367
# File 'lib/ruby-nessus/version2/event.rb', line 365

def exploit_framework_canvas
  @exploit_framework_canvas ||= @event.at('exploit_framework_canvas')&.inner_text == "true"
end

#exploit_framework_coreBoolean

Return if an exploit exploit exists in the CORE Impact framework

Returns:

  • (Boolean)

    Return the event exploit framework core.



405
406
407
# File 'lib/ruby-nessus/version2/event.rb', line 405

def exploit_framework_core
  @exploit_framework_core ||= @event.at('exploit_framework_core')&.inner_text == "true"
end

#exploit_framework_metasploitBoolean

Return if an exploit exploit exists in the Metasploit framework

Returns:

  • (Boolean)

    Return the event exploit framework metasploit.



385
386
387
# File 'lib/ruby-nessus/version2/event.rb', line 385

def exploit_framework_metasploit
  @exploit_framework_metasploit ||= @event.at('exploit_framework_metasploit')&.inner_text == "true"
end

#exploitability_easeString?

Return event exploitability ease.

Returns:

  • (String, nil)

    Return the event exploitability ease.



345
346
347
# File 'lib/ruby-nessus/version2/event.rb', line 345

def exploitability_ease
  @exploitability_ease ||= @event.at('exploitability_ease')&.inner_text
end

#familyString Also known as: plugin_family

Return the event object plugin family name.

Examples:

event.family #=> "Service detection"

Returns:

  • (String)

    Return the event object plugin family name.



114
115
116
# File 'lib/ruby-nessus/version2/event.rb', line 114

def family
  @plugin_family ||= @event.at('@pluginFamily').inner_text
end

#high?Boolean

Return true if the event is of high severity.

Returns:

  • (Boolean)

    Return true if the event is high severity.



77
78
79
# File 'lib/ruby-nessus/version2/event.rb', line 77

def high?
  severity == 3
end

#idInteger Also known as: plugin_id

Return the event object nessus plugin id

Examples:

event.plugin_id #=> 3245

Returns:

  • (Integer)

    Return the event object nessus plugin id



100
101
102
# File 'lib/ruby-nessus/version2/event.rb', line 100

def id
  @plugin_id ||= @event.at('@pluginID').inner_text.to_i
end

#informational?Boolean

Return true if event is of informational severity.

Returns:

  • (Boolean)

    Return true if the event is informational.



47
48
49
# File 'lib/ruby-nessus/version2/event.rb', line 47

def informational?
  severity == 0
end

#low?Boolean

Return true if the event is of low severity.

Returns:

  • (Boolean)

    Return true if the event is low severity.



57
58
59
# File 'lib/ruby-nessus/version2/event.rb', line 57

def low?
  severity == 1
end

#medium?Boolean

Return true if the event is of medium severity.

Returns:

  • (Boolean)

    Return true if the event is medium severity.



67
68
69
# File 'lib/ruby-nessus/version2/event.rb', line 67

def medium?
  severity == 2
end

#metasploit_nameString?

Return name of the Metasploit exploit module.

Returns:

  • (String, nil)

    Return the metasploit_name.



395
396
397
# File 'lib/ruby-nessus/version2/event.rb', line 395

def metasploit_name
  @metasploit_name ||= @event.at('metasploit_name')&.inner_text
end

#outputString? Also known as: data, plugin_output

Return the event plugin output.

Returns:

  • (String, nil)

    Return the event plugin output.



193
194
195
# File 'lib/ruby-nessus/version2/event.rb', line 193

def output
  @plugin_output ||= @event.at('plugin_output')&.inner_text
end

#patch_publication_dateTime?

Return the event patch publication date.

Returns:

  • (Time, nil)

    Return the event patch publication date.



239
240
241
# File 'lib/ruby-nessus/version2/event.rb', line 239

def patch_publication_date
  @patch_publication_date ||= Time.parse(@event.at('patch_publication_date').inner_text + ' UTC') if @event.at('patch_publication_date')
end

#plugin_nameString? Also known as: name

Return the event name (plugin_name)

Examples:

event.plugin_name   #=> "PHP < 5.2.4 Multiple Vulnerabilities"
event.name          #=> "PHP < 5.2.4 Multiple Vulnerabilities"

Returns:

  • (String, nil)

    Return the event name (plugin_name)



129
130
131
# File 'lib/ruby-nessus/version2/event.rb', line 129

def plugin_name
  @plugin_name ||= @event.at('@pluginName')&.inner_text unless @event.at('@pluginName').inner_text.empty?
end

#plugin_typeString?

Return the event object plugin type (plugin_type)

Examples:

event.plugin_type   #=> "remote"

Returns:

  • (String, nil)

    Return the event object plugin type (plugin_type)



143
144
145
# File 'lib/ruby-nessus/version2/event.rb', line 143

def plugin_type
  @plugin_type ||= @event.at('plugin_type')&.inner_text
end

#portObject

Return the event port.

Examples:

event.port            #=> "https (443/tcp)"
event.port.number     #=> 443
event.port.service    #=> "https"
event.port.protocol   #=> "tcp"

Returns:

  • (Object)

    Return the event port object or port string.



24
25
26
# File 'lib/ruby-nessus/version2/event.rb', line 24

def port
  @port ||= Port.new(@event.at('@port'), @event.at('@svc_name'), @event.at('@protocol'))
end

#riskString?

Return the event risk.

Returns:

  • (String, nil)

    Return the event risk.



183
184
185
# File 'lib/ruby-nessus/version2/event.rb', line 183

def risk
  @risk_factor ||= @event.at('risk_factor')&.inner_text
end

#see_alsoArray<String> Also known as: links, more, references

Return the event reference links.

Returns:

  • (Array<String>)

    Return the event reference links.



216
217
218
# File 'lib/ruby-nessus/version2/event.rb', line 216

def see_also
  @see_also ||= @event.at('see_also')&.inner_text&.split("\n")
end

#severityInteger

Return the event severity.

Examples:

event.severity          #=> 3

Returns:

  • (Integer)

    Return the event severity.



37
38
39
# File 'lib/ruby-nessus/version2/event.rb', line 37

def severity
  @severity ||= @event.at('@severity').inner_text.to_i
end

#solutionString?

Return the event solution.

Returns:

  • (String, nil)

    Return the event solution.



173
174
175
# File 'lib/ruby-nessus/version2/event.rb', line 173

def solution
  @solution ||= @event.at('solution')&.inner_text
end

#synopsisString?

Return the event synopsis.

Returns:

  • (String, nil)

    Return the event synopsis.



153
154
155
# File 'lib/ruby-nessus/version2/event.rb', line 153

def synopsis
  @synopsis ||= @event.at('synopsis')&.inner_text
end

#versionString? Also known as: plugin_version

Return the event plugin version.

Returns:

  • (String, nil)

    Return the event plugin version.



205
206
207
# File 'lib/ruby-nessus/version2/event.rb', line 205

def version
  @plugin_version ||= @event.at('plugin_version')&.inner_text
end

#vuln_publication_dateTime?

Return the event vulnerability publication date.

Returns:

  • (Time, nil)

    Return the event vulnerability publication date.



229
230
231
# File 'lib/ruby-nessus/version2/event.rb', line 229

def vuln_publication_date
  @vuln_publication_date ||= Time.parse(@event.at('vuln_publication_date').inner_text + ' UTC') if @event.at('vuln_publication_date')
end

#xrefArray<String>

Return other event related references.

Returns:

  • (Array<String>)

    Return the event related references.



303
304
305
306
307
308
309
310
311
# File 'lib/ruby-nessus/version2/event.rb', line 303

def xref
  unless @xref
    @xref = []
    @event.xpath('xref').each do |xref|
      @xref << xref.inner_text
    end
  end
  @xref
end