Skip to content

Commit

Permalink
Update safe_extractor.py fix lint errors
Browse files Browse the repository at this point in the history
additionally converted `_is_within_directory` to static method
  • Loading branch information
Ali-Razmjoo committed Sep 5, 2024
1 parent ad25e16 commit bd84560
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions luigi/safe_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
"""

Expand All @@ -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.
Expand Down

0 comments on commit bd84560

Please sign in to comment.