Skip to content

Commit 2eaad6d

Browse files
authored
Redact Git clone token (#121)
1 parent 628292f commit 2eaad6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

providers/gitops/gitops.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package gitops
33
import (
44
"bytes"
55
"context"
6+
"errors"
67
"fmt"
7-
"github.com/rs/zerolog/log"
88
"os"
99
"os/exec"
1010
"strconv"
1111
"strings"
1212
"time"
13+
14+
"github.com/rs/zerolog/log"
1315
)
1416

1517
type GitCloneError struct {
@@ -76,6 +78,10 @@ func (g *GitClient) Clone(ctx context.Context, clonePath string, url string, tok
7678

7779
for _, c := range commands {
7880
if _, err := g.Command.Run(ctx, c.cmd, c.args, clonePath); err != nil {
81+
if strings.Contains(err.Error(), token) {
82+
return errors.New(strings.ReplaceAll(err.Error(), token, "REDACTED"))
83+
}
84+
7985
return err
8086
}
8187
}

0 commit comments

Comments
 (0)