← All recipes
Moderne licensed

Remove hard-coded IP addresses from comments

Recipe IDorg.openrewrite.text.RemoveHardcodedIPAddressesFromComments
Artifactorg.openrewrite.recipe:rewrite-java-security

Removes hard-coded IPv4 addresses from comments when they match private IP ranges or loopback addresses. This targets IP addresses that are commented out in various comment formats: **Private IP ranges:** * 192.168.0.0 to 192.168.255.255 * 10.0.0.0 to 10.255.255.255 * 172.16.0.0 to 172.31.255.255 **Loopback IP range:** * 127.0.0.0 to 127.255.255.255 **Supported comment formats:** * C-style line comments (//) * C-style block comments (/* */) * Shell/Python style comments (#) * XML comments (<!-- -->) * YAML comments (#) * Properties file comments (# or !) For line comments, the entire line is removed. For block comments, only the IP address is removed.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.text.RemoveHardcodedIPAddressesFromComments

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-java-security:3.36.0

Options

NameTypeDescription
ipAddressReplacementStringIf specified, replaces hard-coded IP addresses with this value. Default is 'IP_ADDRESS_REPLACED'
e.g. IP_ADDRESS_REPLACED

Data tables

Structured output this recipe can produce.

  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats