From 4ae34f8dc33b5a7fdcae7110f46fef463bd4c497 Mon Sep 17 00:00:00 2001 From: 0PeterAdel <1peteradel@gmail.com> Date: Wed, 8 Jul 2026 12:15:54 +0300 Subject: [PATCH] security: mask code completion API keys in logs --- main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 97d60e0..fb7412d 100644 --- a/main.go +++ b/main.go @@ -551,8 +551,15 @@ func getRandomApiKey(paramStr string) string { rand.Seed(time.Now().UnixNano()) randomIndex := rand.Intn(len(params)) fmt.Println("Code completion API Key index:", randomIndex) - fmt.Println("Code completion API Key:", strings.TrimSpace(params[randomIndex])) - return strings.TrimSpace(params[randomIndex]) + key := strings.TrimSpace(params[randomIndex]) + maskedKey := key + if len(key) > 12 { + maskedKey = key[:4] + "..." + key[len(key)-4:] + } else if len(key) > 0 { + maskedKey = "******" + } + fmt.Println("Code completion API Key:", maskedKey) + return key } func ConstructRequestBody(body []byte, cfg *config) []byte {