Skip to content

Commit 2b86f44

Browse files
committed
test: add dot/double-dot rejection tests for sanitize_path_id
Addresses CR feedback on a2aproject#1115: explicitly test that '.' and '..' are rejected by sanitize_path_id to prevent path traversal risks.
1 parent 2abd7de commit 2b86f44

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/utils/test_sanitizers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ def test_path_traversal_rejected(self) -> None:
9090
with pytest.raises(InvalidRequestError, match='invalid characters'):
9191
sanitize_path_id('../../etc/passwd')
9292

93+
def test_dot_and_double_dot_rejected(self) -> None:
94+
"""Single dot and double dot are rejected as path traversal risks."""
95+
with pytest.raises(
96+
InvalidRequestError, match=r'cannot be "\." or "\.\."'
97+
):
98+
sanitize_path_id('.')
99+
with pytest.raises(
100+
InvalidRequestError, match=r'cannot be "\." or "\.\."'
101+
):
102+
sanitize_path_id('..')
103+
93104
def test_custom_param_name_in_error(self) -> None:
94105
"""Custom param_name appears in error messages."""
95106
with pytest.raises(InvalidRequestError, match='push_id'):

0 commit comments

Comments
 (0)