Class: Nexpose::ReportConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose.rb

Overview

Description

Object that represents the configuration of a report definition.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, config_id = -1)) ⇒ ReportConfig

Returns a new instance of ReportConfig.



2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
# File 'lib/nexpose.rb', line 2080

def initialize(connection, config_id = -1)

	@error = false
	@connection = connection
	@config_id = config_id
	@xml_tag_stack = Array.new()
	@filters = Array.new()
	@email_recipients = Array.new()
	@name = "New Report " + rand(999999999).to_s

	r = @connection.execute('<ReportConfigRequest session-id="' + @connection.session_id.to_s + '" reportcfg-id="' + @config_id.to_s + '"/>')
	if (r.success)
		r.res.elements.each('ReportConfigResponse/ReportConfig') do |r|
			@name = r.attributes['name']
			@format = r.attributes['format']
			@timezone = r.attributes['timezone']
			@id = r.attributes['id']
			@template_id = r.attributes['template-id']
			@owner = r.attributes['owner']
		end
	else
		@error = true
		@error_msg = 'Error ReportHistoryReponse'
	end
end

Instance Attribute Details

#config_idObject (readonly)

The ID for this report definition



2036
2037
2038
# File 'lib/nexpose.rb', line 2036

def config_id
  @config_id
end

#connectionObject (readonly)

The NSC Connection associated with this object



2034
2035
2036
# File 'lib/nexpose.rb', line 2034

def connection
  @connection
end

#csv_exportObject (readonly)

TODO



2075
2076
2077
# File 'lib/nexpose.rb', line 2075

def csv_export
  @csv_export
end

#db_exportObject (readonly)

TODO



2073
2074
2075
# File 'lib/nexpose.rb', line 2073

def db_export
  @db_export
end

#email_AsObject (readonly)

Form to send the report via email “file”, “zip”, “url”, or NULL (don’t send email)



2062
2063
2064
# File 'lib/nexpose.rb', line 2062

def email_As
  @email_As
end

#email_recipientsObject (readonly)

Array containing the email addresses of the recipients



2067
2068
2069
# File 'lib/nexpose.rb', line 2067

def email_recipients
  @email_recipients
end

#email_to_allObject (readonly)

Send the Email to all Authorized Users boolean - Send the Email to all Authorized Users



2065
2066
2067
# File 'lib/nexpose.rb', line 2065

def email_to_all
  @email_to_all
end

#errorObject (readonly)

true if an error condition exists; false otherwise



2026
2027
2028
# File 'lib/nexpose.rb', line 2026

def error
  @error
end

#error_msgObject (readonly)

Error message string



2028
2029
2030
# File 'lib/nexpose.rb', line 2028

def error_msg
  @error_msg
end

#filtersObject (readonly)

Array of (ReportFilter)* - The Sites, Asset Groups, or Devices to run the report against



2048
2049
2050
# File 'lib/nexpose.rb', line 2048

def filters
  @filters
end

#formatObject (readonly)

html, db, txt, xml, raw-xml, csv, pdf



2042
2043
2044
# File 'lib/nexpose.rb', line 2042

def format
  @format
end

#generate_after_scanObject (readonly)

Automatically generate a new report at the conclusion of a scan 1 or 0



2051
2052
2053
# File 'lib/nexpose.rb', line 2051

def generate_after_scan
  @generate_after_scan
end

#nameObject (readonly)

A unique name for this report definition



2038
2039
2040
# File 'lib/nexpose.rb', line 2038

def name
  @name
end

#ownerObject (readonly)

XXX new



2046
2047
2048
# File 'lib/nexpose.rb', line 2046

def owner
  @owner
end

#request_xmlObject (readonly)

The last XML request sent by this object



2030
2031
2032
# File 'lib/nexpose.rb', line 2030

def request_xml
  @request_xml
end

#response_xmlObject (readonly)

The last XML response received by this object



2032
2033
2034
# File 'lib/nexpose.rb', line 2032

def response_xml
  @response_xml
end

#scheduleObject (readonly)

Schedule to generate reports ReportSchedule Object



2054
2055
2056
# File 'lib/nexpose.rb', line 2054

def schedule
  @schedule
end

#senderObject (readonly)

Sets the FROM field of the Email



2071
2072
2073
# File 'lib/nexpose.rb', line 2071

def sender
  @sender
end

#smtp_relay_serverObject (readonly)

IP Address or Hostname of SMTP Relay Server



2069
2070
2071
# File 'lib/nexpose.rb', line 2069

def smtp_relay_server
  @smtp_relay_server
end

#store_locationObject (readonly)

Location to store the report on the server



2059
2060
2061
# File 'lib/nexpose.rb', line 2059

def store_location
  @store_location
end

#storeOnServerObject (readonly)

Store the reports on the server 1 or 0



