Session

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

Methods available on tio.session:

class SessionAPI(api: APISession)[source]

Tenable Vulnerability Management session API is deprecated. it is recommended to use users endpoint instead

change_password(old_password, new_password)[source]

Change the password of the current user.

session: password

Parameters:
  • old_password (str) – The current password.

  • new_password (str) – The new password.

Returns:

The password has been successfully changed.

Return type:

None

Examples

>>> tio.session.change_password('old_pass', 'new_pass')
details()[source]

Retrieve the current users resource record.

session: get

Returns:

The user’s session resource record.

Return type:

dict

Examples

>>> user = tio.session.details()
>>> pprint(user)
edit(name, email)[source]

Modify the currently logged-in user.

session: edit

Parameters:
  • name (str) – The full name of the user.

  • email (str) – The email address of the user.

Returns:

The session data for the current user.

Return type:

dict

Examples

>>> tio.session.edit('John Doe', 'joe@company.com')
enable_two_factor(phone)[source]

Initiate the phone-based two-factor authorization verification process.

session: two-factor-enable

Parameters:

phone (str) – The phone number to use for two-factor auth.

Returns:

One-time activation code sent to the provided phone number.

Return type:

None

Examples

>>> tio.session.enable_two_factor('9998887766')
gen_api_keys()[source]

Generate new API keys for the current user.

session: keys

Returns:

A dictionary containing the new API Keypair.

Return type:

dict

Examples

>>> keys = tio.session.gen_api_keys()
restore()[source]

Restore the session to the logged-in user. This will remove any user impersonation setting that have been set.

session: restore

Returns:

The session has properly been restored to the original user.

Return type:

None

Example

>>> tio.session.restore()
two_factor(email, sms, phone=None)[source]

Configure two-factor authorization.

session: two-factor

Parameters:
  • email (bool) – Whether two-factor should be additionally sent as an email.

  • sms (bool) – Whether two-factor should be enabled. This will send SMS codes.

  • phone (str, optional) – The phone number to use for two-factor authentication. Required when sms is set to True.

Returns:

Setting changes were successfully updated.

Return type:

None

Example

Configure email multi-factor auth:

>>> tio.session.two_factor(True, False)

Configure SMS multi-factor auth:

>>> tio.session.two_factor(False, True, '9998887766')
verify_two_factor(code)[source]

Send the verification code for two-factor authorization.

session: verify-code

Parameters:

code (str) – The verification code that was sent to the device.

Returns:

The verification code was valid and two-factor is enabled.

Return type:

None

Examples

>>> tio.session.verify_two_factor('abc123')