ImpSfRevokeUnaccessedDevices

Getting all devices data from server, if a device haven't been accessed to in over two months (and is still managed), the script will send the corresponding user a warning mail. If it's haven't been accessed to in over three months, the script will revoke the device credentials and notify the user by mail.

python · Imperva Skyfence

Details

IDImpSfRevokeUnaccessedDevices
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658
TagsImperva Skyfence

README

Gets all of a devices data from the server. If a device hasen’t been accessed in two months or more (and is still managed), the script will send the corresponding user a warning mail.
If the device hasn’t been accessed to in over three months, the script will revoke the device credentials and notify the user by mail.

Script Data


Name Description
Script Type python
Tags Imperva Skyfence

Dependencies


This script uses the following commands and scripts.

  • ImpSfSetEndpointStatus
  • ImpSfListEndpoints

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

import demistomock as demisto
from ImpSfRevokeUnaccessedDevices import main


def test_revoke_empty(mocker):
    empty_result = [{"Type": 1, "Contents": {}, "ContentsFormat": "json"}]
    mocker.patch.object(demisto, "executeCommand", return_value=empty_result)
    demisto_results_mocker = mocker.patch.object(demisto, "results")
    main()
    assert demisto_results_mocker.called
    assert demisto_results_mocker.call_args.args[0][0].get("ContentsFormat") == "markdown"
    assert demisto_results_mocker.call_count == 1


def test_revoke_3_months(mocker):
    old_user = [
        {
            "Type": 1,
            "Contents": [
                {
                    "last_updated": "1627765200000",
                    "accounts": '[{"account_id": "dummy"}]',
                    "endpoint_status": "managed",
                    "endpoint_id": "dummy",
                }
            ],
            "ContentsFormat": "json",
        }
    ]
    mocker.patch.object(demisto, "executeCommand", return_value=old_user)
    demisto_results_mocker = mocker.patch.object(demisto, "results")
    main()
    assert demisto_results_mocker.called
    assert demisto_results_mocker.call_args.args[0][0].get("ContentsFormat") == "markdown"
    assert demisto_results_mocker.call_count == 1