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.



1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'lib/nexpose.rb', line 1191

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



1178
1179
1180
# File 'lib/nexpose.rb', line 1178

def enabled
  @enabled
end

#limitTextObject (readonly)

Limit the text for mobile devices



1182
1183
1184
# File 'lib/nexpose.rb', line 1182

def limitText
  @limitText
end

#nameObject (readonly)

A unique name for this alert



1176
1177
1178
# File 'lib/nexpose.rb', line 1176

def name
  @name
end

#recipientsObject (readonly)

Array containing Strings of email addresses Array of strings with the email addresses of the intended recipients



1185
1186
1187
# File 'lib/nexpose.rb', line 1185

def recipients
  @recipients
end

#senderObject (readonly)

The email address of the sender



1180
1181
1182
# File 'lib/nexpose.rb', line 1180

def sender
  @sender
end

#typeObject (readonly)

The alert type



1189
1190
1191
# File 'lib/nexpose.rb', line 1189

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



1187
1188
1189
# File 'lib/nexpose.rb', line 1187

def vulnFilter
  @vulnFilter
end

Instance Method Details

#addRecipient(recipient) ⇒ Object

Adds a new Recipient to the recipients array



1203
1204
1205
# File 'lib/nexpose.rb', line 1203

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

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



1208
1209
1210
# File 'lib/nexpose.rb', line 1208

def setVulnFilter(vulnFilter)
	@vulnFilter = vulnFilter
end

#to_xmlObject



1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
# File 'lib/nexpose.rb', line 1213

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