Skip to content

Commit b6b9cea

Browse files
fix: validate library name in parse_plot_path
Address Copilot review feedback: reject paths with invalid library names. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2078beb commit b6b9cea

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

automation/scripts/workflow_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,13 @@ def parse_plot_path(file_path: str) -> dict[str, str] | None:
200200
# Match: plots/{spec-id}/implementations/{library}.py
201201
match = re.match(r"plots/([^/]+)/implementations/([^/]+)\.py$", file_path)
202202
if match:
203+
library = match.group(2)
204+
# Validate library name
205+
if library.lower() not in [lib.lower() for lib in SUPPORTED_LIBRARIES]:
206+
return None
203207
return {
204208
"spec_id": match.group(1),
205-
"library": match.group(2),
209+
"library": library,
206210
}
207211

208212
return None

tests/unit/automation/scripts/test_workflow_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ def test_invalid_path(self):
159159
assert parse_plot_path("") is None
160160
assert parse_plot_path(None) is None
161161

162+
def test_invalid_library(self):
163+
# Valid path format but invalid library name
164+
assert parse_plot_path("plots/scatter-basic/implementations/invalid-lib.py") is None
165+
assert parse_plot_path("plots/scatter-basic/implementations/pandas.py") is None
166+
162167

163168
class TestIsValidLibrary:
164169
"""Tests for is_valid_library function."""

0 commit comments

Comments
 (0)