ConvertDomainToURLs
Converts Domain(s) to URL(s).
- Type
- python
- Pack
- GoogleChronicleBackstory
Source
import json
import traceback
from typing import Any
import demistomock as demisto
from CommonServerPython import *
def get_entry_context(domains, is_single) -> dict[str, Any]:
urls_to_return = []
if is_single:
if domains.startswith(("http://", "https://")): # NOSONAR
urls_to_return.append(domains)
else:
urls_to_return.append(f"http://{domains}") # NOSONAR
urls_to_return.append(f"https://{domains}")
else:
for domain in domains:
if domain.startswith(("http://", "https://")): # NOSONAR
urls_to_return.append(domain)
else:
urls_to_return.append(f"http://{domain}") # NOSONAR
urls_to_return.append(f"https://{domain}")
ec = {"DomainToURL": urls_to_return}
return ec
def main() -> None:
try:
domains = demisto.args().get("domains", [])
if domains[0] == "[" and domains[-1] == "]":
domains = json.loads(domains)
ec = get_entry_context(domains, False)
else:
ec = get_entry_context(domains, True)
demisto.results({"Type": entryTypes["note"], "EntryContext": ec, "Contents": {}, "ContentsFormat": formats["json"]})
except Exception as e:
demisto.error(traceback.format_exc())
return_error(f"Error occurred while extracting Domain(s):\n{e}")
# python2 uses __builtin__ python3 uses builtins
if __name__ == "__builtin__" or __name__ == "builtins":
main()
README
Converts Domain(s) to URL(s).
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| domains | List of Domain(s) to be converted to URL(s). |
Outputs
| Path | Description | Type |
|---|---|---|
| DomainToURL | Converted URLs | Unknown |
Script Example
!ConvertDomainToURLs domains=demo.com
Context Example
{
"DomainToURL": [
"http://demo.com",
"https://demo.com"
]
}
Human Readable Output
{}