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
“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
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
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
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
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.
2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 |
# File 'lib/nexpose.rb', line 2572 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
2528 2529 2530 |
# File 'lib/nexpose.rb', line 2528 def config_id @config_id end |
#connection ⇒ Object (readonly)
The NSC Connection associated with this object
2526 2527 2528 |
# File 'lib/nexpose.rb', line 2526 def connection @connection end |
#csv_export ⇒ Object (readonly)
TODO
2567 2568 2569 |
# File 'lib/nexpose.rb', line 2567 def csv_export @csv_export end |
#db_export ⇒ Object (readonly)
TODO
2565 2566 2567 |
# File 'lib/nexpose.rb', line 2565 def db_export @db_export end |
#email_As ⇒ Object (readonly)
“file”, “zip”, “url”, or NULL (don’t send email)
2554 2555 2556 |
# File 'lib/nexpose.rb', line 2554 def email_As @email_As end |
#email_recipients ⇒ Object (readonly)
Array containing the email addresses of the recipients
2559 2560 2561 |
# File 'lib/nexpose.rb', line 2559 def email_recipients @email_recipients end |
#email_to_all ⇒ Object (readonly)
boolean - Send the Email to all Authorized Users
2557 2558 2559 |
# File 'lib/nexpose.rb', line 2557 def email_to_all @email_to_all end |
#error ⇒ Object (readonly)
true if an error condition exists; false otherwise
2518 2519 2520 |
# File 'lib/nexpose.rb', line 2518 def error @error end |
#error_msg ⇒ Object (readonly)
Error message string
2520 2521 2522 |
# File 'lib/nexpose.rb', line 2520 def error_msg @error_msg end |
#filters ⇒ Object (readonly)
Array of (ReportFilter)* - The Sites, Asset Groups, or Devices to run the report against
2540 2541 2542 |
# File 'lib/nexpose.rb', line 2540 def filters @filters end |
#format ⇒ Object (readonly)
html, db, txt, xml, raw-xml, csv, pdf
2534 2535 2536 |
# File 'lib/nexpose.rb', line 2534 def format @format end |
#generate_after_scan ⇒ Object (readonly)
1 or 0
2543 2544 2545 |
# File 'lib/nexpose.rb', line 2543 def generate_after_scan @generate_after_scan end |
#name ⇒ Object (readonly)
A unique name for this report definition
2530 2531 2532 |
# File 'lib/nexpose.rb', line 2530 def name @name end |
#owner ⇒ Object (readonly)
XXX new
2538 2539 2540 |
# File 'lib/nexpose.rb', line 2538 def owner @owner end |
#request_xml ⇒ Object (readonly)
The last XML request sent by this object
2522 2523 2524 |
# File 'lib/nexpose.rb', line 2522 def request_xml @request_xml end |
#response_xml ⇒ Object (readonly)
The last XML response received by this object
2524 2525 2526 |
# File 'lib/nexpose.rb', line 2524 def response_xml @response_xml end |
#schedule ⇒ Object (readonly)
ReportSchedule Object
2546 2547 2548 |
# File 'lib/nexpose.rb', line 2546 def schedule @schedule end |
#sender ⇒ Object (readonly)
Sets the FROM field of the Email
2563 2564 2565 |
# File 'lib/nexpose.rb', line 2563 def sender @sender end |
#smtp_relay_server ⇒ Object (readonly)
IP Address or Hostname of SMTP Relay Server
2561 2562 2563 |
# File 'lib/nexpose.rb', line 2561 def smtp_relay_server @smtp_relay_server end |
#store_location ⇒ Object (readonly)
Location to store the report on the server
2551 2552 2553 |
# File 'lib/nexpose.rb', line 2551 def store_location @store_location end |
#storeOnServer ⇒ Object (readonly)
1 or 0
2549 2550 2551 |
# File 'lib/nexpose.rb', line 2549 def storeOnServer @storeOnServer end |
#template_id ⇒ Object (readonly)
The template ID used for this report definition
2532 2533 2534 |
# File 'lib/nexpose.rb', line 2532 def template_id @template_id end |
#timezone ⇒ Object (readonly)
XXX new
2536 2537 2538 |
# File 'lib/nexpose.rb', line 2536 def timezone @timezone end |
#xml_export ⇒ Object (readonly)
TODO
2569 2570 2571 |
# File 'lib/nexpose.rb', line 2569 def xml_export @xml_export end |
Instance Method Details
#addEmailRecipient(recipient) ⇒ Object
Description
Adds a new email recipient
2625 2626 2627 |
# File 'lib/nexpose.rb', line 2625 def addEmailRecipient(recipient) @email_recipients.push(recipient) end |
#addFilter(filter_type, id) ⇒ Object
Description
Adds a new filter to the report config
2618 2619 2620 2621 |
# File 'lib/nexpose.rb', line 2618 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.
2600 2601 2602 |
# File 'lib/nexpose.rb', line 2600 def generateReport(debug = false) return generateReport(@connection, @config_id, debug) end |
#getXML ⇒ Object
2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 |
# File 'lib/nexpose.rb', line 2635 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.
2607 2608 2609 2610 2611 2612 2613 2614 |
# File 'lib/nexpose.rb', line 2607 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
2685 2686 2687 |
# File 'lib/nexpose.rb', line 2685 def set_email_As(email_As) @email_As = email_As end |
#set_format(format) ⇒ Object
2681 2682 2683 |
# File 'lib/nexpose.rb', line 2681 def set_format(format) @format = format end |
#set_generate_after_scan(generate_after_scan) ⇒ Object
2701 2702 2703 |
# File 'lib/nexpose.rb', line 2701 def set_generate_after_scan(generate_after_scan) @generate_after_scan = generate_after_scan end |
#set_name(name) ⇒ Object
2673 2674 2675 |
# File 'lib/nexpose.rb', line 2673 def set_name(name) @name = name end |
#set_sender(sender) ⇒ Object
2697 2698 2699 |
# File 'lib/nexpose.rb', line 2697 def set_sender(sender) @sender = sender end |
#set_smtp_relay_server(smtp_relay_server) ⇒ Object
2693 2694 2695 |
# File 'lib/nexpose.rb', line 2693 def set_smtp_relay_server(smtp_relay_server) @smtp_relay_server = smtp_relay_server end |
#set_storeOnServer(storeOnServer) ⇒ Object
2689 2690 2691 |
# File 'lib/nexpose.rb', line 2689 def set_storeOnServer(storeOnServer) @storeOnServer = storeOnServer end |
#set_template_id(template_id) ⇒ Object
2677 2678 2679 |
# File 'lib/nexpose.rb', line 2677 def set_template_id(template_id) @template_id = template_id end |
#setSchedule(schedule) ⇒ Object
Description
Sets the schedule for this report config
2631 2632 2633 |
# File 'lib/nexpose.rb', line 2631 def setSchedule(schedule) @schedule = schedule end |