From 0b1fbc4b39bc2aa35cac7e142c025f055afdf5be Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 30 Aug 2017 18:23:23 -0400 Subject: [PATCH] Exclude possibly sensitive data from logs Header fields and data frames can potentially contain sensitive data. This change omits these from Debug output which reduces the chance that this ends up in logs. --- src/frame/data.rs | 1 + src/frame/headers.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/frame/data.rs b/src/frame/data.rs index 7d3ea80..d52d598 100644 --- a/src/frame/data.rs +++ b/src/frame/data.rs @@ -119,6 +119,7 @@ impl fmt::Debug for Data { .field("stream_id", &self.stream_id) .field("flags", &self.flags) .field("pad_len", &self.pad_len) + // `data` purposefully excluded .finish() } } diff --git a/src/frame/headers.rs b/src/frame/headers.rs index 53e86f4..6211a83 100644 --- a/src/frame/headers.rs +++ b/src/frame/headers.rs @@ -16,7 +16,6 @@ use std::io::Cursor; /// Header frame /// /// This could be either a request or a response. -#[derive(Debug)] pub struct Headers { /// The ID of the stream with which this frame is associated. stream_id: StreamId, @@ -319,6 +318,17 @@ impl From for Frame { } } +impl fmt::Debug for Headers { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Headers") + .field("stream_id", &self.stream_id) + .field("stream_dep", &self.stream_dep) + .field("flags", &self.flags) + // `fields` and `pseudo` purposefully not included + .finish() + } +} + // ===== impl PushPromise ===== impl PushPromise {