Class: Nexpose::SnmpAlert

Inherits:
Object
  • Object
show all
Includes:
Sanitize
Defined in:
lib/nexpose.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.



1723
1724
1725
1726
1727
1728
1729
1730
1731
# File 'lib/nexpose.rb', line 1723

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



1715
1716
1717
# File 'lib/nexpose.rb', line 1715

def community
  @community
end

#enabledObject (readonly)

If this alert is enabled or not



1713
1714
1715
# File 'lib/nexpose.rb', line 1713

def enabled
  @enabled
end

#nameObject (readonly)

A unique name for this alert



1711
1712
1713
# File 'lib/nexpose.rb', line 1711

def name
  @name
end

#serverObject (readonly)

The SNMP server to sent this alert



1717
1718
1719
# File 'lib/nexpose.rb', line 1717

def server
  @server
end

#typeObject (readonly)

The alert type



1721
1722
1723
# File 'lib/nexpose.rb', line 1721

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



1719
1720
1721
# File 'lib/nexpose.rb', line 1719

def vulnFilter
  @vulnFilter
end

Instance Method Details

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



1734
1735
1736
# File 'lib/nexpose.rb', line 1734

def setVulnFilter(vulnFilter)
	@vulnFilter = vulnFilter
end

#to_xmlObject



1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
# File 'lib/nexpose.rb', line 1739

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