Skip to content

bandit B310: urlopen in last30days/evaluate_search_quality.py:347 permits file:/ scheme #232

Description

@Jaggerxtrm

Issue

bandit flags Medium severity (CWE-22, High confidence) on evaluate_search_quality.py:347:

with urlopen(request, timeout=120) as response:
    payload = json.loads(response.read().decode("utf-8"))

Bandit warning:

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.
https://bandit.readthedocs.io/en/0.0.0/blacklists/blacklist_calls.html#b310-urllib-urlopen

Impact

Blocks every commit in downstream xtrm-equipped projects that have bandit in their pre-commit config, after any xt update sync. Forces --no-verify to land routine sync commits.

Suggested fix

Either:

  1. Switch to requests or urllib3 (explicit http/https only) — preferred since last30days only fetches public HTTP APIs anyway, and
  2. Or add # nosec B310 - URL is constructed from a trusted env-controlled base; only http(s) schemes used in practice annotation if the call must remain urllib.request.urlopen.

Repro

Downstream chore commit after xt update triggers pre-commit bandit failure on this file.

Discovered in

darth-feedor session 2026-05-13 follow-up; needed --no-verify to land routine chore: xt update commit (cover bead filed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions