IPNetwork

Gather information regarding CIDR - 1. Broadcast_address 2. CIDR 3. First_address 4. Last address 5. Max prefix len 6. Num addresses 7. Private 8. Version.

python · Common Scripts

Details

IDIPNetwork
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsip

README

Gather information regarding CIDR -
1. Broadcast_address
2. CIDR
3. First_address
4. Last address
5. Max prefix len
6. Num addresses
7. Private
8. Version

Script Data


Name Description
Script Type python3
Tags ip
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
cidr IP/CIDR, e.g. 192.168.0.0/24

Outputs


Path Description Type
Network.CIDR Network CIDR. String
Network.Num_addresses Number of availble addresses in the CIDR. Number
Network.First_address First address in the network CIDR. String
Network.Last_address Last address in the network CIDR. String
Network.Version Version of IP. Number
Network.Private True if IP is private. Boolean
Network.Max_prefix_len Max prefix length of CIDR. Number
Network.Broadcast_address Broadcast address of CIDR. String
import json

import pytest


# About the drop some mean regex right now disable-secrets-detection-start
@pytest.mark.parametrize(
    argnames="cidr, expected_ec",
    argvalues=[("192.168.0.0/24", "ipv4_cidr.json"), ("2002::1234:abcd:ffff:c0a8:101/127", "ipv6_cidr.json")],
)
def test_ip_cidr(cidr: str, expected_ec: str, datadir):
    from IPNetwork import ip_cidr

    assert ip_cidr(cidr) == json.loads(datadir[expected_ec].read())


# Drops the mic disable-secrets-detection-end