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,
|
repository_id: int,
|
||||||
*,
|
*,
|
||||||
source_path: str | None = None,
|
source_path: str | None = None,
|
||||||
|
access_username: str | None = None,
|
||||||
|
access_password: str | None = None,
|
||||||
) -> ScanSummary:
|
) -> ScanSummary:
|
||||||
repository = self.store.get_repository(repository_id)
|
repository = self.store.get_repository(repository_id)
|
||||||
run = self.store.create_analysis_run(repository_id)
|
run = self.store.create_analysis_run(repository_id)
|
||||||
@@ -132,7 +134,12 @@ class RegistryService:
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
if source_path is None:
|
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
|
scan_source = checkout.source_path
|
||||||
else:
|
else:
|
||||||
scan_source = source_path
|
scan_source = source_path
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ def create_analysis_run(
|
|||||||
summary = service.analyze_repository(
|
summary = service.analyze_repository(
|
||||||
repository_id,
|
repository_id,
|
||||||
source_path=payload.source_path,
|
source_path=payload.source_path,
|
||||||
|
access_username=payload.access_username,
|
||||||
|
access_password=payload.access_password,
|
||||||
)
|
)
|
||||||
except NotFoundError as exc:
|
except NotFoundError as exc:
|
||||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||||
|
|||||||
@@ -202,12 +202,18 @@ class EvidenceUpdate(BaseModel):
|
|||||||
|
|
||||||
class AnalysisRunCreate(BaseModel):
|
class AnalysisRunCreate(BaseModel):
|
||||||
source_path: str | None = None
|
source_path: str | None = None
|
||||||
|
access_username: str | None = None
|
||||||
|
access_password: str | None = Field(default=None, repr=False)
|
||||||
|
|
||||||
model_config = {
|
model_config = {
|
||||||
"json_schema_extra": {
|
"json_schema_extra": {
|
||||||
"examples": [
|
"examples": [
|
||||||
{},
|
{},
|
||||||
{"source_path": "/path/to/local/repository"},
|
{"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>
|
<h2>Run Analysis</h2>
|
||||||
<form class="stack" method="post" action="/ui/repos/{repository_id}/analysis-runs">
|
<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>
|
<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>
|
</form>
|
||||||
<h2>Analysis Runs</h2>
|
<h2>Analysis Runs</h2>
|
||||||
<table>
|
<table>
|
||||||
@@ -795,11 +800,15 @@ def delete_evidence_from_form(
|
|||||||
def create_analysis_run_from_form(
|
def create_analysis_run_from_form(
|
||||||
repository_id: int,
|
repository_id: int,
|
||||||
source_path: str = Form(""),
|
source_path: str = Form(""),
|
||||||
|
access_username: str = Form(""),
|
||||||
|
access_password: str = Form(""),
|
||||||
service: RegistryService = Depends(get_service),
|
service: RegistryService = Depends(get_service),
|
||||||
) -> RedirectResponse:
|
) -> RedirectResponse:
|
||||||
summary = service.analyze_repository(
|
summary = service.analyze_repository(
|
||||||
repository_id,
|
repository_id,
|
||||||
source_path=source_path or None,
|
source_path=source_path or None,
|
||||||
|
access_username=access_username or None,
|
||||||
|
access_password=access_password or None,
|
||||||
)
|
)
|
||||||
return RedirectResponse(
|
return RedirectResponse(
|
||||||
f"/ui/repos/{repository_id}/analysis-runs/{summary.analysis_run.id}",
|
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)
|
detail_response = client.get(repository_path)
|
||||||
assert detail_response.status_code == 200
|
assert detail_response.status_code == 200
|
||||||
assert "Run Analysis" in detail_response.text
|
assert "Run Analysis" in detail_response.text
|
||||||
|
assert "Running analysis..." in detail_response.text
|
||||||
assert "Repository Metadata" in detail_response.text
|
assert "Repository Metadata" in detail_response.text
|
||||||
|
|
||||||
edit_repository_response = client.post(
|
edit_repository_response = client.post(
|
||||||
@@ -1110,7 +1111,11 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
|||||||
|
|
||||||
run_response = client.post(
|
run_response = client.post(
|
||||||
f"{repository_path}/analysis-runs",
|
f"{repository_path}/analysis-runs",
|
||||||
data={"source_path": ""},
|
data={
|
||||||
|
"source_path": "",
|
||||||
|
"access_username": "",
|
||||||
|
"access_password": "",
|
||||||
|
},
|
||||||
follow_redirects=False,
|
follow_redirects=False,
|
||||||
)
|
)
|
||||||
assert run_response.status_code == 303
|
assert run_response.status_code == 303
|
||||||
|
|||||||
Reference in New Issue
Block a user