mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-05 22:17:20 +02:00
redact credentials within hooks
go-retryablehttp does not redact credentials, so we still log them when we use it https://github.com/hashicorp/go-retryablehttp/pull/133
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -566,3 +567,12 @@ func ParseAllowedIPAndRanges(allowed []string) ([]func(net.IP) bool, error) {
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// GetRedactedURL returns the url redacting the password if any
|
||||
func GetRedactedURL(rawurl string) string {
|
||||
u, err := url.Parse(rawurl)
|
||||
if err != nil {
|
||||
return rawurl
|
||||
}
|
||||
return u.Redacted()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user