From 1e50cc1a834a51d9c5c3dc27f9b2c27984ecbd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 9 Aug 2026 10:05:03 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20proxyHandler=20=E2=80=94=20timeout=2060s?= =?UTF-8?q?,=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D1=8F=20ke?= =?UTF-8?q?y=20=D0=BF=D0=BE=20s3Prefix;=20readyz=20=E2=80=94=20timeout=205?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/main.go b/server/main.go index 7aa02c7..6cae426 100644 --- a/server/main.go +++ b/server/main.go @@ -300,8 +300,15 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, "Missing key param", http.StatusBadRequest) return } + if !strings.HasPrefix(key, s3Prefix+"/") && !strings.HasPrefix(key, "docs/") { + http.Error(w, "Forbidden", http.StatusForbidden) + return + } - obj, err := s3Client.GetObject(context.Background(), bucketName, key, s3.GetObjectOptions{}) + ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) + defer cancel() + + obj, err := s3Client.GetObject(ctx, bucketName, key, s3.GetObjectOptions{}) if err != nil { log.Printf("Error getting object %s/%s: %v", bucketName, key, err) http.Error(w, "File not found", http.StatusNotFound) @@ -479,7 +486,9 @@ func healthzHandler(w http.ResponseWriter, r *http.Request) { } func readyzHandler(w http.ResponseWriter, r *http.Request) { - _, err := s3Client.BucketExists(context.Background(), bucketName) + ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) + defer cancel() + _, err := s3Client.BucketExists(ctx, bucketName) if err != nil { msg := fmt.Sprintf("s3 unreachable: %v", err) log.Printf("readyz: %s", msg)