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.



769
770
771
772
773
774
775
776
777
# File 'lib/nexpose/site.rb', line 769

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



761
762
763
# File 'lib/nexpose/site.rb', line 761

def community
  @community
end

#enabledObject (readonly)

If this alert is enabled or not



759
760
761
# File 'lib/nexpose/site.rb', line 759

def enabled
  @enabled
end

#nameObject (readonly)

A unique name for this alert



757
758
759
# File 'lib/nexpose/site.rb', line 757

def name
  @name
end

#serverObject (readonly)

The SNMP server to sent this alert



763
764
765
# File 'lib/nexpose/site.rb', line 763

def server
  @server
end

#typeObject (readonly)

The alert type



767
768
769
# File 'lib/nexpose/site.rb', line 767

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



765
766
767
# File 'lib/nexpose/site.rb', line 765

def vulnFilter
  @vulnFilter
end

Instance Method Details

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



780
781
782
# File 'lib/nexpose/site.rb', line 780

def setVulnFilter(vulnFilter)
	@vulnFilter = vulnFilter
end

#to_xmlObject



784
785
786
787
788
789
790
791
792
793
# File 'lib/nexpose/site.rb', line 784

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