GetEntries

Collect entries matching to the conditions in the war room.

python · Common Scripts

Source

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401


def main():
    try:
        args = demisto.args()

        params = assign_params(
            id=args.get("id"),
            filter=assign_params(
                tags=argToList(args.get("tags")),
                categories=argToList(args.get("categories")),
                pageSize=arg_to_number(args.get("page_size")),
                lastId=args.get("last_id"),
                firstID=args.get("first_id"),
                selectedEntryID=args.get("selected_entry_id"),
                users=argToList(args.get("users")),
                tagsAndOperator=argToBoolean(args.get("tags_and_operator", False)),
                fromTime=args.get("from_time"),
                parentID=args.get("parent_id"),
            ),
        )

        ents = demisto.executeCommand("getEntries", params)
        if not ents:
            return_results("No matching entries")
        else:
            ents = ents if isinstance(ents, list) else [ents]
            if is_error(ents) and not demisto.get(ents[0], "ID"):
                error_message = get_error(ents)
                raise DemistoException(f"Failed to execute getEntries. Error details:\n{error_message}")

            outputs = [
                assign_params(
                    ID=demisto.get(ent, "ID"),
                    Type=demisto.get(ent, "Type"),
                    Tags=demisto.get(ent, "Metadata.tags"),
                    Category=demisto.get(ent, "Metadata.category"),
                    Created=demisto.get(ent, "Metadata.created"),
                    Modified=demisto.get(ent, "Metadata.modified"),
                )
                for ent in ents
            ]
            return_results(
                CommandResults(
                    outputs_prefix="Entry", outputs=outputs, readable_output=f"Found {len(ents)} entries.", raw_response=ents
                )
            )
    except Exception as e:
        demisto.debug(traceback.format_exc())
        return_error(f"Failed to execute GetEntries.\nError:\n{type(e)}, {e!s}")


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

README

Collect entries matching to the conditions in the war room.

Script Data


Name Description
Script Type python3
Tags Utility
Cortex XSOAR Version 6.5.0

Inputs


Argument Name Description
id Optional incident ID to fetch entries from. If not specified, current incident is used.
tags The list of tags.
categories The list of categories. (commandAndResults, playbookTaskResult, playbookTaskStartAndDone, playbookErrors, justFound, deleted, incidentInfo, chats, evidence, notes, attachments).
page_size The number of entries to return. Maximum is 1000.
last_id Return entries starting from the specified entry ID and backward.
first_id Return entries starting from the specified entry ID and forward.
selected_entry_id Return entries before and after the specified entry ID.
users Return entries with the specified users.
tags_and_operator Whether to return entries that include all specified tags.
from_time Return entries from this time and forward. Format is ISO8601 (i.e., ‘2020-04-30T10:35:00.000Z’).
parent_id The ID of the parent entry.

Outputs


Path Description Type
Entry.ID Entry ID. Unknown
Entry.Type Entry Type. Unknown
Entry.Tags Tags associated with the entry. Unknown
Entry.Category Entry categories. Unknown
Entry.Created Creation time of the entry. Unknown
Entry.Modified Last modified time of the entry. Unknown