New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] AvoidUsingHardCodedIP ignores match pattern #1323

KroArtem opened this Issue Aug 30, 2018 · 3 comments


None yet
3 participants

KroArtem commented Aug 30, 2018

Affects PMD Version:
AvoidUsingHardCodedIP reports that string ":bee" is a hardcoded IP. It looks like support for IPv6 was added but documentation is outdated.

Code Sample demonstrating the issue:


Leads to PMD reporting the following:

Application with hard-coded IP addresses can become impossible to deploy in some cases.
Externalizing IP adresses is preferable.AvoidUsingHardCodedIP

Running PMD through: Junit test runs pmd

Docs say pattern is ^"[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"$


This comment has been minimized.


jsotuyod commented Aug 30, 2018

@KroArtem thanks for spotting this one!

That property is actually unused, and should be removed. It's legacy from back when the rule was a pure XPath rule:

<property name="pattern" type="String" description="Regular Expression" value='^"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"$'/>

The one property that is actually honoured is the checkAddressTypes as documented on

That property defaults to checking all, IPv4, IPv6 and IPv4 mapped IPv6.

@jsotuyod jsotuyod added this to the 6.7.0 milestone Aug 30, 2018

@jsotuyod jsotuyod changed the title from [java] AvoidUsingHardCodedIP reports unexpectedly to [java] AvoidUsingHardCodedIP ignores match pattern Aug 30, 2018

jsotuyod added a commit to Monits/pmd that referenced this issue Aug 30, 2018

jsotuyod added a commit to Monits/pmd that referenced this issue Aug 30, 2018

@jsotuyod jsotuyod added the has:pr label Aug 30, 2018


This comment has been minimized.


adangel commented Sep 1, 2018

":bee" is indeed a invalid ipv6 address, a valid one would be "::bee".

adangel added a commit to adangel/pmd that referenced this issue Sep 1, 2018

[java] AvoidUsingHardCodedIP false positive for ":bee"
"::bee" (two colons) is a valid IPv6 address, while ":bee"
is not.

Refs pmd#1323

@adangel adangel closed this in #1324 Sep 1, 2018


This comment has been minimized.

KroArtem commented Sep 3, 2018

Thanks a lot for explanation, updated pmd to 6.7.0, seems to be working ok now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment