Skip to content

IpAddressMatcher allows hostnames #17499

Open
@levry

Description

@levry

Describe the bug

The class IpAddressMatcher allows hostnames due to incorrect validation of IPv4 addresses. This happens because the regular expression used to validate IPv4 does not escape dots properly.

To Reproduce

new IpAddressMatcher("10x1x1x1");  // looking up '10x1x1x1'

var matcher = new IpAddressMatcher("10.33.1.0/24");
matcher.matches("www"); // looking up 'www'

Expected behavior

It is expected that IpAddressMatcher should only process literal IP addresses (v4 or v6) or subnet mask.

Sample

Here is a small repo reproducing the problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions