Skip to content

Commit cfcbcac

Browse files
authored
fix: remove logging of credentials (#1534)
1 parent 4d661bf commit cfcbcac

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

pkg/registry/auth/auth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ func GetBearerHeader(challenge string, img string, registryAuth string) (string,
9191

9292
if registryAuth != "" {
9393
logrus.Debug("Credentials found.")
94-
logrus.Tracef("Credentials: %v", registryAuth)
94+
// CREDENTIAL: Uncomment to log registry credentials
95+
// logrus.Tracef("Credentials: %v", registryAuth)
9596
r.Header.Add("Authorization", fmt.Sprintf("Basic %s", registryAuth))
9697
} else {
9798
logrus.Debug("No credentials found.")

pkg/registry/digest/digest.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9+
"net"
10+
"net/http"
11+
"strings"
12+
"time"
13+
914
"github.com/containrrr/watchtower/internal/meta"
1015
"github.com/containrrr/watchtower/pkg/registry/auth"
1116
"github.com/containrrr/watchtower/pkg/registry/manifest"
1217
"github.com/containrrr/watchtower/pkg/types"
1318
"github.com/sirupsen/logrus"
14-
"net"
15-
"net/http"
16-
"strings"
17-
"time"
1819
)
1920

2021
// ContentDigestHeader is the key for the key-value pair containing the digest header
@@ -25,7 +26,7 @@ func CompareDigest(container types.Container, registryAuth string) (bool, error)
2526
if !container.HasImageInfo() {
2627
return false, errors.New("container image info missing")
2728
}
28-
29+
2930
var digest string
3031

3132
registryAuth = TransformAuth(registryAuth)
@@ -93,12 +94,13 @@ func GetDigest(url string, token string) (string, error) {
9394
req, _ := http.NewRequest("HEAD", url, nil)
9495
req.Header.Set("User-Agent", meta.UserAgent)
9596

96-
if token != "" {
97-
logrus.WithField("token", token).Trace("Setting request token")
98-
} else {
97+
if token == "" {
9998
return "", errors.New("could not fetch token")
10099
}
101100

101+
// CREDENTIAL: Uncomment to log the request token
102+
// logrus.WithField("token", token).Trace("Setting request token")
103+
102104
req.Header.Add("Authorization", token)
103105
req.Header.Add("Accept", "application/vnd.docker.distribution.manifest.v2+json")
104106
req.Header.Add("Accept", "application/vnd.docker.distribution.manifest.list.v2+json")

pkg/registry/registry.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ func GetPullOptions(imageName string) (types.ImagePullOptions, error) {
1919
if auth == "" {
2020
return types.ImagePullOptions{}, nil
2121
}
22-
log.Tracef("Got auth value: %s", auth)
22+
23+
// CREDENTIAL: Uncomment to log docker config auth
24+
// log.Tracef("Got auth value: %s", auth)
2325

2426
return types.ImagePullOptions{
2527
RegistryAuth: auth,

pkg/registry/trust.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func EncodedEnvAuth(ref string) (string, error) {
3838
Password: password,
3939
}
4040
log.Debugf("Loaded auth credentials for user %s on registry %s", auth.Username, ref)
41-
log.Tracef("Using auth password %s", auth.Password)
41+
// CREDENTIAL: Uncomment to log REPO_PASS environment variable
42+
// log.Tracef("Using auth password %s", auth.Password)
4243
return EncodeAuth(auth)
4344
}
4445
return "", errors.New("registry auth environment variables (REPO_USER, REPO_PASS) not set")
@@ -71,7 +72,8 @@ func EncodedConfigAuth(ref string) (string, error) {
7172
return "", nil
7273
}
7374
log.Debugf("Loaded auth credentials for user %s, on registry %s, from file %s", auth.Username, ref, configFile.Filename)
74-
log.Tracef("Using auth password %s", auth.Password)
75+
// CREDENTIAL: Uncomment to log docker config password
76+
// log.Tracef("Using auth password %s", auth.Password)
7577
return EncodeAuth(auth)
7678
}
7779

0 commit comments

Comments
 (0)