Fix health endpoint scanner availability checks#13
Conversation
|
@sasidaran-99 Tests fail. |
|
Hi @ionfwsrijan will look into this and will update |
|
Hey @Trishanthsai! The core logic looks good.
return {
"ok": True,
"status": status,
"scanners": scanners,
}...or confirm nothing in the frontend depends on it and document the shape change in the PR description. 2 Frontend piece is missing — the issue spec included a warning banner in the UI when Fix these and this is good to merge! |
|
Hi @ionfwsrijan, I've restored the For the frontend warning banner when the health status is Thanks! |
|
@Trishanthsai That LGMT as well. You may raise a followup issue. Also pls resolve the merge conflicts with the main |
|
Hi @ionfwsrijan, I've resolved the merge conflicts with main. The PR now shows no conflicts with the base branch. It looks like the remaining workflow is awaiting maintainer approval. Could you please approve/re-run it when you get a chance? Also, I'll raise a follow-up issue for the frontend degraded-status warning banner as discussed. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR updates the FastAPI backend /health endpoint to report whether required CLI scanners are present on PATH, and to surface a degraded health state when one or more scanners are missing. This supports more accurate operational readiness checks before running scans.
Changes:
- Add
shutil.which()checks forsemgrep,osv-scanner, andgitleaks. - Include per-scanner availability in the
/healthresponse. - Add a derived
statusfield (okvsdegraded) based on scanner availability.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| status = "ok" if all(scanners.values()) else "degraded" | ||
|
|
||
| return { | ||
| "ok": True, | ||
| "status": status, | ||
| "scanners": scanners, | ||
| } |
| scanners = { | ||
| "semgrep": shutil.which("semgrep") is not None, | ||
| "osv-scanner": shutil.which("osv-scanner") is not None, | ||
| "gitleaks": shutil.which("gitleaks") is not None, | ||
| } |
| from __future__ import annotations | ||
| import shutil | ||
|
|
||
| import asyncio | ||
| import os |
Linked issue
Closes #9
What this PR does
Updated the
/healthendpoint to check whethersemgrep,osv-scanner, andgitleaksare available on the system. The endpoint now returns the availability of each scanner and reports the status asdegradedwhen one or more scanners are missing.Type of change
ML tier (if applicable)
Changes
Backend
shutil.which()/healthresponsedegradedstatus when any scanner is unavailableTesting
How did you test this?
Ran the backend locally and verified the
/healthendpoint response in the browser. Confirmed that scanner availability is reported correctly and the status changes todegradedwhen scanners are not installed.Checklist
console.erroror unhandled Python exceptions introducedAnything reviewers should focus on
Health status logic and scanner availability checks.