2057
2058
2059
# File 'lib/nexpose.rb', line 2057

def storeOnServer
  @storeOnServer
end

#template_idObject (readonly)

The template ID used for this report definition



2040
2041
2042
# File 'lib/nexpose.rb', line 2040

def template_id
  @template_id
end

#timezoneObject (readonly)

XXX new



2044
2045
2046
# File 'lib/nexpose.rb', line 2044

def timezone
  @timezone
end

#xml_exportObject (readonly)

TODO



2077
2078
2079
# File 'lib/nexpose.rb', line 2077

def xml_export
  @xml_export
end

Instance Method Details

#addEmailRecipient(recipient) ⇒ Object

Description

Adds a new email recipient



2132
2133
2134
# File 'lib/nexpose.rb', line 2132

def addEmailRecipient(recipient)
	@email_recipients.push(recipient)
end

#addFilter(filter_type, id) ⇒ Object

Description

Adds a new filter to the report config



2125
2126
2127
2128
# File 'lib/nexpose.rb', line 2125

def addFilter(filter_type, id)
	filter = ReportFilter.new(filter_type,id)
	@filters.push(filter)
end

#generateReport(debug = false) ⇒ Object

Description

Generate a new report on this report definition. Returns the new report ID.



2108
2109
2110
# File 'lib/nexpose.rb', line 2108

def generateReport(debug = false)
	return generateReport(@connection, @config_id, debug)
end

#getXMLObject



2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
# File 'lib/nexpose.rb', line 2142

def getXML()

	xml = '<ReportConfig id="' + @config_id.to_s + '" name="' + @name.to_s + '" template-id="' + @template_id.to_s + '" format="' + @format.to_s + '">'

	xml += ' <Filters>'

	@filters.each do |f|
		xml += ' <' + f.type.to_s + ' id="' + f.id.to_s + '"/>'
	end

	xml += ' </Filters>'

	xml += ' <Generate after-scan="' + @generate_after_scan.to_s + '">'

	if (@schedule)
		xml += ' <Schedule type="' + @schedule.type.to_s + '" interval="' + @schedule.interval.to_s + '" start="' + @schedule.start.to_s + '"/>'
	end

	xml += ' </Generate>'

	xml += ' <Delivery>'

	xml += ' <Storage storeOnServer="' + @storeOnServer.to_s + '">'

	if (@store_location and @store_location.length > 0)
		xml += ' <location>' + @store_location.to_s + '</location>'
	end

	xml += ' </Storage>'


	xml += ' </Delivery>'

	xml += ' </ReportConfig>'

	return xml
end

#saveReportObject

Description

Save the report definition to the NSC. Returns the config-id.



2114
2115
2116
2117
2118
2119
2120
2121
# File 'lib/nexpose.rb', line 2114

def saveReport()
	r = @connection.execute('<ReportSaveRequest session-id="' + @connection.session_id.to_s + '">' + getXML().to_s + ' </ReportSaveRequest>')
	if(r.success)
		@config_id = r.attributes['reportcfg-id']
		return true
	end
	return false
end

#set_email_As(email_As) ⇒ Object



2192
2193
2194
# File 'lib/nexpose.rb', line 2192

def set_email_As(email_As)
	@email_As = email_As
end

#set_format(format) ⇒ Object



2188
2189
2190
# File 'lib/nexpose.rb', line 2188

def set_format(format)
	@format = format
end

#set_generate_after_scan(generate_after_scan) ⇒ Object



2208
2209
2210
# File 'lib/nexpose.rb', line 2208

def set_generate_after_scan(generate_after_scan)
	@generate_after_scan = generate_after_scan
end

#set_name(name) ⇒ Object



2180
2181
2182
# File 'lib/nexpose.rb', line 2180

def set_name(name)
	@name = name
end

#set_sender(sender) ⇒ Object



2204
2205
2206
# File 'lib/nexpose.rb', line 2204

def set_sender(sender)
	@sender = sender
end

#set_smtp_relay_server(smtp_relay_server) ⇒ Object



2200
2201
2202
# File 'lib/nexpose.rb', line 2200

def set_smtp_relay_server(smtp_relay_server)
	@smtp_relay_server = smtp_relay_server
end

#set_storeOnServer(storeOnServer) ⇒ Object



2196
2197
2198
# File 'lib/nexpose.rb', line 2196

def set_storeOnServer(storeOnServer)
	@storeOnServer = storeOnServer
end

#set_template_id(template_id) ⇒ Object



2184
2185
2186
# File 'lib/nexpose.rb', line 2184

def set_template_id(template_id)
	@template_id = template_id
end

#setSchedule(schedule) ⇒ Object

Description

Sets the schedule for this report config



2138
2139
2140
# File 'lib/nexpose.rb', line 2138

def setSchedule(schedule)
	@schedule = schedule
end