@@ -13,6 +13,8 @@ import (
1313 "github.com/hay-kot/hookfeed/backend/internal/data/dtos"
1414)
1515
16+ const redactedValue = "<redacted>"
17+
1618// GetHeader retrieves a header value, trying multiple possible keys
1719func GetHeader (r * http.Request , keys ... string ) string {
1820 for _ , key := range keys {
@@ -90,21 +92,21 @@ func sanitizeSecrets(key, value string) string {
9092 // Handle Bearer, Basic, and other auth schemes
9193 parts := strings .SplitN (value , " " , 2 )
9294 if len (parts ) == 2 {
93- return parts [0 ] + " <redacted>"
95+ return parts [0 ] + " " + redactedValue
9496 }
95- return "<redacted>"
97+ return redactedValue
9698
9799 case "cookie" , "set-cookie" :
98- return "<redacted>"
100+ return redactedValue
99101
100102 case "x-api-key" , "x-auth-token" , "api-key" , "apikey" :
101- return "<redacted>"
103+ return redactedValue
102104 }
103105
104106 // Redact query parameters that commonly contain secrets
105107 if keyLower == "token" || keyLower == "api_key" || keyLower == "apikey" ||
106108 keyLower == "secret" || keyLower == "password" || keyLower == "key" {
107- return "<redacted>"
109+ return redactedValue
108110 }
109111
110112 return value
@@ -181,7 +183,7 @@ func copyBody(r *http.Request) ([]byte, error) {
181183 if err != nil {
182184 return nil , fmt .Errorf ("failed to read request body: %w" , err )
183185 }
184- defer r .Body .Close ()
186+ _ = r .Body .Close ()
185187
186188 r .Body = io .NopCloser (bytes .NewReader (body ))
187189
@@ -205,19 +207,3 @@ func copyBody(r *http.Request) ([]byte, error) {
205207
206208 return json .Marshal (wrapped )
207209}
208-
209- // isEmptyJSON checks if the given JSON byte slice represents an empty value
210- // Returns true for: '{}', ”, 'null', '[]', or whitespace-only strings
211- func isEmptyJSON (data []byte ) bool {
212- // Trim whitespace
213- trimmed := bytes .TrimSpace (data )
214-
215- // Check for empty string
216- if len (trimmed ) == 0 {
217- return true
218- }
219-
220- // Check for common empty JSON representations
221- s := string (trimmed )
222- return s == "{}" || s == "null" || s == "[]"
223- }
0 commit comments