From 21c11f84d0d71c705e687ec8dfa44e5c6482fc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 3 May 2026 21:24:44 +0400 Subject: [PATCH] fix: lint-archive error handling, test: big zip binary, v1.3.39 --- console/deploy/console.yaml | 2 +- console/internal/api/lint_archive.go | 16 ++++++++++++---- console/ui/index.html | 4 ++-- scripts/test_lint_archive.sh | 6 +++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/console/deploy/console.yaml b/console/deploy/console.yaml index 961e24b..3e8688d 100644 --- a/console/deploy/console.yaml +++ b/console/deploy/console.yaml @@ -52,7 +52,7 @@ spec: serviceAccountName: fission-console containers: - name: console - image: naeel/fission-console:v1.3.38 + image: naeel/fission-console:v1.3.39 imagePullPolicy: Always ports: - containerPort: 8090 diff --git a/console/internal/api/lint_archive.go b/console/internal/api/lint_archive.go index 6ba625d..3ddb663 100644 --- a/console/internal/api/lint_archive.go +++ b/console/internal/api/lint_archive.go @@ -5,6 +5,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "net/http" "os" @@ -41,12 +42,19 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) { return } - // Ограничиваем тело запроса — не более maxArchiveBytes (+ небольшой overhead для multipart) - r.Body = http.MaxBytesReader(w, r.Body, maxArchiveBytes+4*1024) + // Hard-limit 10 MB чтобы соединение не обрывалось (MaxBytesReader с маленьким лимитом + // закрывает соединение до отправки ответа — клиент получает 000 вместо 413). + // Реальный лимит размера архива проверяется после чтения файла. + r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024) if err := r.ParseMultipartForm(maxArchiveBytes); err != nil { - writeJSONError(w, http.StatusRequestEntityTooLarge, - fmt.Sprintf("архив слишком большой: максимум %d KB", maxArchiveBytes/1024)) + var maxErr *http.MaxBytesError + if errors.As(err, &maxErr) { + writeJSONError(w, http.StatusRequestEntityTooLarge, + fmt.Sprintf("архив слишком большой: максимум %d KB", maxArchiveBytes/1024)) + } else { + writeJSONError(w, http.StatusBadRequest, "ошибка разбора multipart: "+err.Error()) + } return } diff --git a/console/ui/index.html b/console/ui/index.html index 744f6fa..3fe7ac1 100644 --- a/console/ui/index.html +++ b/console/ui/index.html @@ -100,7 +100,7 @@
NUBES
FISSION CONSOLE
-
v1.3.38
+
v1.3.39
@@ -398,7 +398,7 @@
- v1.3.38 + v1.3.39
diff --git a/scripts/test_lint_archive.sh b/scripts/test_lint_archive.sh index 97a6819..b21510f 100755 --- a/scripts/test_lint_archive.sh +++ b/scripts/test_lint_archive.sh @@ -114,9 +114,9 @@ OK=$(json_field "$BODY" ok) echo "" echo ">>> Архив > 100 KB → 413" BIG_ZIP="${TMP}/big.zip" -# Создаём файл > 100 KB и пакуем -dd if=/dev/urandom bs=1024 count=110 2>/dev/null | base64 > "${TMP}/big.txt" -(cd "$TMP" && zip -q big.zip big.txt) +# Случайные бинарные данные не сжимаются → zip гарантированно > 100 KB +dd if=/dev/urandom bs=1024 count=130 2>/dev/null > "${TMP}/big.bin" +(cd "$TMP" && zip -q big.zip big.bin) R=$(lint_post "$BIG_ZIP") HTTP=$(echo "$R" | tail -1) check_http "$HTTP" "413" "Большой архив → 413"