VerifyCIDR
Verify that the CIDRs are valid.
- Type
- python
- Pack
- CommonScripts
Source
import ipaddress
import demistomock as demisto
from CommonServerPython import *
""" STANDALONE FUNCTION """
def is_valid_cidr(cidr: str) -> bool:
try:
ipaddress.ip_network(cidr)
return True
except ValueError:
return False
""" MAIN FUNCTION """
def main():
try:
input_cidr = demisto.args().get("input")
input_cidr = argToList(input_cidr)
valid_cidr = []
for item in input_cidr:
if is_valid_cidr(item):
valid_cidr.append(item)
else:
valid_cidr.append("")
if valid_cidr:
return_results(valid_cidr)
else:
return_results("")
except Exception as e:
return_error(f"Failed to execute VerifyCIDR. Error: {e!s}")
""" ENTRY POINT """
if __name__ in ("__main__", "__builtin__", "builtins"):
main()
README
Verify that the CIDRs are valid.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | indicator-format |
| Cortex XSOAR Version | 6.5.0 |
Inputs
| Argument Name | Description |
|---|---|
| input | A comma-separated list of CIDR inputs. |
Outputs
There are no outputs for this script.
Script Examples
Example command
!VerifyCIDR input=190.0.0.0/1,200.200.200.200/29,300.0.0.0
Context Example
{}
Human Readable Output
200.200.200.200/29