Class: Nexpose::SmtpAlert

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

Overview

Description

Object that represents an SMTP (Email) Alert.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sanitize

#replace_entities

Constructor Details

#initialize(name, sender, limitText, enabled = 1) ⇒ SmtpAlert

Returns a new instance of SmtpAlert.



1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
# File 'lib/nexpose.rb', line 1668

def initialize(name, sender, limitText, enabled = 1)
	@type = :smtp
	@name = name
	@sender = sender
	@enabled = enabled
	@limitText = limitText
	@recipients = Array.new()
	# Sets default vuln filter - All Events
	setVulnFilter(VulnFilter.new("50790400",1))
end

Instance Attribute Details

#enabledObject (readonly)

If this alert is enabled or not



1655
1656
1657
# File 'lib/nexpose.rb', line 1655

def enabled
  @enabled
end

#limitTextObject (readonly)

Limit the text for mobile devices



1659
1660
1661
# File 'lib/nexpose.rb', line 1659

def limitText
  @limitText
end

#nameObject (readonly)

A unique name for this alert



1653
1654
1655
# File 'lib/nexpose.rb', line 1653

def name
  @name
end

#recipientsObject (readonly)

Array of strings with the email addresses of the intended recipients



1662
1663
1664
# File 'lib/nexpose.rb', line 1662

def recipients
  @recipients
end

#senderObject (readonly)

The email address of the sender



1657
1658
1659
# File 'lib/nexpose.rb', line 1657

def sender
  @sender
end

#typeObject (readonly)

The alert type



1666
1667
1668
# File 'lib/nexpose.rb', line 1666

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



1664
1665
1666
# File 'lib/nexpose.rb', line 1664

def vulnFilter
  @vulnFilter
end

Instance Method Details

#addRecipient(recipient) ⇒ Object

Adds a new Recipient to the recipients array



1680
1681
1682
# File 'lib/nexpose.rb', line 1680

def addRecipient(recipient)
	@recipients.push(recipient)
end

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



1685
1686
1687
# File 'lib/nexpose.rb', line 1685

def setVulnFilter(vulnFilter)
	@vulnFilter = vulnFilter
end

#to_xmlObject



1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
# File 'lib/nexpose.rb', line 1690

def to_xml
	xml = "<smtpAlert"
	xml << %Q{ name="#{replace_entities(name)}"}
	xml << %Q{ enabled="#{replace_entities(enabled)}"}
	xml << %Q{ sender="#{replace_entities(sender)}"}
	xml << %Q{ limitText="#{replace_entities(limitText)}">}
	recipients.each do |recpt|
		xml << "<recipient>#{replace_entities(recpt)}</recipient>"
	end
	xml << vulnFilter.to_xml
	xml << "</smtpAlert>"
	xml
end