From 575ba6dcb30797fbab3ba653e12886f222fcd94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 9 Aug 2026 11:00:24 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20/debug=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=20(=D1=83=D1=82=D0=B5=D1=87=D0=BA=D0=B0=20=D1=81=D0=B5=D0=BA?= =?UTF-8?q?=D1=80=D0=B5=D1=82=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY/code-review-results-v3.md | 25 ++++++++++++++++++ server/handlers.go | 43 ------------------------------- server/main.go | 1 - 3 files changed, 25 insertions(+), 44 deletions(-) create mode 100644 HISTORY/code-review-results-v3.md diff --git a/HISTORY/code-review-results-v3.md b/HISTORY/code-review-results-v3.md new file mode 100644 index 0000000..b590112 --- /dev/null +++ b/HISTORY/code-review-results-v3.md @@ -0,0 +1,25 @@ +# Code Review v3 — Результаты (Соннет, 2026-08-09) + +## 1. Структура — ✅ ОК +package main по файлам, ~400 строк — дробить рано. + +## 2. embed — ✅ ОК +Но `tmpl, _ := ReadFile` — ошибка игнорируется. + +## 3. proxyHandler — 🟡 мёртвый параметр +`?bucket=` в URL не читается proxyHandler — можно убрать из downloadLink. + +## 4. listVersions — 🟡 нет таймаута +`context.Background()` без дедлайна. + +## 5. defer в if — ✅ ОК +Корректно, defer привязан к функции. + +## 6. /debug — 🔴 КРИТИЧНО +Секреты S3 отдаются публично. Убрать. + +## 7. Dockerfile — ✅ ОК +Паттерн нормальный. Рекомендация: добавить USER. + +## 8. Итог +Единственный блокер: /debug с утечкой секретов. Остальное — желательно. diff --git a/server/handlers.go b/server/handlers.go index 9c00d22..be73de5 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -5,9 +5,7 @@ import ( "encoding/json" "fmt" "log" - "net" "net/http" - "os" "strings" "time" ) @@ -90,44 +88,3 @@ func readyzHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("ok")) } - -func debugHandler(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - - fmt.Fprintf(w, "=== ENV ===\n") - for _, e := range os.Environ() { - if strings.Contains(e, "S3_") || strings.Contains(e, "REGISTRY") || strings.Contains(e, "PORT") { - fmt.Fprintln(w, e) - } - } - - s3ep := os.Getenv("S3_ENDPOINT") - fmt.Fprintf(w, "\n=== DNS: %s ===\n", s3ep) - addrs, err := net.LookupHost(s3ep) - if err != nil { - fmt.Fprintf(w, "DNS ERROR: %v\n", err) - } else { - for _, a := range addrs { - fmt.Fprintf(w, " %s\n", a) - } - } - - fmt.Fprintf(w, "\n=== TCP dial: %s:443 ===\n", s3ep) - conn, err := net.DialTimeout("tcp", s3ep+":443", 5*time.Second) - if err != nil { - fmt.Fprintf(w, "TCP ERROR: %v\n", err) - } else { - fmt.Fprintf(w, "TCP OK: %s -> %s\n", conn.LocalAddr(), conn.RemoteAddr()) - conn.Close() - } - - fmt.Fprintf(w, "\n=== S3 BucketExists ===\n") - ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second) - defer cancel() - _, err = s3Client.BucketExists(ctx, bucketName) - if err != nil { - fmt.Fprintf(w, "S3 ERROR: %v\n", err) - } else { - fmt.Fprintf(w, "S3 OK: bucket %s accessible\n", bucketName) - } -} diff --git a/server/main.go b/server/main.go index 8becc3b..b4f607f 100644 --- a/server/main.go +++ b/server/main.go @@ -61,7 +61,6 @@ func main() { http.Handle("/", http.HandlerFunc(rootHandler)) http.HandleFunc("/healthz", healthzHandler) http.HandleFunc("/readyz", readyzHandler) - http.HandleFunc("/debug", debugHandler) port := os.Getenv("PORT") if port == "" {