From 420083dae629ebf67fda3bf34a44775e3346329c Mon Sep 17 00:00:00 2001 From: CleverThis Date: Sat, 9 May 2026 21:55:40 +0000 Subject: [PATCH] chore(deps): upgrade PyYAML to address known security vulnerability Remove 4 duplicate Behave step definitions from security_pyyaml_dependency_steps.py that were causing AmbiguousStep errors (already defined in tdd_a2a_sdk_dependency_steps.py). These duplicates caused CI / lint and CI / unit_tests to fail: - @given('the pyproject.toml file exists at "{path}"') - duplicate - @when('I read the project dependencies from pyproject.toml') - duplicate - @when('I attempt to import the "{module_name}" module') - duplicate - @then('the import should succeed without errors') - duplicate Only 3 PyYAML-specific steps and 1 helper remain unique to this file. ISSUES CLOSED: #9055 --- .../steps/security_pyyaml_dependency_steps.py | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/features/steps/security_pyyaml_dependency_steps.py b/features/steps/security_pyyaml_dependency_steps.py index e92585034..a0cb4ff0b 100644 --- a/features/steps/security_pyyaml_dependency_steps.py +++ b/features/steps/security_pyyaml_dependency_steps.py @@ -2,34 +2,16 @@ from __future__ import annotations -import importlib import re from pathlib import Path from typing import Any import tomllib -from behave import given, then, when +from behave import then, when from behave.runner import Context from packaging.version import Version -@given('the pyproject.toml file exists at "{path}"') -def step_pyproject_exists(context: Context, path: str) -> None: - """Verify pyproject.toml exists at the given path.""" - repo_root = Path(__file__).parent.parent.parent # features/steps -> repo root - pyproject_path = repo_root / path - assert pyproject_path.exists(), f"pyproject.toml not found at {path}" - context.pyproject_path = pyproject_path - - -@when("I read the project dependencies from pyproject.toml") -def step_read_project_dependencies(context: Context) -> None: - """Read the [project.dependencies] list from pyproject.toml.""" - content = context.pyproject_path.read_bytes() - data: dict[str, Any] = _load_toml(content) - context.project_dependencies = data.get("project", {}).get("dependencies", []) - - @then('the dependency list should include a package matching "{pattern}"') def step_dependency_matches_pattern(context: Context, pattern: str) -> None: """Assert that a dependency in the project dependencies matches the given regex pattern.""" @@ -78,24 +60,6 @@ def step_pyyaml_minimum_version(context: Context, expected: str) -> None: ) -@when('I attempt to import the "{module_name}" module') -def step_attempt_import(context: Context, module_name: str) -> None: - """Attempt to import the given module and record the result.""" - try: - context.imported_module = importlib.import_module(module_name) - context.import_error = None - except ImportError as exc: - context.imported_module = None - context.import_error = exc - - -@then("the import should succeed without errors") -def step_import_succeeded(context: Context) -> None: - """Assert that the previous import attempt succeeded.""" - assert context.import_error is None, f"Import failed with: {context.import_error}" - assert context.imported_module is not None, "Module was not imported" - - def _load_toml(content: bytes) -> dict[str, Any]: """Load a TOML file from bytes using the stdlib tomllib module (Python 3.11+).""" return tomllib.loads(content.decode("utf-8"))