AsimilyExtraAssetContextData

Script for extracting Asimily device attributes from incident context data.

python · Asimily Insight

Details

IDAsimilyExtraAssetContextData
Languagepython
From Version6.10.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsdynamic-section

README

The script will be used for extracting asset information from context data from incidents. If playbook is applied to call asimily-get-asset-details for incidents to retrieve asset details, fetched information will be saved in incident’s context data under Asimily->Asset.

Permissions


This automation runs using the default Limited User role, unless you explicitly change the permissions.
For more information, see the section about permissions here:
For Cortex XSOAR 6, see the https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/6.x/Cortex-XSOAR-Playbook-Design-Guide/Automations.
For Cortex XSOAR 8 Cloud, see the https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8/Cortex-XSOAR-Cloud-Documentation/Create-a-script.
For Cortex XSOAR 8 On-prem, see the https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8.7/Cortex-XSOAR-On-prem-Documentation/Create-a-script.

Script Data


Name Description
Script Type python
Tags dynamic-section

Inputs


There are no inputs for this script.

Outputs


Returns formatted markdown table as CommandResults listing attributes fetched from context data under Asimily->Asset. of incident.

import pytest


@pytest.fixture(autouse=True)
def patch_missing_modules(mocker):
    # This must happen before any import that relies on CommonServerPython
    mocker.patch.dict("sys.modules", {"DemistoClassApiModule": mocker.MagicMock()})


@pytest.fixture
def mock_context_data():
    return {
        "AsimilyInsight": {
            "Asset": {
                "asimilydeviceid": "12345",
                "asimilydevicemacaddress": "00:11:22:33:44:55",
                "asimilydeviceipv4address": "192.168.1.1",
            }
        }
    }


def test_main(mocker, mock_context_data):
    # Delay all imports that depend on CommonServerPython until after patch
    from CommonServerPython import CommandResults
    from AsimilyExtraAssetContextData import main

    mocker.patch("demistomock.context", return_value=mock_context_data)
    mock_return = mocker.patch("AsimilyExtraAssetContextData.return_results")
    mock_table = mocker.patch("AsimilyExtraAssetContextData.tableToMarkdown", return_value="Mocked Markdown Table")

    main()

    mock_table.assert_called_once()
    mock_return.assert_called_once()

    result = mock_return.call_args[0][0]
    assert isinstance(result, CommandResults)