@@ -99,6 +99,10 @@ class Extractor(Module):
99
99
# type=int,
100
100
# kwargs={'recursive_max_size': 0},
101
101
# description="Limit the total size of all extracted files"),
102
+ Option (short = '1' ,
103
+ long = 'preserve-symlinks' ,
104
+ kwargs = {'do_not_sanitize_symlinks' : True },
105
+ description = "Do not sanitize extracted symlinks that point outside the extraction directory (dangerous)" ),
102
106
Option (short = 'r' ,
103
107
long = 'rm' ,
104
108
kwargs = {'remove_after_execute' : True },
@@ -118,6 +122,7 @@ class Extractor(Module):
118
122
Kwarg (name = 'recursive_max_size' , default = None ),
119
123
Kwarg (name = 'max_count' , default = None ),
120
124
Kwarg (name = 'base_directory' , default = None ),
125
+ Kwarg (name = 'do_not_sanitize_symlinks' , default = False ),
121
126
Kwarg (name = 'remove_after_execute' , default = False ),
122
127
Kwarg (name = 'load_default_rules' , default = False ),
123
128
Kwarg (name = 'run_extractors' , default = True ),
@@ -986,6 +991,10 @@ def shell_call(self, command):
986
991
return os .wait ()[1 ]
987
992
988
993
def symlink_sanitizer (self , file_list , extraction_directory ):
994
+ # User can disable this if desired
995
+ if self .do_not_sanitize_symlinks is True :
996
+ return
997
+
989
998
# Allows either a single file path, or a list of file paths to be passed in for sanitization.
990
999
if type (file_list ) is not list :
991
1000
file_list = [file_list ]
0 commit comments