Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CI] [GHA] Validate job log downloading and Teams hook schemas (#37464)

Andrei Kashchikhin7c43612866b9
diff --git a/.github/scripts/agentic-workflows/common.py b/.github/scripts/agentic-workflows/common.py
index 2330d74b4eb..a49fb3f1db0 100644
--- a/.github/scripts/agentic-workflows/common.py
+++ b/.github/scripts/agentic-workflows/common.py
@@ -19,6 +19,7 @@ import os
import re
import sys
import urllib.error
+import urllib.parse
import urllib.request
from typing import TYPE_CHECKING, Any, Literal
@@ -194,6 +195,8 @@ def post_adaptive_card(webhook_url: str, body: list[dict[str, Any]]) -> None:
}
],
}
+ if urllib.parse.urlsplit(webhook_url).scheme != "https":
+ sys.exit(f"Teams webhook URL must use https, got: '{webhook_url}'")
request = urllib.request.Request(
webhook_url,
data=json.dumps(payload).encode("utf-8"),
@@ -201,7 +204,7 @@ def post_adaptive_card(webhook_url: str, body: list[dict[str, Any]]) -> None:
method="POST",
)
try:
- with urllib.request.urlopen(request) as response:
+ with urllib.request.urlopen(request) as response: # nosec B310 - scheme restricted to https above
print(f"Teams webhook responded with HTTP {response.status}: {response.read().decode('utf-8', 'replace')}")
except urllib.error.HTTPError as error:
sys.exit(f"Teams webhook failed with HTTP {error.code}: {error.read().decode('utf-8', 'replace')}")
diff --git a/.github/scripts/agentic-workflows/download_failure_logs.py b/.github/scripts/agentic-workflows/download_failure_logs.py
index 10d04a77b9c..000c2a4feaf 100644
--- a/.github/scripts/agentic-workflows/download_failure_logs.py
+++ b/.github/scripts/agentic-workflows/download_failure_logs.py
@@ -18,6 +18,7 @@ import json
import os
import re
import sys
+import urllib.parse
import urllib.request
from typing import TYPE_CHECKING, Any, TextIO
@@ -45,8 +46,11 @@ def download_job_log(job: "WorkflowJob") -> None:
"""Download the log for a single failed job and pre-locate error hints."""
log_file = os.path.join(LOG_DIR, f"job-{job.id}.log")
print(f"Downloading log for job {job.id}...")
+ logs_url = job.logs_url()
try:
- with urllib.request.urlopen(job.logs_url()) as response:
+ if urllib.parse.urlsplit(logs_url).scheme not in ("http", "https"):
+ raise ValueError(f"unexpected log URL scheme: '{logs_url}'")
+ with urllib.request.urlopen(logs_url) as response: # nosec B310 - scheme restricted to http(s) above
content = response.read().decode("utf-8", "replace")
except Exception:
content = "(log download failed)\n"