diff options
Diffstat (limited to 'lib/parser.py')
| -rw-r--r-- | lib/parser.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/parser.py b/lib/parser.py index c7e189e..6b899f3 100644 --- a/lib/parser.py +++ b/lib/parser.py | |||
| @@ -8,10 +8,11 @@ import hachoir_editor | |||
| 8 | import sys | 8 | import sys |
| 9 | import os | 9 | import os |
| 10 | import subprocess | 10 | import subprocess |
| 11 | import mat | ||
| 11 | 12 | ||
| 12 | POSTFIX = ".cleaned" | 13 | POSTFIX = ".cleaned" |
| 13 | 14 | ||
| 14 | class Generic_parser(): | 15 | class Generic_parser(object): |
| 15 | def __init__(self, realname, filename, parser, editor, backup): | 16 | def __init__(self, realname, filename, parser, editor, backup): |
| 16 | self.filename = filename | 17 | self.filename = filename |
| 17 | self.realname = realname | 18 | self.realname = realname |
| @@ -19,16 +20,6 @@ class Generic_parser(): | |||
| 19 | self.editor = editor | 20 | self.editor = editor |
| 20 | self.backup = backup | 21 | self.backup = backup |
| 21 | 22 | ||
| 22 | def secure_remove(self): | ||
| 23 | ''' | ||
| 24 | securely remove the file | ||
| 25 | ''' | ||
| 26 | #FIXME : Vulnerable to shell injection ? | ||
| 27 | try: | ||
| 28 | subprocess.call('shred --remove %s' % self.filename, shell=True) | ||
| 29 | except: | ||
| 30 | print('Unable to remove %s' % self.filename) | ||
| 31 | |||
| 32 | def is_clean(self): | 23 | def is_clean(self): |
| 33 | ''' | 24 | ''' |
| 34 | Check if the file is clean from harmful metadatas | 25 | Check if the file is clean from harmful metadatas |
| @@ -47,7 +38,7 @@ class Generic_parser(): | |||
| 47 | self._remove(field) | 38 | self._remove(field) |
| 48 | hachoir_core.field.writeIntoFile(self.editor, self.filename + POSTFIX) | 39 | hachoir_core.field.writeIntoFile(self.editor, self.filename + POSTFIX) |
| 49 | if self.backup is False: | 40 | if self.backup is False: |
| 50 | self.secure_remove() #remove the old file | 41 | mat.secure_remove(self.filename) #remove the old file |
| 51 | os.rename(self.filename+ POSTFIX, self.filename)#rename the new | 42 | os.rename(self.filename+ POSTFIX, self.filename)#rename the new |
| 52 | 43 | ||
| 53 | def remove_all_ugly(self): | 44 | def remove_all_ugly(self): |
