history: add support for exporting multiple and all records

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-03-20 18:57:21 -07:00
parent 13ef01196d
commit 45dfb84361
5 changed files with 158 additions and 33 deletions

View File

@ -7,6 +7,7 @@ import (
"io"
"regexp"
"strings"
"sync"
"github.com/containerd/containerd/v2/core/content"
"github.com/docker/buildx/util/otelutil"
@ -17,15 +18,22 @@ import (
)
var (
sensitiveKeys = []string{"ghtoken", "token", "access_key_id", "secret_access_key", "session_token"}
reAttrs = regexp.MustCompile(`(?i)(` + strings.Join(sensitiveKeys, "|") + `)=[^ ,]+`)
reGhs = regexp.MustCompile(`ghs_[A-Za-z0-9]{36}`)
reOnce sync.Once
reAttrs, reGhs, reGhpat *regexp.Regexp
)
func sanitizeCommand(value string) string {
reOnce.Do(func() {
sensitiveKeys := []string{"ghtoken", "token", "access_key_id", "secret_access_key", "session_token"}
reAttrs = regexp.MustCompile(`(?i)(` + strings.Join(sensitiveKeys, "|") + `)=[^ ,]+`)
reGhs = regexp.MustCompile(`(?:ghu|ghs)_[A-Za-z0-9]{36}`)
reGhpat = regexp.MustCompile(`github_pat_\w{82}`)
})
value = reAttrs.ReplaceAllString(value, "${1}=xxxxx")
// reGhs is just double proofing. Not really needed.
// reGhs/reGhpat is just double proofing. Not really needed.
value = reGhs.ReplaceAllString(value, "xxxxx")
value = reGhpat.ReplaceAllString(value, "xxxxx")
return value
}