Version 0.5.5.93: custom fields in lists, MeshCentral sync flag for statuses
- Show custom field values in asset list, dashboard and list Excel export - New status flag to exclude assets (e.g. scrapped) from MeshCentral sync - Require a secure SESSION_SECRET with a readable startup message - Add SESSION_COOKIE_SECURE and refresh session permissions per request - Translate HTTP errors and remaining fixed UI texts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3f1ef43db
commit
261b4f2029
35 files changed
+768
-308
No files matched your search
+11
-10
@@ -40,6 +40,7 @@ from .analyzer_profiles import (
|
||||
)
|
||||
|
||||
from fastapi import Depends, File, Form, HTTPException, Request, UploadFile
|
||||
from .errors import TranslatedHTTPException
|
||||
from fastapi.responses import RedirectResponse, StreamingResponse
|
||||
|
||||
try:
|
||||
@@ -126,7 +127,7 @@ async def _save_upload(upload: UploadFile) -> tuple[str, Path, int, str]:
|
||||
extension = Path(filename).suffix.lower()
|
||||
if extension not in ALLOWED_EXTENSIONS:
|
||||
await upload.close()
|
||||
raise HTTPException(400, "Unsupported installer file type.")
|
||||
raise TranslatedHTTPException(400, "errors.installer_type_unsupported", "Unsupported installer file type.")
|
||||
|
||||
token = uuid.uuid4().hex
|
||||
job_dir = TEMP_ROOT / token
|
||||
@@ -144,7 +145,7 @@ async def _save_upload(upload: UploadFile) -> tuple[str, Path, int, str]:
|
||||
break
|
||||
total += len(chunk)
|
||||
if total > limit:
|
||||
raise HTTPException(413, f"Maximum upload size exceeded ({MAX_UPLOAD_MB} MB).")
|
||||
raise TranslatedHTTPException(413, "errors.upload_too_large", "Maximum upload size exceeded ({max_mb} MB).", max_mb=MAX_UPLOAD_MB)
|
||||
digest.update(chunk)
|
||||
handle.write(chunk)
|
||||
except Exception:
|
||||
@@ -155,24 +156,24 @@ async def _save_upload(upload: UploadFile) -> tuple[str, Path, int, str]:
|
||||
|
||||
if total == 0:
|
||||
shutil.rmtree(job_dir, ignore_errors=True)
|
||||
raise HTTPException(400, "The uploaded installer is empty.")
|
||||
raise TranslatedHTTPException(400, "errors.installer_empty", "The uploaded installer is empty.")
|
||||
return token, target, total, digest.hexdigest()
|
||||
|
||||
|
||||
def _analysis_file(token: str) -> tuple[Path, dict[str, Any]]:
|
||||
if not re.fullmatch(r"[0-9a-f]{32}", token or ""):
|
||||
raise HTTPException(400, "Invalid analysis token.")
|
||||
raise TranslatedHTTPException(400, "errors.analysis_token_invalid", "Invalid analysis token.")
|
||||
job_dir = TEMP_ROOT / token
|
||||
meta_file = job_dir / "analysis.json"
|
||||
if not meta_file.is_file():
|
||||
raise HTTPException(404, "Analysis is no longer available.")
|
||||
raise TranslatedHTTPException(404, "errors.analysis_unavailable", "Analysis is no longer available.")
|
||||
try:
|
||||
meta = json.loads(meta_file.read_text(encoding="utf-8"))
|
||||
except (OSError, ValueError) as exc:
|
||||
raise HTTPException(404, "Analysis metadata is not available.") from exc
|
||||
raise TranslatedHTTPException(404, "errors.analysis_metadata_unavailable", "Analysis metadata is not available.") from exc
|
||||
target = job_dir / _safe_filename(meta.get("filename"))
|
||||
if not target.is_file():
|
||||
raise HTTPException(404, "Installer file is no longer available.")
|
||||
raise TranslatedHTTPException(404, "errors.installer_unavailable", "Installer file is no longer available.")
|
||||
return target, meta
|
||||
|
||||
|
||||
@@ -1129,15 +1130,15 @@ def _create_payload_archive(target: Path, meta: dict[str, Any]) -> Path:
|
||||
root = (target.parent / root_rel).resolve()
|
||||
job_root = target.parent.resolve()
|
||||
if job_root != root and job_root not in root.parents:
|
||||
raise HTTPException(400, "Invalid embedded payload directory.")
|
||||
raise TranslatedHTTPException(400, "errors.payload_directory_invalid", "Invalid embedded payload directory.")
|
||||
if not root.is_dir():
|
||||
raise HTTPException(404, "Embedded payload is no longer available.")
|
||||
raise TranslatedHTTPException(404, "errors.payload_unavailable", "Embedded payload is no longer available.")
|
||||
archive_path = target.parent / "embedded-payload.zip"
|
||||
if archive_path.exists():
|
||||
archive_path.unlink()
|
||||
count, total = _validate_extracted_tree(root, MAX_EXTRACTED_FILES, MAX_EXTRACTED_MB * 1024 * 1024)
|
||||
if count <= 0 or total <= 0:
|
||||
raise HTTPException(400, "Embedded payload is empty.")
|
||||
raise TranslatedHTTPException(400, "errors.payload_empty", "Embedded payload is empty.")
|
||||
with zipfile.ZipFile(archive_path, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for item in sorted(root.rglob("*")):
|
||||
if item.is_file():
|
||||
|
||||
Reference in new issue
Block a user