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.



1594
1595
1596
1597
1598
1599
1600
1601
1602
# File 'lib/nexpose.rb', line 1594

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



1586
1587
1588
# File 'lib/nexpose.rb', line 1586

def community
  @community
end

#enabledObject (readonly)

If this alert is enabled or not



1584
1585
1586
# File 'lib/nexpose.rb', line 1584

def enabled
  @enabled
end

#nameObject (readonly)

A unique name for this alert



1582
1583
1584
# File 'lib/nexpose.rb', line 1582

def name
  @name
end

#serverObject (readonly)

The SNMP server to sent this alert



1588
1589
1590
# File 'lib/nexpose.rb', line 1588

def server
  @server
end

#typeObject (readonly)

The alert type



1592
1593
1594
# File 'lib/nexpose.rb', line 1592

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



1590
1591
1592
# File 'lib/nexpose.rb', line 1590

def vulnFilter
  @vulnFilter
end

Instance Method Details

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



1605
1606
1607
# File 'lib/nexpose.rb', line 1605

def setVulnFilter(vulnFilter)
	@vulnFilter = vulnFilter
end

#to_xmlObject



1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
# File 'lib/nexpose.rb', line 1610

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