File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -303,25 +303,25 @@ def get_bunny(localstorage=None):
303303 urlretrieve (url , destination )
304304
305305 with tarfile .open (destination ) as file :
306+
306307 def is_within_directory (directory , target ):
307-
308+
308309 abs_directory = os .path .abspath (directory )
309310 abs_target = os .path .abspath (target )
310-
311+
311312 prefix = os .path .commonprefix ([abs_directory , abs_target ])
312-
313+
313314 return prefix == abs_directory
314-
315+
315316 def safe_extract (tar , path = "." , members = None , numeric_owner = False ):
316-
317+
317318 for member in tar .getmembers ():
318319 member_path = os .path .join (path , member .name )
319320 if not is_within_directory (path , member_path ):
320321 raise Exception ("Attempted Path Traversal in Tar File" )
321-
322- tar .extractall (path , members , numeric_owner = numeric_owner )
323-
324-
322+
323+ tar .extractall (path , members , numeric_owner = numeric_owner )
324+
325325 safe_extract (file , localstorage )
326326
327327 os .remove (destination )
You can’t perform that action at this time.
0 commit comments