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/mat.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/mat.py') diff --git a/lib/mat.py b/lib/mat.py index 9624511..c9547c1 100644 --- a/lib/mat.py +++ b/lib/mat.py @@ -6,6 +6,7 @@ import sys import os +import subprocess import hachoir_core.cmd_line import hachoir_parser @@ -29,6 +30,17 @@ strippers = { hachoir_parser.archive.bzip2_parser.Bzip2Parser: archive.Bzip2Stripper, } +def secure_remove(filename): + ''' + securely remove the file + ''' + #FIXME : Vulnerable to shell injection ? + try: + subprocess.call('shred --remove %s' % filename, shell=True) + except: + print('Unable to remove %s' % filename) + + def is_secure(filename): ''' Prevent shell injection -- cgit v1.3