matchblackip()
The matchblackip() function checks whether a specific IP address is included in a specified address group.
Syntax
Parameters
STR_GUID- The GUID of the address group. Must be a valid address group identifier. If a non-existent GUID is specified, an error occurs at query parse time.
IP_ADDR_EXPR- The IP address expression. Only IPv4 address type or IPv4-formatted strings are accepted. If the value is of an unsupported type,
falseis returned.
Description
The matchblackip() function returns true if IP_ADDR_EXPR is included in the specified address group, or false if it is not.
If IP_ADDR_EXPR is null, false is returned. If the value is an IP address type, it is converted to a string before searching the address group. If the value is neither an IPv4 address nor an IPv4-formatted string, false is returned.
Address groups are managed in the Sonar web console under Policies > Address Groups.
Error codes
N/A
Usage examples
-
Check whether the value of the
src_ipfield is included in the specified address groupjson "{'src_ip': '192.0.2.1'}" | eval result = matchblackip("550e8400-e29b-41d4-a716-446655440000", src_ip) | # result: false -
IP_ADDR_EXPRvalue isnulljson "{'src_ip': null}" | eval result = matchblackip("550e8400-e29b-41d4-a716-446655440000", null) | # result: false -
IP_ADDR_EXPRvalue is a non-IPv4 typejson "{'src_ip': 12345}" | eval result = matchblackip("550e8400-e29b-41d4-a716-446655440000", src_ip) | # result: false
Compatibility
matchblackip() has been available since before Sonar 4.0.