IsRFC1918Address

A filter that receives a single IPv4 address string as an input and determines whether it is in the private RFC-1918 address space (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). For more information, see https://en.wikipedia.org/wiki/Private_network

python · Filters And Transformers

Details

IDIsRFC1918Address
Languagepython
From Version5.0.0
Docker Imagedemisto/netutils:1.0.0.11867191
Tagsfilter

README

A filter that receives a single IPv4 address string as an input and determines whether it is in the private RFC-1918 address space (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). For more information, see https://en.wikipedia.org/wiki/Private_network

Script Data


Name Description
Script Type python3
Tags filter
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
value The IPv4 address to check.
left The IPv4 address to check (can be used instead of the value argument).

Outputs


There are no outputs for this script.

import demistomock as demisto


def test_main(mocker):
    from IsRFC1918Address import main

    mocker.patch.object(demisto, "args", return_value={"value": "172.16.0.1"})
    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args
    assert results[0][0] is True

    mocker.patch.object(demisto, "args", return_value={"value": "8.8.8.8"})
    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args
    assert results[0][0] is False

    mocker.patch.object(demisto, "args", return_value={"value": None, "left": "8.8.8.8"})
    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args
    assert results[0][0] is False