Networks¶
The following methods allow for interaction into the Tenable Vulnerability Management networks API endpoints.
Methods available on tio.networks
:
- class NetworksAPI(api: restfly.session.APISession)[source]¶
This will contain all methods related to networks
- assign_scanners(network_id, *scanner_uuids)[source]¶
Assigns one or many scanners to a network.
networks: assign-scanner networks: bulk-assign-scanner
- Parameters
Examples
Assign a single scanner:
>>> tio.networks,assign_scanners( ... '00000000-0000-0000-0000-000000000000', # Network UUID ... '00000000-0000-0000-0000-000000000000') # Scanner UUID
Assign multiple scanners:
>>> tio.networks,assign_scanners( ... '00000000-0000-0000-0000-000000000000', # Network UUID ... '00000000-0000-0000-0000-000000000000', # Scanner1 UUID ... '00000000-0000-0000-0000-000000000000') # Scanner2 UUID
- create(name, description=None, assets_ttl_days=None)[source]¶
Creates a new network within Tenable Vulnerability Management
- Parameters
name (str) – The name of the new network.
description (str, optional) – Description of the network.
assets_ttl_days (int, optional) – The number of days to wait before assets age out.
days. (Assets will be permanently deleted if they are not seen on a scan within the specified number of) –
value (Maximum) – 90
value – 365
- Returns
The resource record of the newly created network.
- Return type
Examples
>>> nw = tio.networks.create('Example')
- delete(network_id)[source]¶
Deletes the specified network.
- Parameters
network_id (str) – The UUID of the network to remove.
Examples
>>> tio.networks.delete('00000000-0000-0000-0000-000000000000')
- details(network_id)[source]¶
Retrieves the details of the specified network.
- Parameters
network_id (str) – The UUID of the network.
Examples
>>> nw = tio.networks.details('00000000-0000-0000-0000-000000000000')
- edit(network_id, name, description=None, assets_ttl_days=None)[source]¶
Updates the specified network resource.
- Parameters
network_id (str) – The UUID of the network resource to update.
name (str) – The new name of the network resource.
description (str, optional) – The new description of the network resource.
assets_ttl_days (int, optional) – The number of days to wait before assets age out.
days. (Assets will be permanently deleted if they are not seen on a scan within the specified number of) –
value (Maximum) – 90
value – 365
- Returns
The updates network resource.
- Return type
Examples
>>> nw = tio.networks.edit('00000000-0000-0000-0000-000000000000', ... 'Updated Network', 'Updated Description', 180)
- list(*filters, **kw)[source]¶
Get the listing of configured networks from Tenable Vulnerability Management.
- Parameters
*filters (tuple, optional) –
Filters are tuples in the form of (‘NAME’, ‘OPERATOR’, ‘VALUE’). Multiple filters can be used and will filter down the data being returned from the API.
Examples
('name', 'eq', 'example')
As the filters may change and sortable fields may change over time, it’s highly recommended that you look at the output of the
tio.networks.network_filters()
endpoint to get more details.filter_type (str, optional) – The filter_type operator determines how the filters are combined together.
and
will inform the API that all of the filter conditions must be met for an access group to be returned, whereasor
would mean that if any of the conditions are met, the access group record will be returned.include_deleted (bool, optional) – Indicates whether deleted network objects should be included in the response. If left unspecified, the default is
False
.limit (int, optional) – The number of records to retrieve. Default is 50
offset (int, optional) – The starting record to retrieve. Default is 0.
sort (tuple, optional) – A tuple of tuples identifying the the field and sort order of the field.
wildcard (str, optional) – A string to pattern match against all available fields returned.
wildcard_fields (list, optional) – A list of fields to optionally restrict the wild-card matching to.
- Returns
An iterator that handles the page management of the requested records.
- Return type
NetworksIterator
Examples
Getting the listing of all agents:
>>> for nw in tio.networks.list(): ... pprint(nw)
Retrieving all of the windows agents:
>>> for nw in tio.access_groups.list(('name', 'match', 'win')): ... pprint(nw)
- list_scanners(network_id)[source]¶
Retrieves the list of scanners associated to a given network.
- Parameters
network_id (str) – The UUID of the network.
- Returns
List of scanner resources associated to this network.
- Return type
Examples
>>> network = '00000000-0000-0000-0000-000000000000' >>> for scanner in tio.networks.list_scanners(network): ... pprint(scanner)
- network_asset_count(network_id, num_days)[source]¶
get the total number of assets in the network along with the number of assets that have not been seen for the specified number of days.
- Parameters
- Returns
Returns the total number of assets in the network along with the number of assets that have not been seen for the specified number of days.
- Return type
Examples
>>> network = '00000000-0000-0000-0000-000000000000' >>> count = tio.networks.network_asset_count(network, 180)
- unassigned_scanners(network_id)[source]¶
Retrieves the list of scanners that are currently unassigned to the given network. This will include scanners and scanner groups that are currently assigned to the default network.
networks: list-assignable-scanners
- Parameters
id (str) – The UUID of the network.
- Returns
The list of unassigned scanner resources
- Return type
Examples
>>> network = '00000000-0000-0000-0000-000000000000' >>> for scanner in tio.networks.unassigned_scanners(network): ... pprint(scanner)