Skip to content

Comments

Add OWASP A10:2025 exception handling composite recipe#817

Draft
dsgrieve wants to merge 1 commit intomainfrom
jkschneider/owasp-a10-exception-handling
Draft

Add OWASP A10:2025 exception handling composite recipe#817
dsgrieve wants to merge 1 commit intomainfrom
jkschneider/owasp-a10-exception-handling

Conversation

@dsgrieve
Copy link

@dsgrieve dsgrieve commented Feb 20, 2026

Summary

  • Add composite recipe org.openrewrite.staticanalysis.security.OwaspA10 bundling 12 recipes for OWASP Top 10 2025 A10 (Mishandling of Exceptional Conditions)
  • Add new RemovePrintStackTrace recipe that removes Throwable#printStackTrace() calls
  • 5 new tests for RemovePrintStackTrace

Problem

OWASP 2025 introduced A10 covering improper error handling, including empty catch blocks that swallow exceptions, overly broad exception types, sensitive info leaked via stack traces, and missing null checks. There was no composite recipe to address this category.

Solution

Created a declarative composite recipe that bundles existing exception-handling recipes (EmptyBlock, OnlyCatchDeclaredExceptions, CatchClauseOnlyRethrows, etc.) along with a new RemovePrintStackTrace recipe. The new recipe uses MethodMatcher("java.lang.Throwable printStackTrace(..)") to detect and remove all printStackTrace overloads.

Test plan

  • Existing tests pass

  • New tests added for RemovePrintStackTrace (basic removal, PrintStream overload, false positives, preserving other statements, no-op)

  • Full build passes including recipe CSV validation

  • Fixes moderneinc/customer-requests#1839

…tStackTrace

Add a new composite recipe org.openrewrite.staticanalysis.security.OwaspA10
that bundles existing exception-handling recipes addressing OWASP Top 10 2025
A10 (Mishandling of Exceptional Conditions). Also add a new RemovePrintStackTrace
recipe that removes Throwable#printStackTrace() calls which can expose sensitive
information.

The composite recipe includes coverage for:
- Empty catch blocks (EmptyBlock, RenameExceptionInEmptyCatch, CatchClauseOnlyRethrows)
- Overly broad exception types (OnlyCatchDeclaredExceptions, UnnecessaryCatch, CombineSemanticallyEqualCatchBlocks)
- Sensitive info in error output (RemoveSystemOutPrintln, RemovePrintStackTrace)
- Null safety (EqualsAvoidsNull, AnnotateNullableMethods, AnnotateNullableParameters)
- Resource leak prevention (BufferedWriterCreationRecipes)

Fixes moderneinc/customer-requests#1839
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Feb 20, 2026
@dsgrieve dsgrieve marked this pull request as draft February 20, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant