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.



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_idObject (readonly)

The ID for this report definition



2399
2400
2401
# File 'lib/nexpose.rb', line 2399

def config_id
  @config_id
end

#connectionObject (readonly)

The NSC Connection associated with this object



2397
2398
2399
# File 'lib/nexpose.rb', line 2397

def connection
  @connection
end

#csv_exportObject (readonly)

TODO



2438
2439
2440
# File 'lib/nexpose.rb', line 2438

def csv_export
  @csv_export
end

#db_exportObject (readonly)

TODO



2436
2437
2438
# File 'lib/nexpose.rb', line 2436

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)



2425
2426
2427
# File 'lib/nexpose.rb', line 2425

def email_As
  @email_As
end

#email_recipientsObject (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_allObject (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

#errorObject (readonly)

true if an error condition exists; false otherwise



2389
2390
2391
# File 'lib/nexpose.rb', line 2389

def error
  @error
end

#error_msgObject (readonly)

Error message string



2391
2392
2393
# File 'lib/nexpose.rb', line 2391

def error_msg
  @error_msg
end

#filtersObject (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

#formatObject (readonly)

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



2405
2406
2407
# File 'lib/nexpose.rb', line 2405

def format
  @format
end

#generate_after_scanObject (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

#nameObject (readonly)

A unique name for this report definition



2401
2402
2403
# File 'lib/nexpose.rb', line 2401

def name
  @name
end

#ownerObject (readonly)

XXX new



2409
2410
2411
# File 'lib/nexpose.rb', line 2409

def owner
  @owner
end

#request_xmlObject (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_xmlObject (readonly)

The last XML response received by this object



2395
2396
2397
# File 'lib/nexpose.rb', line 2395

def response_xml
  @response_xml
end

#scheduleObject (readonly)

Schedule to generate reports ReportSchedule Object



2417
2418
2419
# File 'lib/nexpose.rb', line 2417

def schedule
  @schedule
end

#senderObject (readonly)

Sets the FROM field of the Email



2434
2435
2436
# File 'lib/nexpose.rb', line 2434

def sender
  @sender
end

#smtp_relay_serverObject (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_locationObject (readonly)

Location to store the report on the server



2422
2423
2424
# File 'lib/nexpose.rb', line 2422

def store_location
  @store_location
end

#storeOnServerObject (readonly)

Store the reports on the server 1 or 0



2420
2421
2422
# File 'lib/nexpose.rb', line 2420

def storeOnServer
  @storeOnServer
end

#template_idObject (readonly)

The template ID used for this report definition



2403
2404
2405
# File 'lib/nexpose.rb', line 2403

def template_id
  @template_id
end

#timezoneObject (readonly)

XXX new



2407
2408
2409
# File 'lib/nexpose.rb', line 2407

def timezone
  @timezone
end

#xml_exportObject (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

#getXMLObject



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

#saveReportObject

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