Skip to content

Commit fdfda61

Browse files
committed
examples(python): annotate remaining bandit findings; tighten CI gate
1 parent 806bd4a commit fdfda61

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

.github/workflows/test-python-bindings.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
working-directory: bindings/python
5353
run: python -m bandit -c pyproject.toml -r src tests --severity-level low --confidence-level low
5454

55+
- name: Run Bandit on examples (must be clean at medium+/high-confidence)
56+
working-directory: bindings/python
57+
run: python -m bandit -c pyproject.toml -r examples --severity-level medium --confidence-level high
58+
5559
# First job: Download ArcadeDB JARs (platform-agnostic)
5660
download-jars:
5761
name: Download ArcadeDB JARs

bindings/python/examples/11_vector_index_build.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ def get_docker_version() -> str | None:
9595

9696

9797
def fetch_json(url: str) -> dict:
98+
if not url.startswith("https://"):
99+
raise ValueError(f"Refusing to open non-HTTPS URL: {url!r}")
98100
req = Request(url, headers={"User-Agent": "arcadedb-bench"})
99-
with urlopen(req, timeout=30) as response:
101+
with urlopen(req, timeout=30) as response: # nosec B310 - https-only
100102
payload = json.load(response)
101103
if not isinstance(payload, dict):
102104
raise RuntimeError(f"Expected JSON object from {url}")
@@ -962,7 +964,9 @@ def wait_for_qdrant_ready(host: str, port: int, timeout_sec: int = 120) -> None:
962964
while True:
963965
for url in urls:
964966
try:
965-
with urlopen(url, timeout=3) as response:
967+
with urlopen(
968+
url, timeout=3
969+
) as response: # nosec B310 - localhost health-check URL
966970
if 200 <= int(response.status) < 500:
967971
return
968972
except Exception:
@@ -1012,7 +1016,9 @@ def ensure_milvus_compose_file(compose_file: Path, release_tag: str) -> None:
10121016
"https://github.com/milvus-io/milvus/releases/download/"
10131017
f"{release_tag}/milvus-standalone-docker-compose.yml"
10141018
)
1015-
urlretrieve(url, str(compose_file))
1019+
urlretrieve(
1020+
url, str(compose_file)
1021+
) # nosec B310 - url is a hardcoded https://github.com URL
10161022
raw = compose_file.read_text(encoding="utf-8")
10171023

10181024
sanitized = re.sub(r"(?m)^\s*container_name:\s*.*\n", "", raw)

bindings/python/examples/12_vector_search.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ def get_docker_version() -> str | None:
100100

101101

102102
def fetch_json(url: str) -> dict:
103+
if not url.startswith("https://"):
104+
raise ValueError(f"Refusing to open non-HTTPS URL: {url!r}")
103105
req = Request(url, headers={"User-Agent": "arcadedb-bench"})
104-
with urlopen(req, timeout=30) as response:
106+
with urlopen(req, timeout=30) as response: # nosec B310 - https-only
105107
payload = json.load(response)
106108
if not isinstance(payload, dict):
107109
raise RuntimeError(f"Expected JSON object from {url}")
@@ -1006,7 +1008,9 @@ def wait_for_qdrant_ready(host: str, port: int, timeout_sec: int = 120) -> None:
10061008
while True:
10071009
for url in urls:
10081010
try:
1009-
with urlopen(url, timeout=3) as response:
1011+
with urlopen(
1012+
url, timeout=3
1013+
) as response: # nosec B310 - localhost health-check URL
10101014
if 200 <= int(response.status) < 500:
10111015
return
10121016
except Exception:
@@ -1243,7 +1247,9 @@ def ensure_milvus_compose_file(compose_file: Path, release_tag: str) -> None:
12431247
"https://github.com/milvus-io/milvus/releases/download/"
12441248
f"{release_tag}/milvus-standalone-docker-compose.yml"
12451249
)
1246-
urlretrieve(url, str(compose_file))
1250+
urlretrieve(
1251+
url, str(compose_file)
1252+
) # nosec B310 - url is a hardcoded https://github.com URL
12471253
raw = compose_file.read_text(encoding="utf-8")
12481254

12491255
sanitized = re.sub(r"(?m)^\s*version\s*:\s*.*\n", "", raw)

0 commit comments

Comments
 (0)