Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion backend/app/app/api/api_v1/endpoints/scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,13 @@
db: Session = Depends(get_db),
) -> None:
format = settings.IMAGE_FORMAT
static_dir = Path(settings.IMAGE_STATIC_DIR).resolve()
upload_path = (static_dir / f"{id}.{format}").resolve()
Comment thread
cjh1 marked this conversation as resolved.
Dismissed
if not upload_path.is_relative_to(static_dir):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid path"
)

upload_path = Path(settings.IMAGE_STATIC_DIR) / f"{id}.{format}"
async with aiofiles.open(upload_path, "wb") as fp:
await upload_to_file(file, fp)

Expand All @@ -453,3 +458,4 @@
await send_scan_event_to_kafka(
schemas.ScanUpdateEvent(image_path=image_path, id=id)
)

Loading