From 6c5cad3f96a1bbe20b668730ba66dfb43eb14b08 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 27 Jun 2011 17:42:42 +0200 Subject: Add is_clean() method to archives, and move the 'secure_remove' function from parser.py to mat.py --- lib/parser.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'lib/parser.py') 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 import sys import os import subprocess +import mat POSTFIX = ".cleaned" -class Generic_parser(): +class Generic_parser(object): def __init__(self, realname, filename, parser, editor, backup): self.filename = filename self.realname = realname @@ -19,16 +20,6 @@ class Generic_parser(): self.editor = editor self.backup = backup - def secure_remove(self): - ''' - securely remove the file - ''' - #FIXME : Vulnerable to shell injection ? - try: - subprocess.call('shred --remove %s' % self.filename, shell=True) - except: - print('Unable to remove %s' % self.filename) - def is_clean(self): ''' Check if the file is clean from harmful metadatas @@ -47,7 +38,7 @@ class Generic_parser(): self._remove(field) hachoir_core.field.writeIntoFile(self.editor, self.filename + POSTFIX) if self.backup is False: - self.secure_remove() #remove the old file + mat.secure_remove(self.filename) #remove the old file os.rename(self.filename+ POSTFIX, self.filename)#rename the new def remove_all_ugly(self): -- cgit v1.3