Agent Exclusions

The following methods allow for interaction into the Tenable Vulnerability Management agent exclusions API endpoints.

Methods available on tio.agent_exclusions:

class AgentExclusionsAPI(api: APISession)[source]
create(name, scanner_id=1, start_time=None, end_time=None, timezone=None, description=None, frequency=None, interval=None, weekdays=None, day_of_month=None, enabled=True)[source]

Creates a new agent exclusion.

agent-exclusions: create

Parameters:
  • name (str) – The name of the exclusion to create.

  • scanner_id (int, optional) – The scanner id.

  • description (str, optional) – Some further detail about the exclusion.

  • start_time (datetime) – When the exclusion should start.

  • end_time (datetime) – When the exclusion should end.

  • timezone (str, optional) – The timezone to use for the exclusion. The default if none is specified is to use UTC. For the list of usable timezones, please refer to: https://cloud.tenable.com/api#/resources/scans/timezones

  • frequency (str, optional) – The frequency of the rule. The string inputted will be up-cased. Valid values are: ONETIME, DAILY, WEEKLY, MONTHLY, YEARLY. Default value is ONETIME.

  • interval (int, optional) – The interval of the rule. The default interval is 1

  • weekdays (list, optional) – List of 2-character representations of the days of the week to repeat the frequency rule on. Valid values are: SU, MO, TU, WE, TH, FR, SA Default values: ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']

  • day_of_month (int, optional) – The day of the month to repeat a MONTHLY frequency rule on. The default is today.

  • enabled (bool, optional) – enable/disable exclusion. The default is True

Returns:

Dictionary of the newly minted exclusion.

Return type:

dict

Examples

Creating a one-time exclusion:

>>> from datetime import datetime, timedelta
>>> exclusion = tio.agent_exclusions.create(
...     'Example One-Time Agent Exclusion',
...     ['127.0.0.1'],
...     start_time=datetime.utcnow(),
...     end_time=datetime.utcnow() + timedelta(hours=1))

Creating a daily exclusion:

>>> exclusion = tio.agent_exclusions.create(
...     'Example Daily Agent Exclusion',
...     ['127.0.0.1'],
...     frequency='daily',
...     start_time=datetime.utcnow(),
...     end_time=datetime.utcnow() + timedelta(hours=1))

Creating a weekly exclusion:

>>> exclusion = tio.agent_exclusions.create(
...     'Example Weekly Exclusion',
...     ['127.0.0.1'],
...     frequency='weekly',
...     weekdays=['mo', 'we', 'fr'],
...     start_time=datetime.utcnow(),
...     end_time=datetime.utcnow() + timedelta(hours=1))

Creating a monthly esxclusion:

>>> exclusion = tio.agent_exclusions.create(
...     'Example Monthly Agent Exclusion',
...     ['127.0.0.1'],
...     frequency='monthly',
...     day_of_month=1,
...     start_time=datetime.utcnow(),
...     end_time=datetime.utcnow() + timedelta(hours=1))

Creating a yearly exclusion:

>>> exclusion = tio.agent_exclusions.create(
...     'Example Yearly Agent Exclusion',
...     ['127.0.0.1'],
...     frequency='yearly',
...     start_time=datetime.utcnow(),
...     end_time=datetime.utcnow() + timedelta(hours=1))
delete(exclusion_id, scanner_id=1)[source]

Delete an agent exclusion.

agent-exclusions: delete

Parameters:
  • exclusion_id (int) – The id of the exclusion object in Tenable Vulnerability Management

  • scanner_id (int, optional) – The id of the scanner

Returns:

The Exclusion was successfully deleted

Return type:

None

Examples

>>> tio.agent_exclusions.delete(1)
details(exclusion_id, scanner_id=1)[source]

Retrieve the details for a specific agent exclusion.

agent-exclusion: details

Parameters:
  • exclusion_id (int) – The id of the exclusion object in Tenable Vulnerability Management

  • scanner_id (int, optional) – The id of the scanner

Returns:

The exclusion resource dictionary.

Return type:

dict

Examples

>>> exclusion = tio.agent_exclusions.details(1)
edit(exclusion_id, scanner_id=1, name=None, start_time=None, end_time=None, timezone=None, description=None, frequency=None, interval=None, weekdays=None, day_of_month=None, enabled=None)[source]

Edit an existing agent exclusion.

agent-exclusions: edit

The edit function will first gather the details of the exclusion that will be edited and will overlay the changes on top. The result will then be pushed back to the API to modify the exclusion.

Parameters:
  • exclusion_id (int) – The id of the exclusion object in Tenable Vulnerability Management

  • scanner_id (int, optional) – The scanner id.

  • name (str, optional) – The name of the exclusion to create.

  • description (str, optional) – Some further detail about the exclusion.

  • start_time (datetime, optional) – When the exclusion should start.

  • end_time (datetime, optional) – When the exclusion should end.

  • timezone (str, optional) – The timezone to use for the exclusion. The default if none is specified is to use UTC.

  • frequency (str, optional) – The frequency of the rule. The string inputted will be up-cased. Valid values are: ONETIME, DAILY, WEEKLY, MONTHLY, YEARLY.

  • interval (int, optional) – The interval of the rule.

  • weekdays (list, optional) – List of 2-character representations of the days of the week to repeat the frequency rule on. Valid values are: SU, MO, TU, WE, TH, FR, SA Default values: ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']

  • day_of_month (int, optional) – The day of the month to repeat a MONTHLY frequency rule on.

  • enabled (bool, optional) – enable/disable exclusion.

Returns:

Dictionary of the newly minted exclusion.

Return type:

dict

Examples

>>> exclusion = tio.agent_exclusions.edit(1, name='New Name')
list(scanner_id=1)[source]

Lists all of the currently configured agent exclusions.

agent-exclusions: list

Parameters:

scanner_id (int, optional) – The scanner identifier to be used.

Returns:

List of agent exclusions.

Return type:

list

Examples

>>> for exclusion in tio.agent_exclusions.list():
...     pprint(exclusion)