Class: Nexpose::SNMPAlert

Inherits:
Object
  • Object
show all
Includes:
Sanitize
Defined in:
lib/nexpose/site.rb

Overview

Description

Object that represents an SNMP Alert.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sanitize

#replace_entities

Constructor Details

#initialize(name, community, server, enabled = 1) ⇒ SNMPAlert

Returns a new instance of SNMPAlert.



666
667
668
669
670
671
672
673
674
# File 'lib/nexpose/site.rb', line 666

def initialize(name, community, server, enabled = 1)
  @type = :snmp
  @name = name
  @community = community
  @server = server
  @enabled = enabled
  # Sets default vuln filter - All Events
  setVulnFilter(VulnFilter.new("50790400", 1))
end

Instance Attribute Details

#communityObject (readonly)

The community string



658
659
660
# File 'lib/nexpose/site.rb', line 658

def community
  @community
end

#enabledObject (readonly)

If this alert is enabled or not



656
657
658
# File 'lib/nexpose/site.rb', line 656

def enabled
  @enabled
end

#nameObject (readonly)

A unique name for this alert



654
655
656
# File 'lib/nexpose/site.rb', line 654

def name
  @name
end

#serverObject (readonly)

The SNMP server to sent this alert



660
661
662
# File 'lib/nexpose/site.rb', line 660

def server
  @server
end

#typeObject (readonly)

The alert type



664
665
666
# File 'lib/nexpose/site.rb', line 664

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



662
663
664
# File 'lib/nexpose/site.rb', line 662

def vulnFilter
  @vulnFilter
end

Instance Method Details

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



677
678
679
# File 'lib/nexpose/site.rb', line 677

def setVulnFilter(vulnFilter)
  @vulnFilter = vulnFilter
end

#to_xmlObject



681
682
683
684
685
686
687
688
689
690
# File 'lib/nexpose/site.rb', line 681

def to_xml
  xml = "<snmpAlert"
  xml << %Q{ name="#{replace_entities(name)}"}
  xml << %Q{ enabled="#{replace_entities(enabled)}"}
  xml << %Q{ community="#{replace_entities(community)}"}
  xml << %Q{ server="#{replace_entities(server)}">}
  xml << vulnFilter.to_xml
  xml << "</snmpAlert>"
  xml
end