Replace printStackTrace with manual stack trace construction in Utils#245
Draft
semgrep-code-traveltime-dev[bot] wants to merge 1 commit into
Draft
Replace printStackTrace with manual stack trace construction in Utils#245semgrep-code-traveltime-dev[bot] wants to merge 1 commit into
semgrep-code-traveltime-dev[bot] wants to merge 1 commit into
Conversation
Replace `printStackTrace()` with manual stack trace string construction to remove active debug code. ## Changes - Replaced `cause.printStackTrace(new PrintWriter(caw))` with manual iteration over `getStackTrace()` elements - Removed unused `CharArrayWriter` and `PrintWriter` imports - Added handling for exception cause chain to maintain full stack trace output ## Why The `printStackTrace()` method is flagged as active debug code because it's typically used for debugging purposes and can expose sensitive information in production environments. By manually constructing the stack trace string using `getStackTrace()`, we achieve the same functionality without using debug-oriented APIs. The new implementation iterates over `StackTraceElement` objects and properly handles chained exceptions. ## Semgrep Finding Details Possible active debug code detected. Deploying an application with debug code can create unintended entry points or expose sensitive information. Semgrep generated this pull request to fix [a finding](https://semgrep.dev/orgs/traveltime/findings/778279756) from the detection rule [java.lang.security.audit.active-debug-code-printstacktrace.active-debug-code-printstacktrace](https://semgrep.dev/r/java.lang.security.audit.active-debug-code-printstacktrace.active-debug-code-printstacktrace).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace
printStackTrace()with manual stack trace string construction to remove active debug code.Changes
cause.printStackTrace(new PrintWriter(caw))with manual iteration overgetStackTrace()elementsCharArrayWriterandPrintWriterimportsWhy
The
printStackTrace()method is flagged as active debug code because it's typically used for debugging purposes and can expose sensitive information in production environments. By manually constructing the stack trace string usinggetStackTrace(), we achieve the same functionality without using debug-oriented APIs. The new implementation iterates overStackTraceElementobjects and properly handles chained exceptions.Semgrep Finding Details
Possible active debug code detected. Deploying an application with debug code can create unintended entry points or expose sensitive information.
Semgrep generated this pull request to fix a finding from the detection rule java.lang.security.audit.active-debug-code-printstacktrace.active-debug-code-printstacktrace.