Module: Nexpose

Defined in:
lib/nexpose.rb

Defined Under Namespace

Modules: NexposeAPI, Sanitize, XMLUtils Classes: APIError, APIRequest, AdminCredentials, AuthenticationFailed, Connection, Device, EngineActivity, EngineListing, EngineSummary, HostName, IPRange, Reference, ReportAdHoc, ReportConfig, ReportConfigSummary, ReportFilter, ReportHistory, ReportSchedule, ReportSection, ReportSummary, ReportTemplateListing, ReportTemplateSummary, ScanConfig, ScanFilter, ScanStatistics, ScanSummary, ScanTrigger, Schedule, Site, SiteConfig, SiteDeviceListing, SiteListing, SiteScanHistory, SiteSummary, SmtpAlert, SnmpAlert, SyslogAlert, VulnFilter, VulnerabilityDetail, VulnerabilityListing, VulnerabilitySummary

Class Method Summary collapse

Class Method Details

.get_iso_8601_date(int_date) ⇒ Object

Description

Returns an ISO 8601 formatted date/time stamp. All dates in NeXpose must use this format.



2853
2854
2855
2856
2857
# File 'lib/nexpose.rb', line 2853

def self.get_iso_8601_date(int_date)
#@date_mod = date('Ymd\THis000', @int_date)
	date_mod = ''
return date_mod
end

.getAttribute(attribute, xml) ⇒ Object

Description

TODO



2845
2846
2847
2848
2849
# File 'lib/nexpose.rb', line 2845

def self.getAttribute(attribute, xml)
	value = ''
	#@value = substr(substr(strstr(strstr(@xml,@attribute),'"'),1),0,strpos(substr(strstr(strstr(@xml,@attribute),'"'),1),'"'))
	return value
end

.printXML(object) ⇒ Object

Description

Echos the last XML API request and response for the specified object. (Useful for debugging)



2861
2862
2863
2864
# File 'lib/nexpose.rb', line 2861

def self.printXML(object)
	puts "request" + object.request_xml.to_s
	puts "response is " + object.response_xml.to_s
end

.site_device_scan(connection, site_id, device_array, host_array, debug = false) ⇒ Object

TODO add



2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
# File 'lib/nexpose.rb', line 2823

def self.site_device_scan(connection, site_id, device_array, host_array, debug = false)

	request_xml = '<SiteDevicesScanRequest session-id="' + connection.session_id.to_s + '" site-id="' + site_id.to_s + '">'
	request_xml += '<Devices>'
	device_array.each do |d|
		request_xml += '<device id="' + d.to_s + '"/>'
	end
	request_xml += '</Devices>'
	request_xml += '<Hosts>'
	# The host array can only by single IP addresses for now. TODO: Expand to full API Spec.
	host_array.each do |h|
		request_xml += '<range from="' + h.to_s + '"/>'
	end
	request_xml += '</Hosts>'
	request_xml += '</SiteDevicesScanRequest>'

	r = connection.execute(request_xml)
	r.success ? { :engine_id => r.attributes['engine_id'], :scan_id => r.attributes['scan-id'] } : nil
end