-
Notifications
You must be signed in to change notification settings - Fork 196
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
std::fmt::Display
implementation on error
shapes does not honor the sensitive
trait
#1743
Comments
During implementation of Logging in the Presence of Sensitive Data, I added https://github.com/awslabs/smithy-rs/blob/dcfb85578ef10e8d4fcb037c2fcf7d2a5e879f70/rust-runtime/aws-smithy-http-server/src/instrumentation/sensitivity/sensitive.rs. Reusing this machinery might be a good idea because:
This changes the proposed implementation very slightly: impl std::fmt::Debug for ErrorWithMessage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut formatter = f.debug_struct("ErrorWithMessage");
formatter.field("message", Sensitive(self.message));
formatter.finish()
}
} A similar argument can be made for going back and editing this implementation too #229. |
I think the current implementation would only make sense if the structure ErrorWithMessage {
@sensitive
message: String
} That way you could only worry about the field being sensitive in the context of the encompassing But if we have a plain type like: @sensitive
string SensitiveString That should be sensitive regardless of where it's used, but currently you could do: println!("{}", error_with_message.message/* or .unwrap() */) And have it logged. From what I can see, the only way to fix it would be to generate a |
Done in #1802. |
@jjant We should create a new issue with your findings in #1743 (comment) about whether we should wrap |
This model:
generates:
Note how the
Debug
implementation honors the sensitive trait, but theDisplay
implementation does not.The code that generates the
Debug
implementation is:https://github.com/awslabs/smithy-rs/blob/ffafbec885c1e83a460fed38fc98119bb63d0439/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/StructureGenerator.kt#L108-L127
The code that generates the
Display
implementation is:https://github.com/awslabs/smithy-rs/blob/ffafbec885c1e83a460fed38fc98119bb63d0439/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/TopLevelErrorGenerator.kt#L82-L93
The text was updated successfully, but these errors were encountered: