Important

The Nessus Package is currently a Technology Preview

Policies

Methods described in this section relate to the files API. These methods can be accessed at Nessus.policies.

class PoliciesAPI(api: restfly.session.APISession)[source]
copy(policy_id: int) Dict[source]

Duplicates an existing scan policy.

Parameters

policy_id (int) – The id of the policy to clone.

Returns

The cloned policy object.

Return type

Dict

Example

>>> nessus.policies.copy(1)
create(uuid: str, **kwargs) Dict[source]

Creates a new scan policy using the provided settings.

Parameters
  • uuid (str) – The UUID for the editor template to use.

  • **kwargs (dict) – Additional settings to use to create the policy.

Returns

Response object with identifying information on the new policy

Return type

Dict

Example

>>> tmpl = '731a8e52-3ea6-a291-ec0a-d2ff0619c19d7bd788d6be818b65'
>>> nessus.policies.create(tmpl_uuid, settings={
...     'name': 'Sample Policy'
... })
delete(policy_id: int) None[source]

Deletes the specified scan policy.

Parameters

policy_id (int) – The id of the policy to delete.

Example

>>> nessus.policies.delete(1)
delete_many(policy_ids: List[int]) List[int][source]

Deletes the specified scan policies.

Parameters

policy_ids (list[int]) – The list of policy ids to delete.

Example

>>> nessus.policies.delete_many([1, 2, 3])
details(policy_id: int) Dict[source]

Returns the details of the selected policy.

Parameters

policy_id (int) – The id of the policy to retrieve.

Returns

The policy object.

Return type

Dict

Example

>>> nessus.policies.details(1)
edit(policy_id: int, **kwargs) None[source]

Updates an existing scan policy.

Parameters
  • policy_id (int) – The id of the policy to edit.

  • **kwargs (dict) – Attributes to be passed into the JSON body.

Example

>>> policy = nessus.policies.details(1)
>>> policy['settings']['name'] = 'Updated Policy'
>>> nessus.policies.edit(1, **policy)
export_policy(policy_id: int, fobj: Optional[_io.BytesIO] = None, **kwargs) _io.BytesIO[source]

Export the specified policy and download it.

Parameters
  • policy_id (int) – The id of the policy to export.

  • fobj (BytexIO, optional) – The file object to write the exported file to. If none is specified then a BytesIO object is written to in memory.

  • chunk_size (int, optional) – The chunk sizing for the download itself.

  • stream_hook (callable, optional) – Overload the default downloading behavior with a custom stream hook.

  • hook_kwargs (dict, optional) – keyword arguments to pass to the stream_hook callable in addition to the default passed params.

import_policy(fobj: _io.BytesIO) Dict[source]

Imports the policy into the nessus scanner.

Parameters

fobj (BytesIO) – The file object containing the policy.

Returns

The imported policy object.

Return type

Dict

Example

>>> with open('policy.xml', 'rb') as policy:
...     nessus.policies.import_policy(policy)
list() List[Dict][source]

Lists the available policies.

Returns

List of policy objects.

Return type

List[Dict]

Example

>>> for policy in nessus.policies.list():
...     print(policy)