-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rust): Disallows Debug format derivation and Debug formatting in release code. #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stevenj
wants to merge
5
commits into
master
Choose a base branch
from
feat/disallow-debug-format
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Mr-Leshiy
previously approved these changes
Aug 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
rafal-ch
previously approved these changes
Aug 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
stanislav-tkach
previously approved these changes
Aug 5, 2025
…hk/catalyst-ci into feat/disallow-debug-format
706ca5e
saibatizoku
approved these changes
Aug 6, 2025
8 tasks
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
This change enforces that Debug formatting of structures can not be used in any release build.
This is achieved by using use_debug and also disallowd_macros
Why restrict this?
The purpose of the Debug trait is to facilitate debugging Rust code, and no guarantees are made about its output. It should not be used in user-facing output.
There is also a non zero risk of Debug formatted output leaking secrets or other information which can lead to vulnerabilities or security issues. They will also make any comprehensive security audit of the code difficult, if not impossible, as the output is uncontrolled.
This will also effect wrapping Errors by using
{e:?}
this is no longer permitted.If an error is to be wrapped, it should impl
Display
and we should control what it produces when formatted for printing.In preference complex structs should have a custom method attached (or
impl Display
) which allows the intended functional structure (without internal details) to be serialized to a json string. This allows this information to be properly embedded in logs, or later de-serialized and interpreted. This does not impose a requirement to allow all structs to have json de-serialization, and especially not serialization. It is suggested only where the structured contents of the structure are desirable for logging or reporting purposes.Debug printing is useful during development, and there is no requirement to strip these logs or formatted prints from the code, instead they need to be wrapped to prevent them build built in release mode, but making them available to developers when debugging.
Example:
Breaking Changes
Intentionally will break builds that use this in release builds.
Please confirm the following checks