FormatURL

Strips, unquotes and unescapes URLs. If the URL is a Proofpoint or ATP URL, extracts its redirect URL. If more than one URL is passed to the formatter, the separator must be a pipe ("|").

python · Common Scripts

Source

import demistomock as demisto
from CommonServerPython import *
from FormatURLApiModule import *  # noqa: E402


def main():
    raw_urls = argToList(demisto.args().get("input"), separator="|")
    try:
        formatted_urls = format_urls(raw_urls)
        output = [
            {
                "Type": entryTypes["note"],
                "ContentsFormat": formats["json"],
                "Contents": [urls],
                "EntryContext": {"URL": urls},
            }
            for urls in formatted_urls
        ]

        for url in output:
            demisto.results(url)

    except Exception as e:
        return_error(f"Failed to execute the automation. Error: \n{e!s}")


if __name__ in ("__main__", "__builtin__", "builtins"):  # pragma: no-cover
    main()

README

Strips, unquotes and unescapes URLs. If the URL is a Proofpoint or ATP URL, extracts its redirect URL.
If more than one URL is passed to the formatter, the separator must be a pipe (“|”).

Script Data


Name Description
Script Type python3
Tags indicator-format
Cortex XSOAR Version 5.5.0

Inputs


Argument Name Description  
input A pipe (“ ”) separated list of URL inputs.

Outputs


Path Description Type
URL URL formatted. String

Script Example

!FormatURL input=https://urldefense.proofpoint.com/v2/url?u=https-3A__example.com_something.html

Context Example

{
    "URL": [
        "https://example.com/something.html"
    ]
}

Human Readable Output

https://example.com/something.html