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.



1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
# File 'lib/nexpose.rb', line 1317

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



1304
1305
1306
# File 'lib/nexpose.rb', line 1304

def enabled
  @enabled
end

#limitTextObject (readonly)

Limit the text for mobile devices



1308
1309
1310
# File 'lib/nexpose.rb', line 1308

def limitText
  @limitText
end

#nameObject (readonly)

A unique name for this alert



1302
1303
1304
# File 'lib/nexpose.rb', line 1302

def name
  @name
end

#recipientsObject (readonly)

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



1311
1312
1313
# File 'lib/nexpose.rb', line 1311

def recipients
  @recipients
end

#senderObject (readonly)

The email address of the sender



1306
1307
1308
# File 'lib/nexpose.rb', line 1306

def sender
  @sender
end

#typeObject (readonly)

The alert type



1315
1316
1317
# File 'lib/nexpose.rb', line 1315

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



1313
1314
1315
# File 'lib/nexpose.rb', line 1313

def vulnFilter
  @vulnFilter
end

Instance Method Details

#addRecipient(recipient) ⇒ Object

Adds a new Recipient to the recipients array



1329
1330
1331
# File 'lib/nexpose.rb', line 1329

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

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



1334
1335
1336
# File 'lib/nexpose.rb', line 1334

def setVulnFilter(vulnFilter)
	@vulnFilter = vulnFilter
end

#to_xmlObject



1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
# File 'lib/nexpose.rb', line 1339

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