fix: lint-archive error handling, test: big zip binary, v1.3.39
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<div class="nubes">NUBES</div>
|
||||
<div class="product">FISSION CONSOLE</div>
|
||||
</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.38</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.39</div>
|
||||
</div>
|
||||
<div class="row" style="margin:0;">
|
||||
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
||||
@@ -398,7 +398,7 @@
|
||||
</div>
|
||||
|
||||
<div class="actions" style="justify-content:space-between; align-items:center;">
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.38</span>
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.39</span>
|
||||
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user