IPv4Blacklist
Transformer that returns a filtered list of IPv4 addresses, based on whether they do not match a comma-separated list of IPv4 ranges. Useful for filtering out internal IP address space.
python · Filters And Transformers
Source
import demistomock as demisto from CommonServerPython import * from netaddr import IPAddress, IPNetwork def main(): ip_addresses = argToList(demisto.args()["value"]) cidr_range_list = argToList(demisto.args()["cidr_ranges"]) excluded_addresses = [] for ip_address in ip_addresses: found = False ip = IPAddress(ip_address) for cidr_range in cidr_range_list: if ip in IPNetwork(cidr_range): found = True if not found: excluded_addresses.append(ip_address) if not excluded_addresses: demisto.results(None) else: demisto.results(excluded_addresses) if __name__ == "__builtin__" or __name__ == "builtins": main()
README
Transformer that returns a filtered list of IPv4 addresses, based on whether they do not match a comma-separated list of IPv4 ranges. Useful for filtering out internal IP address space.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer, entirelist |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| value | Array or comma-separated list of IPv4 addresses to filter. |
| cidr_ranges | Array or comma-separated list of IPv4 ranges, in CIDR notation, against which to match the IPv4 addresses. |
Outputs
There are no outputs for this script.