diff --git a/luigi/safe_extractor.py b/luigi/safe_extractor.py index b4c279b193..8f68e9ed6a 100644 --- a/luigi/safe_extractor.py +++ b/luigi/safe_extractor.py @@ -16,11 +16,11 @@ # """ -This module provides a class `SafeExtractor` that offers a secure way to extract tar files while -mitigating path traversal vulnerabilities, which can occur when files inside the archive are +This module provides a class `SafeExtractor` that offers a secure way to extract tar files while +mitigating path traversal vulnerabilities, which can occur when files inside the archive are crafted to escape the intended extraction directory. -The `SafeExtractor` ensures that the extracted file paths are validated before extraction to +The `SafeExtractor` ensures that the extracted file paths are validated before extraction to prevent malicious archives from extracting files outside the intended directory. Classes: @@ -47,7 +47,7 @@ class SafeExtractor: _is_within_directory(directory, target): Checks if a target path is within a given directory. - safe_extract(tar_path, members=None, *, numeric_owner=False): + safe_extract(tar_path, members=None, \\*, numeric_owner=False): Safely extracts the contents of a tar file to the specified directory. """ @@ -60,7 +60,8 @@ def __init__(self, path="."): """ self.path = path - def _is_within_directory(self, directory, target): + @staticmethod + def _is_within_directory(directory, target): """ Checks if a target path is within a given directory.