GreaterCidrNumAddresses

Check if number of availble addresses in IPv4 or IPv6 CIDR is greater than given number.

python · Filters And Transformers

Details

IDGreaterCidrNumAddresses
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsfilter

README

Check if number of availble addresses in IPv4 or IPv6 CIDR is greater than given number.

Script Data


Name Description
Script Type python3
Tags filter
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
left IP/CIDR, e.g. 192.168.0.0/24
right The number of addresses to be greater from.

Outputs


There are no outputs for this script.

import demistomock as demisto
import pytest


# About the drop some mean regex right now disable-secrets-detection-start
@pytest.mark.parametrize(
    argnames="cidr, min_num_addresses, expected",
    argvalues=[("192.168.0.0/24", 257, False), ("192.168.0.0/24", 255, True), ("2002::1234:abcd:ffff:c0a8:101/127", 3, False)],
)
def test_cidr_network_addresses_greater_from_const(cidr: str, min_num_addresses: str, expected: bool):
    from GreaterCidrNumAddresses import cidr_network_addresses_greater_from_const

    assert cidr_network_addresses_greater_from_const(ip_cidr=cidr, min_num_addresses=min_num_addresses) == expected


# Drops the mic disable-secrets-detection-end


@pytest.mark.parametrize(argnames="expected", argvalues=[("192.168.0.0/24", 257, False)])
def test_main(mocker, expected):
    from GreaterCidrNumAddresses import main

    mocker = mocker.patch.object(demisto, "args", return_value={"left": "192.168.0.0/24,192.168.0.0/24", "right": 257})
    main()
    assert mocker.called == 1