🔒 security: move IMAP credentials to request body and fix CI/pylint issues
- Moved IMAP credentials from query parameters to the request body for the test-connection endpoint. - Created missing `__init__.py` files across `backend/app/` to fix CI `ModuleNotFoundError`. - Reformatted `setup.py` and `user.py` using `black` to pass lint checks. - Addressed Pylint warnings in `imap.py` (unused arguments, lazy logging, exception chaining). Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ class IMAPTestRequest(BaseModel):
|
|||||||
@router.post("/test-connection")
|
@router.post("/test-connection")
|
||||||
async def test_imap_connection(
|
async def test_imap_connection(
|
||||||
request: IMAPTestRequest,
|
request: IMAPTestRequest,
|
||||||
auth: dict = Depends(require_admin_auth),
|
_auth: dict = Depends(require_admin_auth),
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Test connection to an IMAP server and gather mailbox statistics
|
Test connection to an IMAP server and gather mailbox statistics
|
||||||
@@ -55,7 +55,7 @@ async def test_imap_connection(
|
|||||||
@router.post("/fetch-reports")
|
@router.post("/fetch-reports")
|
||||||
async def fetch_imap_reports(
|
async def fetch_imap_reports(
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
auth: dict = Depends(require_admin_auth),
|
_auth: dict = Depends(require_admin_auth),
|
||||||
days: int = 7,
|
days: int = 7,
|
||||||
delete_emails: bool = False,
|
delete_emails: bool = False,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
@@ -92,14 +92,14 @@ async def fetch_imap_reports(
|
|||||||
"timestamp": datetime.now().isoformat(),
|
"timestamp": datetime.now().isoformat(),
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error fetching IMAP reports: {str(e)}")
|
logger.error("Error fetching IMAP reports: %s", str(e))
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=500, detail="Failed to fetch reports. Check server logs for details."
|
status_code=500, detail="Failed to fetch reports. Check server logs for details."
|
||||||
)
|
) from e
|
||||||
|
|
||||||
|
|
||||||
@router.get("/status")
|
@router.get("/status")
|
||||||
async def get_imap_status(auth: dict = Depends(require_admin_auth)) -> Dict[str, Any]:
|
async def get_imap_status(_auth: dict = Depends(require_admin_auth)) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Get the current status of IMAP polling background processes
|
Get the current status of IMAP polling background processes
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from fastapi import APIRouter, HTTPException, status
|
from fastapi import APIRouter, HTTPException, status
|
||||||
from pydantic import BaseModel, EmailStr
|
from pydantic import BaseModel, EmailStr
|
||||||
|
|
||||||
@@ -38,7 +37,8 @@ class SystemConfigRequest(BaseModel):
|
|||||||
async def get_setup_status():
|
async def get_setup_status():
|
||||||
"""Get the current setup status"""
|
"""Get the current setup status"""
|
||||||
return SetupStatusResponse(
|
return SetupStatusResponse(
|
||||||
is_setup_complete=setup_status["is_setup_complete"], app_name=setup_status["app_name"]
|
is_setup_complete=setup_status["is_setup_complete"],
|
||||||
|
app_name=setup_status["app_name"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
from app.core.database import Base
|
|
||||||
from sqlalchemy import Boolean, Column, Integer, String
|
from sqlalchemy import Boolean, Column, Integer, String
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.core.database import Base
|
||||||
|
|
||||||
|
|
||||||
class User(Base):
|
class User(Base):
|
||||||
"""User model"""
|
"""User model"""
|
||||||
|
|||||||
Reference in New Issue
Block a user