VectraXDRGenerateMailBody

Generate an email body based on the detection assessment for MDR escalation process.

python · Vectra XDR

Details

IDVectraXDRGenerateMailBody
Languagepython
From Version6.10.0
Docker Imagedemisto/python3:3.12.13.10116658

README

Generate an email body based on the detection assessment for MDR escalation process.

Script Data


Name Description
Script Type python3
Cortex XSOAR Version 6.10.0

Inputs


Argument Name Description
body_content Please provide the content needed to generate the email body.

Outputs


Path Description Type
VectraXDRMailBody Email body generated based on the detection assessment. string
import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401
from VectraXDRGenerateMailBody import main  # Import the main function from the script file
from VectraXDRGenerateMailBody import generate_mail_body


def test_generate_mail_body():
    """
    Given:
    - A list of detection assessment responses.

    When:
    - Calling the 'generate_mail_body' function with the provided list.

    Then:
    - Assert that the function returns a CommandResults object.
    """
    # Test with a list of detection assessment responses
    body_content = {
        "12345-test_detection_name_1": {
            "0": "True Positive",
            "1": "",
            "name": "admin",
        },
    }

    output_context = {
        "VectraXDRMailBody": "Hi,\nPlease find below the detection assessment response for Vectra MDR escalation process.\n\n "
        "1.Detection ID: 12345\n    Detection Name: test_detection_name_1\n    "
        "- Assessment Reason: True Positive\n\n"
    }

    result = generate_mail_body(body_content)
    result_context = result.to_context()
    assert result.outputs_prefix == "VectraXDRMailBody"
    assert result_context.get("HumanReadable") == output_context["VectraXDRMailBody"]
    assert result_context.get("EntryContext") == output_context


def test_main(mocker):
    """
    Given:
    - A list of detection assessment responses.

    When:
    - Calling the 'main' function with the provided args.
    """
    detection_assessment_content = '{"12345-test_detection_name_1":{"0":"True Positive","1":"","name":"admin"}}'
    args = {"body_content": detection_assessment_content}
    mocker.patch.object(demisto, "args", return_value=args)

    main()