Skip to content

Commit f76998e

Browse files
committed
Fix platform-independent evidence path validation
1 parent 7b182a5 commit f76998e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/detfuzz/contract.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import shutil
55
from datetime import datetime
6-
from pathlib import Path
6+
from pathlib import Path, PurePosixPath, PureWindowsPath
77
from typing import Any
88

99
SUITE_REPORT_SCHEMA_VERSION = "1.0"
@@ -227,10 +227,12 @@ def _is_date_time(value: object) -> bool:
227227

228228
def _is_safe_relative_path(value: str) -> bool:
229229
normalized = value.replace("\\", "/")
230-
path = Path(normalized)
230+
posix_path = PurePosixPath(normalized)
231+
windows_path = PureWindowsPath(normalized)
231232
return (
232233
bool(normalized)
233-
and not path.is_absolute()
234-
and not path.drive
235-
and ".." not in path.parts
234+
and not posix_path.is_absolute()
235+
and not windows_path.is_absolute()
236+
and not windows_path.drive
237+
and ".." not in posix_path.parts
236238
)

0 commit comments

Comments
 (0)