From 7bad4cf64f5a95131584456ddddd62870c15e4a7 Mon Sep 17 00:00:00 2001 From: Daniel Beseda Date: Wed, 28 Apr 2021 11:59:36 +0000 Subject: [PATCH] Redact password in Stringer of packets.ConnectPacket --- packets/connect.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packets/connect.go b/packets/connect.go index 7284682..2184703 100644 --- a/packets/connect.go +++ b/packets/connect.go @@ -29,7 +29,11 @@ type ConnectPacket struct { } func (c *ConnectPacket) String() string { - return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, c.Password) + var password string + if len(c.Password) > 0 { + password = "" + } + return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, password) } func (c *ConnectPacket) Write(w io.Writer) error {