Class: Nexpose::ReportConfig
- Inherits:
-
Object
- Object
- Nexpose::ReportConfig
- Defined in:
- lib/nexpose.rb
Overview
Description
Object that represents the configuration of a report definition.
Instance Attribute Summary collapse
-
#config_id ⇒ Object
readonly
The ID for this report definition.
-
#connection ⇒ Object
readonly
The NSC Connection associated with this object.
-
#csv_export ⇒ Object
readonly
TODO.
-
#db_export ⇒ Object
readonly
TODO.
-
#email_As ⇒ Object
readonly
Form to send the report via email “file”, “zip”, “url”, or NULL (don’t send email).
-
#email_recipients ⇒ Object
readonly
Array containing the email addresses of the recipients.
-
#email_to_all ⇒ Object
readonly
Send the Email to all Authorized Users boolean - Send the Email to all Authorized Users.
-
#error ⇒ Object
readonly
true if an error condition exists; false otherwise.
-
#error_msg ⇒ Object
readonly
Error message string.
-
#filters ⇒ Object
readonly
Array of (ReportFilter)* - The Sites, Asset Groups, or Devices to run the report against.
-
#format ⇒ Object
readonly
html, db, txt, xml, raw-xml, csv, pdf.
-
#generate_after_scan ⇒ Object
readonly
Automatically generate a new report at the conclusion of a scan 1 or 0.
-
#name ⇒ Object
readonly
A unique name for this report definition.
-
#owner ⇒ Object
readonly
XXX new.
-
#request_xml ⇒ Object
readonly
The last XML request sent by this object.
-
#response_xml ⇒ Object
readonly
The last XML response received by this object.
-
#schedule ⇒ Object
readonly
Schedule to generate reports ReportSchedule Object.
-
#sender ⇒ Object
readonly
Sets the FROM field of the Email.
-
#smtp_relay_server ⇒ Object
readonly
IP Address or Hostname of SMTP Relay Server.
-
#store_location ⇒ Object
readonly
Location to store the report on the server.
-
#storeOnServer ⇒ Object
readonly
Store the reports on the server 1 or 0.
-
#template_id ⇒ Object
readonly
The template ID used for this report definition.
-
#timezone ⇒ Object
readonly
XXX new.
-
#xml_export ⇒ Object
readonly
TODO.
Instance Method Summary collapse
-
#addEmailRecipient(recipient) ⇒ Object
Description Adds a new email recipient.
-
#addFilter(filter_type, id) ⇒ Object
Description Adds a new filter to the report config.
-
#generateReport(debug = false) ⇒ Object
Description Generate a new report on this report definition.
- #getXML ⇒ Object
-
#initialize(connection, config_id = -1)) ⇒ ReportConfig
constructor
A new instance of ReportConfig.
-
#saveReport ⇒ Object
Description Save the report definition to the NSC.
- #set_email_As(email_As) ⇒ Object
- #set_format(format) ⇒ Object
- #set_generate_after_scan(generate_after_scan) ⇒ Object
- #set_name(name) ⇒ Object
- #set_sender(sender) ⇒ Object
- #set_smtp_relay_server(smtp_relay_server) ⇒ Object
- #set_storeOnServer(storeOnServer) ⇒ Object
- #set_template_id(template_id) ⇒ Object
-
#setSchedule(schedule) ⇒ Object
Description Sets the schedule for this report config.
Constructor Details
#initialize(connection, config_id = -1)) ⇒ ReportConfig
Returns a new instance of ReportConfig.
2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 |
# File 'lib/nexpose.rb', line 2443 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_id ⇒ Object (readonly)
The ID for this report definition
2399 2400 2401 |
# File 'lib/nexpose.rb', line 2399 def config_id @config_id end |
#connection ⇒ Object (readonly)
The NSC Connection associated with this object
2397 2398 2399 |
# File 'lib/nexpose.rb', line 2397 def connection @connection end |
#csv_export ⇒ Object (readonly)
TODO
2438 2439 2440 |
# File 'lib/nexpose.rb', line 2438 def csv_export @csv_export end |
#db_export ⇒ Object (readonly)
TODO
2436 2437 2438 |
# File 'lib/nexpose.rb', line 2436 def db_export @db_export end |
#email_As ⇒ Object (readonly)
Form to send the report via email “file”, “zip”, “url”, or NULL (don’t send email)
2425 2426 2427 |
# File 'lib/nexpose.rb', line 2425 def email_As @email_As end |
#email_recipients ⇒ Object (readonly)
Array containing the email addresses of the recipients
2430 2431 2432 |
# File 'lib/nexpose.rb', line 2430 def email_recipients @email_recipients end |
#email_to_all ⇒ Object (readonly)
Send the Email to all Authorized Users boolean - Send the Email to all Authorized Users
2428 2429 2430 |
# File 'lib/nexpose.rb', line 2428 def email_to_all @email_to_all end |
#error ⇒ Object (readonly)
true if an error condition exists; false otherwise
2389 2390 2391 |
# File 'lib/nexpose.rb', line 2389 def error @error end |
#error_msg ⇒ Object (readonly)
Error message string
2391 2392 2393 |
# File 'lib/nexpose.rb', line 2391 def error_msg @error_msg end |
#filters ⇒ Object (readonly)
Array of (ReportFilter)* - The Sites, Asset Groups, or Devices to run the report against
2411 2412 2413 |
# File 'lib/nexpose.rb', line 2411 def filters @filters end |
#format ⇒ Object (readonly)
html, db, txt, xml, raw-xml, csv, pdf
2405 2406 2407 |
# File 'lib/nexpose.rb', line 2405 def format @format end |
#generate_after_scan ⇒ Object (readonly)
Automatically generate a new report at the conclusion of a scan 1 or 0
2414 2415 2416 |
# File 'lib/nexpose.rb', line 2414 def generate_after_scan @generate_after_scan end |
#name ⇒ Object (readonly)
A unique name for this report definition
2401 2402 2403 |
# File 'lib/nexpose.rb', line 2401 def name @name end |
#owner ⇒ Object (readonly)
XXX new
2409 2410 2411 |
# File 'lib/nexpose.rb', line 2409 def owner @owner end |
#request_xml ⇒ Object (readonly)
The last XML request sent by this object
2393 2394 2395 |
# File 'lib/nexpose.rb', line 2393 def request_xml @request_xml end |
#response_xml ⇒ Object (readonly)
The last XML response received by this object
2395 2396 2397 |
# File 'lib/nexpose.rb', line 2395 def response_xml @response_xml end |
#schedule ⇒ Object (readonly)
Schedule to generate reports ReportSchedule Object
2417 2418 2419 |
# File 'lib/nexpose.rb', line 2417 def schedule @schedule end |
#sender ⇒ Object (readonly)
Sets the FROM field of the Email
2434 2435 2436 |
# File 'lib/nexpose.rb', line 2434 def sender @sender end |
#smtp_relay_server ⇒ Object (readonly)
IP Address or Hostname of SMTP Relay Server
2432 2433 2434 |
# File 'lib/nexpose.rb', line 2432 def smtp_relay_server @smtp_relay_server end |
#store_location ⇒ Object (readonly)
Location to store the report on the server
2422 2423 2424 |
# File 'lib/nexpose.rb', line 2422 def store_location @store_location end |
#storeOnServer ⇒ Object (readonly)
Store the reports on the server 1 or 0
2420 2421 2422 |
# File 'lib/nexpose.rb', line 2420 def storeOnServer @storeOnServer end |
#template_id ⇒ Object (readonly)
The template ID used for this report definition
2403 2404 2405 |
# File 'lib/nexpose.rb', line 2403 def template_id @template_id end |
#timezone ⇒ Object (readonly)
XXX new
2407 2408 2409 |
# File 'lib/nexpose.rb', line 2407 def timezone @timezone end |
#xml_export ⇒ Object (readonly)
TODO
2440 2441 2442 |
# File 'lib/nexpose.rb', line 2440 def xml_export @xml_export end |
Instance Method Details
#addEmailRecipient(recipient) ⇒ Object
Description
Adds a new email recipient
2496 2497 2498 |
# File 'lib/nexpose.rb', line 2496 def addEmailRecipient(recipient) @email_recipients.push(recipient) end |
#addFilter(filter_type, id) ⇒ Object
Description
Adds a new filter to the report config
2489 2490 2491 2492 |
# File 'lib/nexpose.rb', line 2489 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.
2471 2472 2473 |
# File 'lib/nexpose.rb', line 2471 def generateReport(debug = false) return generateReport(@connection, @config_id, debug) end |
#getXML ⇒ Object
2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 |
# File 'lib/nexpose.rb', line 2506 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 |
#saveReport ⇒ Object
Description
Save the report definition to the NSC. Returns the config-id.
2478 2479 2480 2481 2482 2483 2484 2485 |
# File 'lib/nexpose.rb', line 2478 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
2556 2557 2558 |
# File 'lib/nexpose.rb', line 2556 def set_email_As(email_As) @email_As = email_As end |
#set_format(format) ⇒ Object
2552 2553 2554 |
# File 'lib/nexpose.rb', line 2552 def set_format(format) @format = format end |
#set_generate_after_scan(generate_after_scan) ⇒ Object
2572 2573 2574 |
# File 'lib/nexpose.rb', line 2572 def set_generate_after_scan(generate_after_scan) @generate_after_scan = generate_after_scan end |
#set_name(name) ⇒ Object
2544 2545 2546 |
# File 'lib/nexpose.rb', line 2544 def set_name(name) @name = name end |
#set_sender(sender) ⇒ Object
2568 2569 2570 |
# File 'lib/nexpose.rb', line 2568 def set_sender(sender) @sender = sender end |
#set_smtp_relay_server(smtp_relay_server) ⇒ Object
2564 2565 2566 |
# File 'lib/nexpose.rb', line 2564 def set_smtp_relay_server(smtp_relay_server) @smtp_relay_server = smtp_relay_server end |
#set_storeOnServer(storeOnServer) ⇒ Object
2560 2561 2562 |
# File 'lib/nexpose.rb', line 2560 def set_storeOnServer(storeOnServer) @storeOnServer = storeOnServer end |
#set_template_id(template_id) ⇒ Object
2548 2549 2550 |
# File 'lib/nexpose.rb', line 2548 def set_template_id(template_id) @template_id = template_id end |
#setSchedule(schedule) ⇒ Object
Description
Sets the schedule for this report config
2502 2503 2504 |
# File 'lib/nexpose.rb', line 2502 def setSchedule(schedule) @schedule = schedule end |