IPv4Whitelist
Transformer that returns a filtered list of IPv4 addresses, based on whether they match a comma-separated list of IPv4 ranges. Useful for filtering in internal IP address space.
- Type
- python
- Pack
- FiltersAndTransformers
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"])
included_addresses = []
for ip_address in ip_addresses:
ip = IPAddress(ip_address)
for cidr_range in cidr_range_list:
if ip in IPNetwork(cidr_range):
included_addresses.append(ip_address)
if not included_addresses:
demisto.results(None)
else:
demisto.results(included_addresses)
if __name__ == "__builtin__" or __name__ == "builtins":
main()
README
Transformer that returns a filtered list of IPv4 addresses, based on whether they match a comma-separated list of IPv4 ranges. Useful for filtering in 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.