Remediate OWASP A10:2025 Mishandling of exceptional conditions
Recipe ID
org.openrewrite.java.security.Owasp2025A10Artifactorg.openrewrite.recipe:rewrite-java-securityOWASP A10:2025 covers improper error handling: swallowed exceptions, overly broad catch/throws declarations, sensitive information leaked through error messages and stack traces, missing null checks, missing switch defaults, and omitted break statements. This is a new category in 2025.
Composite recipeCWE-478CWE-215CWE-248CWE-754CWE-755CWE-703CWE-209CWE-460CWE-396CWE-484CWE-550CWE-397CWE-476securityCWE-390CWE-391Proprietary
Add to your build
Get a download tokenThis recipe is Moderne licensed, so the token must belong to a Moderne customer. It replaces YOUR_DOWNLOAD_TOKEN below.
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.java.security.Owasp2025A10")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-java-security:3.42.0")
}
Then run
./gradlew rewriteRunUsage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.security.Owasp2025A10If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-java-security:RELEASEDefinition
This recipe runs the following recipes in order.
- Remove empty blocks
org.openrewrite.staticanalysis.EmptyBlock - Rename caught exceptions in empty catch blocks to
ignoredorg.openrewrite.staticanalysis.RenameExceptionInEmptyCatch - Catch clause should do more than just rethrow
org.openrewrite.staticanalysis.CatchClauseOnlyRethrows - Replace
catch(Exception)with specific declared exceptions thrown in the try blockorg.openrewrite.staticanalysis.OnlyCatchDeclaredExceptions - Remove catch for a checked exception if the try block does not throw that exception
org.openrewrite.staticanalysis.UnnecessaryCatch - Combine semantically equal catch blocks
org.openrewrite.staticanalysis.CombineSemanticallyEqualCatchBlocks - Unnecessary throws
org.openrewrite.staticanalysis.UnnecessaryThrows - Remove
System.out#printlnstatementsorg.openrewrite.staticanalysis.RemoveSystemOutPrintln - Mask credit card numbers
org.openrewrite.staticanalysis.MaskCreditCardNumbers - Use logger instead of
printStackTrace()org.openrewrite.java.logging.PrintStackTraceToLogError - Equals avoids null
org.openrewrite.staticanalysis.EqualsAvoidsNull - Annotate methods which may return
nullwith@Nullableorg.openrewrite.staticanalysis.AnnotateNullableMethods - Annotate null-checked method parameters with
@Nullableorg.openrewrite.staticanalysis.AnnotateNullableParameters - Avoid boxed boolean expressions
org.openrewrite.staticanalysis.AvoidBoxedBooleanExpressions - Default comes last
org.openrewrite.staticanalysis.DefaultComesLast - Fall through
org.openrewrite.staticanalysis.FallThrough - Modernize
BufferedWritercreation & prevent file descriptor leaksorg.openrewrite.staticanalysis.BufferedWriterCreationRecipes - Unnecessary close in try-with-resources
org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources
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