Repository navigation
Conversation
Let logging integrations mark message bodies as already formatted while preserving their original arguments as structured log attributes. This prevents percent sequences from user input from being interpreted during a second formatting pass. Fixes #6715
Contributor
PR risk: mediumFor commit Main concerns: public contract, reach, data sent to Sentry. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
📲 Install BuildsAndroid
|
This branch has not been deployed
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.
📜 Description
Add a
messageAlreadyFormattedoption toSentryLogParameters. Logback, Log4j2, and JUL set it when forwarding messages they have already formatted, so the Sentry logger preserves the message body instead of applyingString.formatagain.Original message arguments are still passed through and recorded as structured
sentry.message.parameter.*attributes.💡 Motivation and Context
Logging integrations currently pass both the framework-formatted message and its original arguments to the Sentry Logs API. The API interprets the formatted message as a new Java format string, allowing percent sequences introduced by argument values to be processed during a second formatting pass. Large field widths can corrupt the message or exhaust the heap.
Resolves #6715
Refs JAVA-849
💚 How did you test it?
Added regression coverage for the core logger and the Logback, Log4j2, and JUL integrations using an argument containing
%2010B.Ran:
make format api./gradlew ':sentry:test' --tests='*ScopesTest*' ':sentry-logback:test' --tests='*SentryAppenderTest*' ':sentry-log4j2:test' ':sentry-jul:test' --tests='*SentryHandlerTest*'📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None.