Context
Issue #517 fixed utils/notify.py: the # nosec B310 comment claimed "caller
validates scheme" but no validation existed. Fix added _validate_webhook_url().
Same pattern exists in scripts/poll_dashboard_scan.py — two urlopen calls with
# nosec B310 but no scheme validation:
# scripts/poll_dashboard_scan.py — get_json() and post_json()
with urllib.request.urlopen(req, timeout=60) as r: # nosec B310
The --base / DATA_BOAR_BASE argument accepts any URL (default:
http://127.0.0.1:8088). No if parsed.scheme not in {"http", "https"} guard.
Contrast with fixed files
| File |
nosec B310 |
Scheme validation |
utils/notify.py |
✅ fixed by #517 |
_validate_webhook_url() → raises on non-https |
scripts/ops_notify.py |
✅ |
if parsed.scheme != "https": raise (line 34) |
scripts/check_name_availability.py |
✅ |
URL hardcoded as https://pypi.org/... |
scripts/sonar_issues.py |
partial |
defaults to https://sonarcloud.io but env-var not validated |
scripts/poll_dashboard_scan.py |
❌ |
no validation — localhost default but accepts any --base |
Risk
Low — dev/ops helper, not product code, operator-controlled input. But the
nosec justification is technically false (same as old notify.py), misleads
reviewers, and creates a pattern inconsistency with the already-fixed files.
Suggested fix
In scripts/poll_dashboard_scan.py, add before the first urlopen in both
get_json() and post_json():
import urllib.parse
_parsed = urllib.parse.urlparse(base)
if _parsed.scheme not in {"http", "https"}:
raise ValueError(f"Unsupported scheme '{_parsed.scheme}' in base URL '{base}'")
Or extract a shared _validate_base_url(base: str) called once in main().
Update # nosec B310 comment to # nosec B310 — scheme validated above.
Acceptance criteria
Out of scope
scripts/sonar_issues.py — separate issue if operator wants to address
- Changing product code (
utils/notify.py already fixed)
Context
Issue #517 fixed
utils/notify.py: the# nosec B310comment claimed "callervalidates scheme" but no validation existed. Fix added
_validate_webhook_url().Same pattern exists in
scripts/poll_dashboard_scan.py— twourlopencalls with# nosec B310but no scheme validation:The
--base/DATA_BOAR_BASEargument accepts any URL (default:http://127.0.0.1:8088). Noif parsed.scheme not in {"http", "https"}guard.Contrast with fixed files
utils/notify.py_validate_webhook_url()→ raises on non-httpsscripts/ops_notify.pyif parsed.scheme != "https": raise(line 34)scripts/check_name_availability.pyhttps://pypi.org/...scripts/sonar_issues.pyhttps://sonarcloud.iobut env-var not validatedscripts/poll_dashboard_scan.py--baseRisk
Low — dev/ops helper, not product code, operator-controlled input. But the
nosecjustification is technically false (same as oldnotify.py), misleadsreviewers, and creates a pattern inconsistency with the already-fixed files.
Suggested fix
In
scripts/poll_dashboard_scan.py, add before the firsturlopenin bothget_json()andpost_json():Or extract a shared
_validate_base_url(base: str)called once inmain().Update
# nosec B310comment to# nosec B310 — scheme validated above.Acceptance criteria
urlopenin bothget_json()andpost_json()# nosec B310comment updated to reflect true justificationuv run bandit -r . -c pyproject.toml -ll -iistill passeshttp://andhttps://URLsOut of scope
scripts/sonar_issues.py— separate issue if operator wants to addressutils/notify.pyalready fixed)