fix(security): remove clear-text logging of sensitive data and fix Annotated+Depends pattern

- audit_logs.py: Remove _db_dep pattern that fails with latest FastAPI on
  Python 3.11. Use clean DbSession = Annotated[Session, Depends(get_db)]
  without default values.
- billing.py: Remove owner_id from log messages to fix CodeQL clear-text
  logging of sensitive information alerts.
- files.py: Remove owner_id from log messages to fix CodeQL clear-text
  logging of sensitive information alerts.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-16 12:07:04 +00:00
parent 8cc817930d
commit b7a3b301a3
3 changed files with 9 additions and 13 deletions
+4 -6
View File
@@ -20,16 +20,14 @@ logger = logging.getLogger(__name__)
router = APIRouter()
# Module-level dependency singleton to satisfy Ruff B008 while maintaining default values for manual calls (e.g. in decorators).
_db_dep = Depends(get_db)
DbSession = Annotated[Session, _db_dep]
DbSession = Annotated[Session, Depends(get_db)]
@router.get("/audit-logs")
@require_login
async def list_audit_logs(
request: Request,
db: DbSession = _db_dep,
db: DbSession,
action: Annotated[str | None, Query(description="Filter by action (exact match)")] = None,
user: Annotated[str | None, Query(description="Filter by username")] = None,
resource_type: Annotated[str | None, Query(description="Filter by resource type")] = None,
@@ -75,7 +73,7 @@ async def list_audit_logs(
@require_login
async def list_distinct_actions(
request: Request,
db: DbSession = _db_dep,
db: DbSession,
) -> list[str]:
"""Return the distinct action values present in the audit log."""
from app.models import AuditLog
@@ -88,7 +86,7 @@ async def list_distinct_actions(
@require_login
async def list_distinct_users(
request: Request,
db: DbSession = _db_dep,
db: DbSession,
) -> list[str]:
"""Return the distinct user values present in the audit log."""
from app.models import AuditLog