Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 80c5fc1

Browse files
authored
Merge pull request #137 from Ankit-Kotnala/fix/authenticated-scanner-scan
Secure scanner scan creation with authenticated ownership
2 parents 50871d1 + fa9e5d7 commit 80c5fc1

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ src/api/routes/search.py
9090

9191
# Misc
9292
error.json
93-
MIGRATION_PLAN.md
93+
MIGRATION_PLAN.md

‎src/api/routes/scanner.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ class ValidateUrlRequest(BaseModel):
7575

7676
class ScanRequest(BaseModel):
7777
github_url: str = Field(..., min_length=1)
78-
username: str = Field(..., min_length=1)
78+
username: str = Field(
79+
default="",
80+
description="Deprecated and ignored; the username is derived from authentication.",
81+
)
7982
pat: str = Field(default="")
8083
branch: str = Field(default="main")
8184
force_full: bool = Field(default=True)
@@ -753,15 +756,15 @@ async def resume_scan(req: ResumeScanRequest, user: dict = Depends(require_api_k
753756

754757

755758
@router.post("/scan", summary="Start scanning a GitHub repository")
756-
async def start_scan(req: ScanRequest):
759+
async def start_scan(req: ScanRequest, user: dict = Depends(require_api_key)):
757760
try:
758761
org, repo = _parse_github_url(req.github_url)
759762
except ValueError as e:
760763
return JSONResponse(
761764
{"status": "error", "error": str(e)}, status_code=400,
762765
)
763766

764-
username = req.username
767+
username = user.get("username") or user.get("name") or user["id"]
765768
job_id = f"{username}:{org}:{repo}"
766769
store = _get_code_store()
767770

0 commit comments

Comments
 (0)