From 5e3a0d3740b07a7c13f4f4ed292711aa4c778baf Mon Sep 17 00:00:00 2001 From: jgheewala Date: Tue, 16 Nov 2021 13:47:00 -0500 Subject: [PATCH] sfxclient/httpsink: use hex encoded string representation for loggable headers if sha1 representation bytes is directly converted to string the output is garbage during logging. Instead use go built-in hex package EncodeToString() api --- sfxclient/httpsink.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sfxclient/httpsink.go b/sfxclient/httpsink.go index e05b840..85d8ed3 100644 --- a/sfxclient/httpsink.go +++ b/sfxclient/httpsink.go @@ -5,6 +5,7 @@ import ( "compress/gzip" "context" "crypto/sha1" + "encoding/hex" "encoding/json" "fmt" "io" @@ -160,7 +161,7 @@ func getShaValue(values []string) string { for _, v := range values { h.Write([]byte(v)) } - return string(h.Sum(nil)) + return hex.EncodeToString(h.Sum(nil)) } // loggableHeaders returns headers that are only allowed to be logged. For instance "X-Sf-Token" should not be logged so