|
|
|
@ -12,6 +12,7 @@ from src.auth.service import CurrentUser
|
|
|
|
from src.config import WINDOWS_AEROS_BASE_URL, AEROS_BASE_URL, CLAMAV_HOST, CLAMAV_PORT
|
|
|
|
from src.config import WINDOWS_AEROS_BASE_URL, AEROS_BASE_URL, CLAMAV_HOST, CLAMAV_PORT
|
|
|
|
from src.database.core import DbSession
|
|
|
|
from src.database.core import DbSession
|
|
|
|
from src.database.service import search_filter_sort_paginate
|
|
|
|
from src.database.service import search_filter_sort_paginate
|
|
|
|
|
|
|
|
from src.utils import sanitize_filename
|
|
|
|
import clamd
|
|
|
|
import clamd
|
|
|
|
import io
|
|
|
|
import io
|
|
|
|
|
|
|
|
|
|
|
|
@ -26,13 +27,23 @@ client = httpx.AsyncClient(timeout=300.0)
|
|
|
|
async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosProjectInput):
|
|
|
|
async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosProjectInput):
|
|
|
|
# windows_aeros_base_url = WINDOWS_AEROS_BASE_URL
|
|
|
|
# windows_aeros_base_url = WINDOWS_AEROS_BASE_URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file = aeros_project_in.aro_file
|
|
|
|
file = aeros_project_in.aro_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Sanitize and validate filename
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
clean_filename = sanitize_filename(file.filename)
|
|
|
|
|
|
|
|
except ValueError as e:
|
|
|
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
|
|
|
status_code=400,
|
|
|
|
|
|
|
|
detail=f"Invalid filename: {str(e)}"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Get filename
|
|
|
|
# Get filename
|
|
|
|
filename_without_ext = os.path.splitext(file.filename)[0]
|
|
|
|
filename_without_ext = os.path.splitext(clean_filename)[0]
|
|
|
|
|
|
|
|
|
|
|
|
# Get file extension
|
|
|
|
# Get file extension
|
|
|
|
file_ext = os.path.splitext(file.filename)[1].lower()
|
|
|
|
file_ext = os.path.splitext(clean_filename)[1].lower()
|
|
|
|
|
|
|
|
|
|
|
|
# Validate file extension
|
|
|
|
# Validate file extension
|
|
|
|
if file_ext not in ALLOWED_EXTENSIONS:
|
|
|
|
if file_ext not in ALLOWED_EXTENSIONS:
|
|
|
|
@ -92,7 +103,7 @@ async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosPr
|
|
|
|
|
|
|
|
|
|
|
|
# Prepare file for upload
|
|
|
|
# Prepare file for upload
|
|
|
|
files = {
|
|
|
|
files = {
|
|
|
|
"file": (file.filename, content, file.content_type or "application/octet-stream")
|
|
|
|
"file": (clean_filename, content, file.content_type or "application/octet-stream")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print("fetch")
|
|
|
|
print("fetch")
|
|
|
|
|