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
|
serviceAccountName: fission-console
|
||||||
containers:
|
containers:
|
||||||
- name: console
|
- name: console
|
||||||
image: naeel/fission-console:v1.3.38
|
image: naeel/fission-console:v1.3.39
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8090
|
- containerPort: 8090
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -41,12 +42,19 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ограничиваем тело запроса — не более maxArchiveBytes (+ небольшой overhead для multipart)
|
// Hard-limit 10 MB чтобы соединение не обрывалось (MaxBytesReader с маленьким лимитом
|
||||||
r.Body = http.MaxBytesReader(w, r.Body, maxArchiveBytes+4*1024)
|
// закрывает соединение до отправки ответа — клиент получает 000 вместо 413).
|
||||||
|
// Реальный лимит размера архива проверяется после чтения файла.
|
||||||
|
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)
|
||||||
|
|
||||||
if err := r.ParseMultipartForm(maxArchiveBytes); err != nil {
|
if err := r.ParseMultipartForm(maxArchiveBytes); err != nil {
|
||||||
writeJSONError(w, http.StatusRequestEntityTooLarge,
|
var maxErr *http.MaxBytesError
|
||||||
fmt.Sprintf("архив слишком большой: максимум %d KB", maxArchiveBytes/1024))
|
if errors.As(err, &maxErr) {
|
||||||
|
writeJSONError(w, http.StatusRequestEntityTooLarge,
|
||||||
|
fmt.Sprintf("архив слишком большой: максимум %d KB", maxArchiveBytes/1024))
|
||||||
|
} else {
|
||||||
|
writeJSONError(w, http.StatusBadRequest, "ошибка разбора multipart: "+err.Error())
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
<div class="nubes">NUBES</div>
|
<div class="nubes">NUBES</div>
|
||||||
<div class="product">FISSION CONSOLE</div>
|
<div class="product">FISSION CONSOLE</div>
|
||||||
</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>
|
||||||
<div class="row" style="margin:0;">
|
<div class="row" style="margin:0;">
|
||||||
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
||||||
@@ -398,7 +398,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions" style="justify-content:space-between; align-items:center;">
|
<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>
|
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ OK=$(json_field "$BODY" ok)
|
|||||||
echo ""
|
echo ""
|
||||||
echo ">>> Архив > 100 KB → 413"
|
echo ">>> Архив > 100 KB → 413"
|
||||||
BIG_ZIP="${TMP}/big.zip"
|
BIG_ZIP="${TMP}/big.zip"
|
||||||
# Создаём файл > 100 KB и пакуем
|
# Случайные бинарные данные не сжимаются → zip гарантированно > 100 KB
|
||||||
dd if=/dev/urandom bs=1024 count=110 2>/dev/null | base64 > "${TMP}/big.txt"
|
dd if=/dev/urandom bs=1024 count=130 2>/dev/null > "${TMP}/big.bin"
|
||||||
(cd "$TMP" && zip -q big.zip big.txt)
|
(cd "$TMP" && zip -q big.zip big.bin)
|
||||||
R=$(lint_post "$BIG_ZIP")
|
R=$(lint_post "$BIG_ZIP")
|
||||||
HTTP=$(echo "$R" | tail -1)
|
HTTP=$(echo "$R" | tail -1)
|
||||||
check_http "$HTTP" "413" "Большой архив → 413"
|
check_http "$HTTP" "413" "Большой архив → 413"
|
||||||
|
|||||||
Reference in New Issue
Block a user