fix: /debug убран (утечка секретов)
This commit is contained in:
@@ -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 с утечкой секретов. Остальное — желательно.
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 == "" {
|
||||
|
||||
Reference in New Issue
Block a user