EmailDomainWhitelist
Accepts an array of domains as an allow list, and a list of email addresses. The script then filters out any email address whose domain is not in the allow list. The filtered list will be returned as an array.
python · Filters And Transformers
Details
| ID | EmailDomainWhitelist |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | transformer general entirelist |
README
Accepts an array of domains as an allow list, and a list of email addresses. The script then filters out any email address whose domain is not in the allow list. The filtered list will be returned as an array.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer, general, entirelist |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| value | An array of email addresses to be filtered by domain. |
| domain_list | An array of domains to allow list. |
Outputs
There are no outputs for this script.
import demistomock as demisto EMAIL_ADDRESSES = "test@test.com,filterme@nowhere.com,nobody@demistotest.com" EMAIL_ADDRESSES_LIST = ["test@test.com", "filterme@nowhere.com", "nobody@demistotest.com"] DOMAIN_LIST = "nowhere.com" def test_main(mocker): from EmailDomainWhitelist import main mocker.patch.object(demisto, "args", return_value={"value": EMAIL_ADDRESSES, "domain_list": DOMAIN_LIST}) mocker.patch.object(demisto, "results") main() assert demisto.results.call_count == 1 results = demisto.results.call_args[0][0] assert len(results) == 1 assert results[0] == "filterme@nowhere.com" # do it again, passing in a list this time mocker.patch.object(demisto, "args", return_value={"value": EMAIL_ADDRESSES_LIST, "domain_list": DOMAIN_LIST}) mocker.patch.object(demisto, "results") main() assert demisto.results.call_count == 1 results = demisto.results.call_args[0][0] assert len(results) == 1 assert results[0] == "filterme@nowhere.com" def test_csv_string_to_list(mocker): from EmailDomainWhitelist import csv_string_to_list results = csv_string_to_list(EMAIL_ADDRESSES) assert len(results) == 3 assert results[0] == "test@test.com" assert results[1] == "filterme@nowhere.com" assert results[2] == "nobody@demistotest.com" # do it again, passing in a list this time results = csv_string_to_list(EMAIL_ADDRESSES_LIST) assert len(results) == 3 assert results[0] == "test@test.com" assert results[1] == "filterme@nowhere.com" assert results[2] == "nobody@demistotest.com"