tenable_io.helpers package¶
Submodules¶
tenable_io.helpers.folder module¶
-
class
tenable_io.helpers.folder.
FolderHelper
(client)¶ Bases:
object
-
create
(name)¶ Create a new folder.
Parameters: name – The folder name. Returns: The instance of FolderRef for the newly created folder.
-
folders
(name_regex=None, name=None, type=None)¶ Retrieve folders.
Parameters: - name_regex – Regular expression to match folder name with, default to None.
- name – String to match folder name with, default to None.
- type – The type of folders, default to None. (ex. Folder.TYPE_CUSTOM)
Returns: A list of FolderRef instances of all matching folders.
-
id
(id)¶ Retrieve a folder by ID.
Parameters: id – The folder ID. Returns: An instance of FolderRef for the folder, None if folder is not found.
-
main_folder
()¶ Get the main folder.
Returns: An instance of FolderRef for the main folder.
-
trash_folder
()¶ Get the trash folder.
Returns: An instance of FolderRef for the trash folder.
-
-
class
tenable_io.helpers.folder.
FolderRef
(client, id)¶ Bases:
object
-
add
(scan=None, scan_id=None)¶ Add a scan to the folder.
Parameters: - scan – An instance of ScanRef for the scan, default to None.
- scan_id – The ID of the scan, default to None.
Returns: The same instance of FolderRef.
-
delete
()¶ zDelete the folder.
Returns: The same instance of FolderRef.
-
name
()¶ Get the folder name.
Returns: The folder name.
-
scans
()¶ Get scans in the folder.
Returns: A list of ScanRef for the scans in the folder.
-
stop_scans
()¶ Stop all the scans in the folder.
Returns: The same instance of FolderRef.
-
type
()¶ Get the folder type.
Returns: The folder type.
-
tenable_io.helpers.policy module¶
-
class
tenable_io.helpers.policy.
PolicyHelper
(client)¶ Bases:
object
-
create
(name, template)¶ Create a policy.
Parameters: - name – The name of the policy.
- template – The name or title of the template, or an instance of Template.
Returns: PolicyRef referenced by id if exists.
-
import_policy
(path)¶ Upload and import the policy file.
Parameters: path – Path of the policy file. Returns: PolicyRef referenced by id if exists.
-
template
(name=None, title=None)¶ Get template by name or title. The ‘title’ argument is ignored if ‘name is passed.
Parameters: - name – The name of the template.
- title – The title of the template.
Returns: An instance of Template if exists, otherwise None.
-
-
class
tenable_io.helpers.policy.
PolicyRef
(client, id)¶ Bases:
object
-
copy
()¶ Create a copy of the policy.
Returns: An instance of PolicyRef that references the newly copied policy.
-
delete
()¶ Delete the policy.
Returns: The same PolicyRef Instance.
-
details
()¶ Get the policy detail.
Returns: An instance of tenable_io.api.models.PolicyDetails
.
-
download
(path, file_open_mode='wb')¶ Download a policy file.
Parameters: - path – The file path to save the file.
- file_open_mode – The open mode to the file output. Default to ‘wb’.
Returns: The same PolicyRef instance.
-
name
()¶ Get the name of the policy.
Returns: The name.
-
tenable_io.helpers.scan module¶
-
class
tenable_io.helpers.scan.
ScanActivity
(client=None, history_id=None, history_uuid=None, scan_id=None, schedule_uuid=None, timestamp=None)¶ Bases:
object
-
details
()¶
-
scan
()¶
-
-
class
tenable_io.helpers.scan.
ScanHelper
(client)¶ Bases:
object
-
STATUSES_STOPPED
= [u'aborted', u'canceled', u'completed', u'imported', u'empty']¶
-
activities
(targets=None, fqdns=None, ipv4s=None, mac_addresses=None, netbios_names=None, tenable_uuids=None, date_range=7)¶ Get scan activities against a list of targets. Note: For uncompleted scans, only the targets configured for the scan are matched against on the SDK-side. Completed scans are queried and matched on the API server-side.
Parameters: - targets – A single string target or a list of string targets in IPv4 or FQDN format.
- fqdns – A list of string values in FQDN format.
- ipv4s – A list of string values in IPv4 format.
- mac_addresses – A list of string values in MAC address format.
- netbios_names – A list of netbios_name’s.
- tenable_uuids – A list of tenable_uuid’s.
- date_range – The number of days of data prior to and including today that should be considered.
return: ScanActivity list sort by timestamp; active ScanActivity’s are ordered first with None timestamp.
-
create
(name, text_targets, template)¶ Get scan by ID.
Parameters: - name – The name of the Scan to be created.
- text_targets – A string of comma separated targets or a list of targets.
- template – The name or title of the template, or an instance of Template.
Returns: ScanRef referenced by id if exists.
-
id
(id)¶ Get scan by ID.
Parameters: id – Scan ID. Returns: ScanRef referenced by id if exists.
-
import_scan
(path, include_aggregate=True)¶ Uploads and then imports scan report.
Parameters: - path – Path of the scan report.
- include_aggregate – Flag indicating whether import scan results should be shown on Workbenches.
Returns: ScanRef referenced by id if exists.
-
scans
(name_regex=None, name=None, folder_id=None)¶ Get scans.
Parameters: - name – A string to match scans with, default to None. Ignored if the name_regex argument is passed.
- name_regex – A regular expression to match scans’ names with, default to None.
- folder_id – Only scans in the folder identified by folder_id, default to None.
Returns: A list of ScanRef.
-
stop_all
(folder=None, folder_id=None)¶ Stop all scans.
Parameters: - folder – Instance of FolderRef. Stop all scan in the folder only. Default to None.
- folder_id – Stop all scan in the folder identified by folder_id only. Default to None.
Returns: The current instance of ScanHelper.
-
template
(name=None, title=None)¶ Get template by name or title. The title argument is ignored if name is passed.
Parameters: - name – The name of the template.
- title – The title of the template.
Returns: An instance of Template if exists, otherwise None.
-
-
class
tenable_io.helpers.scan.
ScanRef
(client, id)¶ Bases:
object
-
copy
()¶ Create a copy of the scan.
Returns: An instance of ScanRef that references the newly copied scan.
-
delete
(force_stop=False)¶ Delete the scan.
Returns: The same ScanRef instance.
-
details
(history_id=None)¶ Get the scan detail.
Returns: An instance of tenable_io.api.models.ScanDetails
.
-
download
(path, history_id=None, format=u'pdf', chapter=u'vuln_hosts_summary', file_open_mode='wb')¶ Download a scan report.
Parameters: - path – The file path to save the report to.
- format – The report format. Default to
tenable_io.api.scans.ScanExportRequest
.FORMAT_PDF. - chapter – The report contents. Default to
tenable_io.api.scans.ScanExportRequest
.CHAPTER_EXECUTIVE_SUMMARY. - file_open_mode – The open mode to the file output. Default to “wb”.
- history_id – A specific scan history ID, None for the most recent scan history. default to None.
Returns: The same ScanRef instance.
-
folder
(history_id=None)¶ Get the folder the scan is in.
Parameters: history_id – The scan history to get folder for, None for most recent. Default to None. Returns: An instance of FolderRef.
-
histories
(since=None)¶ Get scan histories.
Parameters: since – As instance of datetime. Default to None. If defined, only scan histories after this are returned. Returns: A list of tenable_io.api.models.ScanDetailsHistory
.
-
last_history
()¶ Get last (most recent) scan history if exists.
Returns: An instance of tenable_io.api.models.ScanDetailsHistory
if exists, otherwise None.
-
launch
(wait=True, alt_targets=None)¶ Launch the scan.
Parameters: - wait – If True, the method blocks until the scan’s status is not
tenable_io.api.models.Scan
.STATUS_PENDING. Default is False. - alt_targets – String of comma separated alternative targets or list of alternative target strings.
Returns: The same ScanRef instance.
- wait – If True, the method blocks until the scan’s status is not
-
move_to
(folder)¶ Move the scan to a folder.
Parameters: folder – An instance of FolderRef identifying the folder to move the scan to. Returns: The same ScanRef instance.
-
name
(history_id=None)¶ Get the name of the scan.
Parameters: history_id – The scan history to get name for, None for most recent. Default to None. Returns: The name.
-
pause
(wait=True)¶ Pause the scan.
Parameters: wait – If True, the method blocks until the scan’s status is not tenable_io.api.models.Scan
.STATUS_PAUSING. Default is False.Returns: The same ScanRef instance.
-
resume
(wait=True)¶ Resume the scan.
Parameters: wait – If True, the method blocks until the scan’s status is not tenable_io.api.models.Scan
.STATUS_RESUMING. Default is False.Returns: The same ScanRef instance.
-
status
(history_id=None, _context=None)¶ Get the scan’s status.
Parameters: history_id – The scan history to get status for, None for most recent. Default to None. Returns: The same ScanRef instance.
-
stop
(wait=True)¶ Stop the scan.
Parameters: wait – If True, the method blocks until the scan’s status is stopped. Default is False. Returns: The same ScanRef instance.
-
stopped
(history_id=None, _context=None)¶ Check if the scan is stopped.
Parameters: history_id – The scan history to check, None for most recent. Default to None. Returns: True if stopped, False otherwise.
-
trash
()¶ Move the scan into the trash folder.
Returns: The same ScanRef instance.
-
wait_or_cancel_after
(seconds)¶ Blocks until the scan is stopped, or cancel if it isn’t stopped within the specified seconds.
Parameters: seconds – The maximum amount of seconds the method should block before canceling the scan. Returns: The same ScanRef instance.
-
wait_until_stopped
(history_id=None)¶ Blocks until the scan is stopped.
Parameters: history_id – The scan history to wait for, None for most recent. Default to None. Returns: The same ScanRef instance.
-
tenable_io.helpers.workbench module¶
-
class
tenable_io.helpers.workbench.
Asset
(bios_uuid=None, host_fqdn=None, hostname=None, host_ip=None, host_uuid=None, host_start=None, host_end=None, local_checks_proto=None, mac_address=None, mcafee_epo_guid=None, netbios_name=None, operating_system=None, system_type=None)¶ Bases:
object
-
host_properties
(host_properties)¶
-
-
class
tenable_io.helpers.workbench.
AssetVulnerabilities
(name=None, asset=None, vulnerabilities=None)¶ Bases:
object
-
from_report
(report)¶
-
-
class
tenable_io.helpers.workbench.
Vulnerability
(plugin_family=None, severity=None, protocol=None, plugin_name=None, plugin_id=None, svc_name=None, port=None, bid=None, canvas_package=None, cve=None, cvss_base_score=None, cvss_temporal_score=None, cvss_temporal_vector=None, cvss_vector=None, cvss3_base_score=None, cvss3_temporal_score=None, cvss3_temporal_vector=None, cvss3_vector=None, d2_elliot_name=None, description=None, exploit_available=None, exploited_by_nessus=None, exploit_framework_canvas=None, exploit_framework_core=None, exploit_framework_exploithub=None, exploit_framework_metasploit=None, exploit_framework_d2_elliot=None, exploited_by_malware=None, first_found=None, has_patch=None, in_the_news=None, last_found=None, last_fixed=None, malware=None, metasploit_name=None, patch_publication_date=None, plugin_modification_date=None, plugin_publication_date=None, plugin_output=None, plugin_type=None, plugin_version=None, risk_factor=None, solution=None, synopsis=None, unsupported_by_vendor=None, vulnerability_state=None, vuln_publication_date=None, xref=None, see_also=None)¶ Bases:
object
-
from_report_item
(report_item)¶
-
-
class
tenable_io.helpers.workbench.
WorkbenchHelper
(client)¶ Bases:
object
-
DEFAULT_PAGE_SIZE
= 10¶
-
assets
(date_range=1, plugin_id=None, page_size=10)¶ Retrieve recorded assets.
Parameters: - date_range – The number of days of data prior to today to return, default to 1.
- plugin_id – If specified, returns only assets with vulnerabilities found by the plugin identified by plugin_id, default to None.
- page_size – The page size of the pages returns by the iterator, default to DEFAULT_PAGE_SIZE.
Raises: TenableIOApiException – When API error is encountered.
Returns: Iterator that yields pages of
AssetVulnerabilities
.
-
assets_api
(date_range=1, plugin_id=None)¶ Retrieve recorded assets.
Parameters: - date_range – The number of days of data prior to today to return, default to 1.
- plugin_id – If specified, returns only assets with vulnerabilities found by the plugin identified by plugin_id, default to None.
Raises: TenableIOApiException – When API error is encountered.
Returns: A list of
AssetVulnerabilities
.
-
assets_parse
(date_range=1, plugin_id=None, page_size=10)¶ Retrieve recorded assets from the workbench nessus report.
Parameters: - date_range – The number of days of data prior to today to return, default to 1.
- plugin_id – If specified, returns only assets with vulnerabilities found by the plugin identified by plugin_id, default to None.
- page_size – The page size of the pages returns by the iterator, default to DEFAULT_PAGE_SIZE.
Raises: TenableIOApiException – When API error is encountered.
Returns: Iterator that yields pages of
AssetVulnerabilities
.
-
export
(path, format=u'nessus', report=u'vulnerabilities', chapter=u'vuln_by_asset', file_open_mode='wb', **kwargs)¶ Download a workbench report.
Parameters: - format – The file format. Default to WorkbenchesApi.FORMAT_NESSUS.
- report – The type of workbench report. Default to WorkbenchesApi.REPORT_VULNERABILITIES.
- chapter – Chapter to include. Default to WorkbenchesApi.CHAPTER_VULN_BY_ASSET.
- file_open_mode – Chapter to include, WorkbenchesApi.CHAPTER_VULN_BY_ASSET.
- **kwargs –
Additional keyword arguments are the same as
tenable_io.api.workbenches.WorkbenchesApi.export_request
Returns: The same WorkbenchHelper instance.
-
vulnerabilities
(date_range=1, asset_id=None, page_size=10)¶ Retrieve recorded vulnerabilities from the workbench nessus report.
Parameters: - date_range – The number of days of data prior to today to return, default to 1.
- asset_id – If specified, returns only vulnerabilities for the asset identified by asset_id, default to None.
- page_size – The page size of the pages returns by the iterator, default to DEFAULT_PAGE_SIZE.
Raises: TenableIOApiException – When API error is encountered.
Returns: Iterator that yields pages of
Vulnerability
.
-
vulnerabilities_api
(date_range=1, asset_id=None)¶ Retrieve recorded vulnerabilities.
Parameters: - date_range – The number of days of data prior to today to return, default to 1.
- asset_id – If specified, returns only vulnerabilities for the asset identified by asset_id, default to None.
Raises: TenableIOApiException – When API error is encountered.
Returns: A list of
Vulnerability
.
-
vulnerabilities_parse
(date_range=1, asset_id=None, page_size=10)¶ Retrieve recorded vulnerabilities from the workbench nessus report.
Parameters: - date_range – The number of days of data prior to today to return, default to 1.
- asset_id – If specified, returns only vulnerabilities for the asset identified by asset_id, default to None.
- page_size – The page size of the pages returns by the iterator, default to DEFAULT_PAGE_SIZE.
Raises: TenableIOApiException – When API error is encountered.
Returns: Iterator that yields pages of
Vulnerability
.
-