chore: bump app version to v0.5.2 and improve logging by masking sensitive information in API requests and responses
All checks were successful
Release / build-image (push) Successful in 1m51s

This commit is contained in:
Tommy 2025-03-15 19:21:00 +01:00
parent 67882bc3b6
commit ff26110cff
Signed by: tommy
SSH key fingerprint: SHA256:1LWgQT3QPHIT29plS8jjXc3S1FcE/4oGvsx3Efxs6Uc
3 changed files with 16 additions and 11 deletions

View file

@ -1 +1 @@
appVersion: v0.5.1
appVersion: v0.5.2

View file

@ -101,7 +101,18 @@ func (c *Client) Request(method string, endpoint string, reqBody []byte, v inter
}
if logLevel == "debug" {
log.Printf("Making request with headers: %v", req.Header)
// Make a copy of the headers to mask sensitive information
safeHeaders := make(http.Header)
for k, v := range req.Header {
safeHeaders[k] = v
}
// Remove sensitive headers entirely from logs
if _, exists := safeHeaders["Authorization"]; exists {
safeHeaders.Set("Authorization", "[REDACTED]")
}
log.Printf("Making request with headers: %v", safeHeaders)
}
resp, err := c.http.Do(req)
@ -124,11 +135,8 @@ func (c *Client) Request(method string, endpoint string, reqBody []byte, v inter
if logLevel == "debug" {
log.Printf("API response status: %s", resp.Status)
if len(respBody) > 0 {
shortBody := respBody
if len(shortBody) > 500 {
shortBody = shortBody[:500]
}
log.Printf("API response body (truncated): %s", string(shortBody))
// For security, don't log the API response content
log.Printf("Received API response (%d bytes)", len(respBody))
}
}

View file

@ -235,8 +235,5 @@ func main() {
// Helper function to mask secrets in logs
func maskSecret(secret string) string {
if len(secret) <= 4 {
return "****"
}
return secret[:2] + "****" + secret[len(secret)-2:]
return "[REDACTED]"
}