mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 23:45:40 -07:00
Fix multiple_dots test for Windows path resolution
On Windows, ....//secrets.yaml escapes the base directory (403), while on Unix it stays inside (404). Use sys.platform to set the expected status code per platform.
This commit is contained in:
@@ -8,6 +8,7 @@ import gzip
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
@@ -535,7 +536,11 @@ async def test_download_binary_handler_subdirectory_file_url_encoded(
|
||||
pytest.param("zephyr/../../../secrets.yaml", 403, id="traversal_with_prefix"),
|
||||
pytest.param("/etc/passwd", 403, id="absolute_path"),
|
||||
pytest.param("//etc/passwd", 403, id="double_slash_absolute"),
|
||||
pytest.param("....//secrets.yaml", 404, id="multiple_dots"),
|
||||
pytest.param(
|
||||
"....//secrets.yaml",
|
||||
403 if sys.platform == "win32" else 404,
|
||||
id="multiple_dots",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_download_binary_handler_path_traversal_protection(
|
||||
|
||||
Reference in New Issue
Block a user