Remediate OWASP A10:2025 Mishandling of exceptional conditions
ProprietaryOWASP 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.
org. openrewrite. java. security. Owasp2025A10mod run . --recipe= org. openrewrite. java. security. Owasp2025A10Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Remove empty blocks
- Rename caught exceptions in empty catch blocks to
ignored - Catch clause should do more than just rethrow
- Replace
catch(Exception)with specific declared exceptions thrown in the try block - Remove catch for a checked exception if the try block does not throw that exception
- Combine semantically equal catch blocks
- Unnecessary throws
- Remove
System.out#printlnandSystem.err#printlnstatements - Mask credit card numbers
- Use logger instead of
printStackTrace() - Equals avoids null
- Annotate methods which may return
nullwith@Nullable - Annotate null-checked method parameters with
@Nullable - Avoid boxed boolean expressions
- Default comes last
- Fall through
- Modernize
BufferedWritercreation and prevent file descriptor leaks - Unnecessary close in try-with-resources