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, limit_text, enabled = 1) ⇒ SMTPAlert

Returns a new instance of SMTPAlert.



651
652
653
654
655
656
657
658
659
660
# File 'lib/nexpose/site.rb', line 651

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

Instance Attribute Details

#enabledObject (readonly)

If this alert is enabled or not



638
639
640
# File 'lib/nexpose/site.rb', line 638

def enabled
  @enabled
end

#limit_textObject (readonly)

Limit the text for mobile devices



642
643
644
# File 'lib/nexpose/site.rb', line 642

def limit_text
  @limit_text
end

#nameObject (readonly)

A unique name for this alert



636
637
638
# File 'lib/nexpose/site.rb', line 636

def name
  @name
end

#recipientsObject (readonly)

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



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

def recipients
  @recipients
end

#senderObject (readonly)

The email address of the sender



640
641
642
# File 'lib/nexpose/site.rb', line 640

def sender
  @sender
end

#typeObject (readonly)

The alert type



649
650
651
# File 'lib/nexpose/site.rb', line 649

def type
  @type
end

#vuln_filterObject

The vulnerability filter to trigger the alert



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

def vuln_filter
  @vuln_filter
end

Instance Method Details

#add_recipient(recipient) ⇒ Object

Adds a new Recipient to the recipients array



663
664
665
# File 'lib/nexpose/site.rb', line 663

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

#to_xmlObject



669
670
671
672
673
674
675
676
677
678
679
680
681
# File 'lib/nexpose/site.rb', line 669

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(limit_text)}">}
  recipients.each do |recpt|
    xml << "<recipient>#{replace_entities(recpt)}</recipient>"
  end
  xml << vuln_filter.to_xml
  xml << '</smtpAlert>'
  xml
end