class Nexpose::Email

Configuration structure for e-mail notification.

The send_as and send_to_acl_as attributes are optional, but one of them is required for sending reports via e-mail. The send_as attribute is required for sending e-mails to users who are not on the report access list. The send_to_acl attribute is required for sending e-mails to report access list members.

E-mails and attachments are sent via the Internet in clear text and are not encrypted. If you do not set a valid value for either attribute, the application will save the report but not send it via e-mail. If you set a valid value for the send_as attribute but not for the send_to_acl_as attribute, the application will send the report via e-mail to non-access-list members only. If you set a valid value for the send_to_acl_as attribute, the application will send the report via e-mail to access-list members only. If you set a valid value for both attributes, the application will send reports via e-mail to access-list members and non-members.

Attributes

recipients[RW]

Recipients will be in form of email address.

Array<String>

E-mail addresses of additional report recipients (i.e., not already on the report access list).

send_as[RW]

Send as file attachment or zipped file to individuals who are not members of the report access list.

String

Attachment format, 'file' | 'zip'.

send_to_acl_as[RW]

Send to users on the report access list.

String

Attachment format 'file' | 'zip'

send_to_owner_as[RW]

Format to send to users on the report access list.

String

Attachment format 'file' | 'zip' | 'url'

sender[RW]

Sender that e-mail will be attributed to.

String

an email address

smtp_relay_server[RW]

SMTP relay server.

String

the IP address, host name or FQDN of the SMTP server.

to_all_authorized[RW]

Send to all the authorized users of sites, groups, and assets.

Fixnum

1 | 0

Public Class Methods

new(to_all_authorized, send_to_owner_as, send_to_acl_as, send_as) click to toggle source
# File lib/nexpose/common.rb, line 50
def initialize(to_all_authorized, send_to_owner_as, send_to_acl_as, send_as)
  @to_all_authorized = to_all_authorized
  @send_to_owner_as  = send_to_owner_as
  @send_to_acl_as    = send_to_acl_as
  @send_as           = send_as
  @recipients        = []
end
parse(xml) click to toggle source
# File lib/nexpose/common.rb, line 77
def self.parse(xml)
  xml.elements.each('//Email') do |email|
    config = Email.new(email.attributes['toAllAuthorized'] == '1',
                       email.attributes['sendToOwnerAs'],
                       email.attributes['sendToAclAs'],
                       email.attributes['sendAs'])

    xml.elements.each('//Sender') do |sender|
      config.sender = sender.text
    end
    xml.elements.each('//SmtpRelayServer') do |server|
      config.smtp_relay_server = server.text
    end
    xml.elements.each('//Recipient') do |recipient|
      config.recipients << recipient.text
    end
    return config
  end
  nil
end

Public Instance Methods

to_xml() click to toggle source
# File lib/nexpose/common.rb, line 58
def to_xml
  xml = '<Email'
  xml << %( toAllAuthorized='#{@to_all_authorized ? 1 : 0}')
  xml << %( sendToOwnerAs='#{@send_to_owner_as}') if @send_to_owner_as
  xml << %( sendToAclAs='#{@send_to_acl_as}') if @send_to_acl_as
  xml << %( sendAs='#{@send_as}') if @send_as
  xml << '>'
  xml << %(<Sender>#{@sender}</Sender>) if @sender
  xml << %(<SmtpRelayServer>#{@smtp_relay_server}</SmtpRelayServer>) if @smtp_relay_server
  if @recipients
    xml << '<Recipients>'
    @recipients.each do |recipient|
      xml << %(<Recipient>#{recipient}</Recipient>)
    end
    xml << '</Recipients>'
  end
  xml << '</Email>'
end