CompareLists

Compare two lists and put the differences in context.

Type
python
Pack
CommonScripts

Source

import demistomock as demisto
from CommonServerPython import *


def compare(left, right):
    return {
        "ListCompare": {
            "LeftOnly": [x for x in left if x not in right],
            "RightOnly": [x for x in right if x not in left],
            "Both": [x for x in left if x in right],
        }
    }


def main():
    left = argToList(demisto.args().get("left"))
    right = argToList(demisto.args().get("right"))

    out = compare(left, right)

    demisto.results(
        {
            "Type": entryTypes["note"],
            "ContentsFormat": formats["json"],
            "Contents": json.dumps(out),
            "HumanReadable": "Set comparisons in Context.",
            "EntryContext": out,
        }
    )


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()

README

Compare two lists and put the differences in context.

Script Data


Name Description
Script Type python3
Cortex XSOAR Version 5.0.0

Used In


This script is used in the following playbooks and scripts.

Inputs


Argument Name Description
left Left list
right Right list

Outputs


Path Description Type
ListCompare.LeftOnly Items only found within the list in the left argument Unknown
ListCompare.RightOnly Items only found within the list in the right argument Unknown
ListCompare.Both Common items that were found in both lists Unknown