Assets¶
The following methods allow for interaction into the Tenable Vulnerability Management assets API endpoints.
Methods available on tio.assets
:
- class AssetsAPI(api: APISession)[source]¶
This will contain all methods related to Assets
- asset_import(source, *assets)[source]¶
Imports asset information into Tenable Vulnerability Management from an external source.
Imports a list of asset definition dictionaries. Each asset record must contain at least one of the following attributes:
fqdn
,ipv4
,netbios_name
,mac_address
. Each record may also contain additional properties.- Parameters:
- Returns:
The job UUID.
- Return type:
Examples
import single asset:
>>> tio.assets.asset_import('example_source', { ... 'fqdn': ['example.py.test'], ... 'ipv4': ['192.168.254.1'], ... 'netbios_name': 'example', ... 'mac_address': ['00:00:00:00:00:00'] ... })
import multiple asset:
>>> tio.assets.asset_import('multiple_asset_example_source', ... { ... 'fqdn': ['example_one.py.test'], ... 'ipv4': ['192.168.1.1'], ... 'netbios_name': 'example_one', ... 'mac_address': ['00:00:00:00:00:00'] ... },{ ... 'fqdn': ['example_two.py.test'], ... 'ipv4': ['192.168.255.1'], ... 'netbios_name': 'example_two', ... 'mac_address': ['00:00:00:00:00:00'] ... })
- assign_tags(action, assets, tags)[source]¶
Add/remove tags for asset(s).
- Parameters:
- Returns:
The job Resource record.
- Return type:
Examples
>>> asset = tio.assets.assign_tags( ... 'add', ['00000000-0000-0000-0000-000000000000'], ... ['00000000-0000-0000-0000-000000000000'])
- bulk_delete(*filters, hard_delete=None, filter_type=None)[source]¶
Deletes the specified assets.
- Parameters:
*filters – A defined filter tuple consisting of the name, operator, and value. Example:
('host.hostname', 'match', 'asset.com')
.- Returns:
Returns the number of deleted assets.
- Return type:
Examples
>>> asset = tio.assets.bulk_delete( ... ('host.hostname', 'match', 'asset.com'), filter_type='or') >>> pprint(asset)
- delete(uuid)[source]¶
Deletes the asset.
Examples
>>> asset_id = '00000000-0000-0000-0000-000000000000' >>> tio.asset.delete(asset_id)
- details(uuid)[source]¶
Retrieves the details about a specific asset.
- Parameters:
uuid (str) – The UUID (unique identifier) for the asset.
- Returns:
Asset resource definition.
- Return type:
Examples
>>> asset = tio.assets.details( ... '00000000-0000-0000-0000-000000000000')
- import_job_details(uuid)[source]¶
Returns the details about a specific asset import job.
- uuid (str):
The UUID (unique identifier) for the job.
- Returns:
The job Resource record.
- Return type:
Examples
>>> job = tio.assets.import_job_details( ... '00000000-0000-0000-0000-000000000000') >>> pprint(job)
- list()[source]¶
Returns a list of assets.
- Returns:
List of asset records.
- Return type:
Examples
>>> for asset in tio.assets.list(): ... pprint(asset)
- list_import_jobs()[source]¶
Returns a list of asset import jobs.
- Returns:
List of job records.
- Return type:
Examples
>>> for job in tio.assets.list_import_jobs(): ... pprint(job)
- move_assets(source, destination, targets)[source]¶
Moves assets from the specified network to another network.
- source (str):
The UUID of the network currently associated with the assets.
- destination (str):
The UUID of the network to associate with the specified assets.
- targets (list):
The IPv4 addresses of the assets to move.
- Returns:
Returns the number of moved assets.
- Return type:
Examples
>>> asset = tio.assets.move_assets('00000000-0000-0000-0000-000000000000', ... '10000000-0000-0000-0000-000000000001', ["127.0.0.1"]) >>> pprint(asset)
- tags(uuid)[source]¶
Retrieves the details about a specific asset.
- Parameters:
uuid (str) – The UUID (unique identifier) for the asset.
- Returns:
Asset resource definition.
- Return type:
Examples
>>> asset = tio.assets.tags( ... '00000000-0000-0000-0000-000000000000')
- update_acr(assets_uuid_list, reason, value, note='')[source]¶
Updates ACR for the provided asset UUID’s with reason(s).
- Parameters:
- Returns:
Status code for the request.
- Return type:
Examples
>>> tio.assets.update_acr( ... ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001'], ... ['Other'], 1, 'some notes')