File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
volatility3/framework/interfaces Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def preferred_filename(self):
4343 return self ._preferred_filename
4444
4545 @preferred_filename .setter
46- def preferred_filename (self , filename ):
46+ def preferred_filename (self , filename : str ):
4747 """Sets the preferred filename"""
4848 if self .closed :
4949 raise IOError ("FileHandler name cannot be changed once closed" )
@@ -57,6 +57,18 @@ def preferred_filename(self, filename):
5757 def close (self ):
5858 """Method that commits the file and fixes the final filename for use"""
5959
60+ @staticmethod
61+ def sanitize_filename (filename : str ) -> str :
62+ """Sanititizes the filename to ensure only a specific whitelist of characters is allowed through"""
63+ allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.- ()[]\{\}!$%^:#~?<>,|"
64+ result = ""
65+ for char in filename :
66+ if char in allowed :
67+ result += char
68+ else :
69+ result += "?"
70+ return result
71+
6072 def __enter__ (self ):
6173 return self
6274
You can’t perform that action at this time.
0 commit comments