generated from coulomb/repo-seed
Username/Password fields on analyse repo mask
This commit is contained in:
@@ -120,6 +120,8 @@ class RegistryService:
|
||||
repository_id: int,
|
||||
*,
|
||||
source_path: str | None = None,
|
||||
access_username: str | None = None,
|
||||
access_password: str | None = None,
|
||||
) -> ScanSummary:
|
||||
repository = self.store.get_repository(repository_id)
|
||||
run = self.store.create_analysis_run(repository_id)
|
||||
@@ -132,7 +134,12 @@ class RegistryService:
|
||||
)
|
||||
try:
|
||||
if source_path is None:
|
||||
checkout = self.ingestion.resolve(repository.url, branch=repository.branch)
|
||||
checkout = self.ingestion.resolve(
|
||||
repository.url,
|
||||
branch=repository.branch,
|
||||
access_username=access_username,
|
||||
access_password=access_password,
|
||||
)
|
||||
scan_source = checkout.source_path
|
||||
else:
|
||||
scan_source = source_path
|
||||
|
||||
@@ -245,6 +245,8 @@ def create_analysis_run(
|
||||
summary = service.analyze_repository(
|
||||
repository_id,
|
||||
source_path=payload.source_path,
|
||||
access_username=payload.access_username,
|
||||
access_password=payload.access_password,
|
||||
)
|
||||
except NotFoundError as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
|
||||
@@ -202,12 +202,18 @@ class EvidenceUpdate(BaseModel):
|
||||
|
||||
class AnalysisRunCreate(BaseModel):
|
||||
source_path: str | None = None
|
||||
access_username: str | None = None
|
||||
access_password: str | None = Field(default=None, repr=False)
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{},
|
||||
{"source_path": "/path/to/local/repository"},
|
||||
{
|
||||
"access_username": "git-user",
|
||||
"access_password": "access-token",
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,7 +480,12 @@ def repository_detail(
|
||||
<h2>Run Analysis</h2>
|
||||
<form class="stack" method="post" action="/ui/repos/{repository_id}/analysis-runs">
|
||||
<label>Override source path <input name="source_path" placeholder="Optional local path"></label>
|
||||
<button type="submit">Analyze</button>
|
||||
<label>Username <input name="access_username" autocomplete="username" placeholder="Optional for private HTTP(S) repos"></label>
|
||||
<label>Password or access token <input name="access_password" type="password" autocomplete="current-password" placeholder="Used for this Git operation only"></label>
|
||||
<div class="actions">
|
||||
<button type="submit">Analyze</button>
|
||||
<span data-pending>Running analysis...</span>
|
||||
</div>
|
||||
</form>
|
||||
<h2>Analysis Runs</h2>
|
||||
<table>
|
||||
@@ -795,11 +800,15 @@ def delete_evidence_from_form(
|
||||
def create_analysis_run_from_form(
|
||||
repository_id: int,
|
||||
source_path: str = Form(""),
|
||||
access_username: str = Form(""),
|
||||
access_password: str = Form(""),
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> RedirectResponse:
|
||||
summary = service.analyze_repository(
|
||||
repository_id,
|
||||
source_path=source_path or None,
|
||||
access_username=access_username or None,
|
||||
access_password=access_password or None,
|
||||
)
|
||||
return RedirectResponse(
|
||||
f"/ui/repos/{repository_id}/analysis-runs/{summary.analysis_run.id}",
|
||||
|
||||
@@ -1092,6 +1092,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
detail_response = client.get(repository_path)
|
||||
assert detail_response.status_code == 200
|
||||
assert "Run Analysis" in detail_response.text
|
||||
assert "Running analysis..." in detail_response.text
|
||||
assert "Repository Metadata" in detail_response.text
|
||||
|
||||
edit_repository_response = client.post(
|
||||
@@ -1110,7 +1111,11 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
|
||||
run_response = client.post(
|
||||
f"{repository_path}/analysis-runs",
|
||||
data={"source_path": ""},
|
||||
data={
|
||||
"source_path": "",
|
||||
"access_username": "",
|
||||
"access_password": "",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert run_response.status_code == 303
|
||||
|
||||
Reference in New Issue
Block a user