Exports¶
The following methods allow for interaction into the Tenable Vulnerability Management exports API endpoints.
Methods available on tio.exports
:
As exports are asynchronous, pyTenable by default will return an iterator to handle the state tracking, data chunking, and presentation of the data in order to reduce the amount of boilerplate code that would otherwise have to be created. These iterators support both serial iteration and threaded handling of data depending on how the data is accessed.
- class ExportsIterator(api, **kwargs)[source]¶
The export iterator can be used to handle the downloading and processing of the data chunks from an export request.
- run_threaded(func: Any, kwargs: Optional[Dict] = None, num_threads: int = 2) List [source]¶
Initiate a multi-threaded export using the provided function and keyword arguments. The following field names are reserved and must be accepted either as an optional keyword argument, or as a named param.
data (list[dict]): Receiver of the data-chunk.
export_uuid (str): Receiver for the export job UUID.
export_type (str): Receiver for the export data-type.
export_chunk_id (int): Receiver for the export chunk id.
- Parameters
func – The function to pass to the thread executor.
kwargs – Any additional keyword arguments that are to be passed to the function as part of execution.
num_threads – How many concurrent threads should be run. The default is
2
.
Examples
A simple example to download the chunks and write them to disk.
>>> def write_chunk(data, ... export_uuid: str, ... export_type: str, ... export_chunk_id: int ... ): ... fn = f'{export_type}-{export_uuid}-{export_chunk_id}.json' ... with open(fn, 'w') as fobj: ... json.dump(data, fobj) >>> >>> export = tio.exports.vulns() >>> export.run_threaded(write_chunk, num_threads=4)