Class: Nexpose::SMTPAlert

Inherits:
Object
  • Object
show all
Includes:
Sanitize
Defined in:
lib/nexpose/site.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.



634
635
636
637
638
639
640
641
642
643
# File 'lib/nexpose/site.rb', line 634

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

Instance Attribute Details

#enabledObject (readonly)

If this alert is enabled or not



621
622
623
# File 'lib/nexpose/site.rb', line 621

def enabled
  @enabled
end

#limitTextObject (readonly)

Limit the text for mobile devices



625
626
627
# File 'lib/nexpose/site.rb', line 625

def limitText
  @limitText
end

#nameObject (readonly)

A unique name for this alert



619
620
621
# File 'lib/nexpose/site.rb', line 619

def name
  @name
end

#recipientsObject (readonly)

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



628
629
630
# File 'lib/nexpose/site.rb', line 628

def recipients
  @recipients
end

#senderObject (readonly)

The email address of the sender



623
624
625
# File 'lib/nexpose/site.rb', line 623

def sender
  @sender
end

#typeObject (readonly)

The alert type



632
633
634
# File 'lib/nexpose/site.rb', line 632

def type
  @type
end

#vulnFilterObject (readonly)

The vulnerability filter to trigger the alert



630
631
632
# File 'lib/nexpose/site.rb', line 630

def vulnFilter
  @vulnFilter
end

Instance Method Details

#addRecipient(recipient) ⇒ Object

Adds a new Recipient to the recipients array



646
647
648
# File 'lib/nexpose/site.rb', line 646

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

#setVulnFilter(vulnFilter) ⇒ Object

Sets the Vulnerability Filter for this alert.



651
652
653
# File 'lib/nexpose/site.rb', line 651

def setVulnFilter(vulnFilter)
  @vulnFilter = vulnFilter
end

#to_xmlObject



657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/nexpose/site.rb', line 657

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