Module: Resource::Exports

Included in:
NessusClient
Defined in:
lib/modules/exports.rb

Overview

Namespace for Exports resource.

Instance Method Summary collapse

Instance Method Details

#export_download(scan_id, file_id) ⇒ JSON

Download exported scan.

Examples:

Download a ready export.

export = nc.export_download( '17', '46b78587')
open("scan_report", "wb") do |file|
  file.write( export )
end

Parameters:

  • scan_id (String)

    The identifier for the scan. This identifier can be the either the ‘schedule_uuid’ or the numeric ‘id’ attribute for the scan. We recommend that you use ‘schedule_uuid’.

  • file_id (String)

    The ID of the file to poll (Included in response from #export_request).

Returns:

  • (JSON)


34
35
36
# File 'lib/modules/exports.rb', line 34

def export_download(scan_id, file_id)
  request.get({ path: "/scans/#{scan_id}/export/#{file_id}/download", headers: headers })
end

#export_request(scan_id, format = 'nessus') ⇒ JSON

Export the given scan. Once requested, the file can be downloaded using the Resource::Tokens.token_download method upon receiving a “ready” status from the Resource::Tokens#token_status method. You can also use the older Resource::Exports#export_status and Resource::Exports#export_download methods.

Parameters:

  • scan_id (String)

    The export uuid string.

  • format (String) (defaults to: 'nessus')

    The file format to use (Nessus, HTML, PDF, CSV, or DB).

Returns:

  • (JSON)


9
10
11
12
# File 'lib/modules/exports.rb', line 9

def export_request(scan_id, format = 'nessus')
  payload = { format: format }
  request.post({ path: "/scans/#{scan_id}/export", payload: payload, headers: headers })
end

#export_status(scan_id, file_id) ⇒ JSON

Check the file status of an exported scan. When an export has been requested, it is necessary to poll this resource until a “ready” status is returned, at which point the file is complete and can be downloaded using the export download resource.

Examples:

Checking the status of a export.

export_status = nc.export_status( "15", "cd956" )
return true if export_status["status"] == "ready"

Parameters:

  • scan_id (String)

    The identifier for the scan. This identifier can be the either the ‘schedule_uuid’ or the numeric ‘id’ attribute for the scan. We recommend that you use ‘schedule_uuid’.

  • file_id (String)

    The ID of the file to poll (Included in response from #export_request).

Returns:

  • (JSON)


21
22
23
# File 'lib/modules/exports.rb', line 21

def export_status(scan_id, file_id)
  request.get({ path: "/scans/#{scan_id}/export/#{file_id}/status", headers: headers })
end