diff options
| author | jvoisin | 2011-06-27 17:42:42 +0200 |
|---|---|---|
| committer | jvoisin | 2011-06-27 17:42:42 +0200 |
| commit | 6c5cad3f96a1bbe20b668730ba66dfb43eb14b08 (patch) | |
| tree | 152001b274384ec6a9d16a493ced84009412b525 /lib/mat.py | |
| parent | 7c05c4edef20cc7438a8a90f2e9f1b507e82c132 (diff) | |
Add is_clean() method to archives, and move the 'secure_remove' function from parser.py to mat.py
Diffstat (limited to 'lib/mat.py')
| -rw-r--r-- | lib/mat.py | 12 |
1 files changed, 12 insertions, 0 deletions
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | import sys | 7 | import sys |
| 8 | import os | 8 | import os |
| 9 | import subprocess | ||
| 9 | 10 | ||
| 10 | import hachoir_core.cmd_line | 11 | import hachoir_core.cmd_line |
| 11 | import hachoir_parser | 12 | import hachoir_parser |
| @@ -29,6 +30,17 @@ strippers = { | |||
| 29 | hachoir_parser.archive.bzip2_parser.Bzip2Parser: archive.Bzip2Stripper, | 30 | hachoir_parser.archive.bzip2_parser.Bzip2Parser: archive.Bzip2Stripper, |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 33 | def secure_remove(filename): | ||
| 34 | ''' | ||
| 35 | securely remove the file | ||
| 36 | ''' | ||
| 37 | #FIXME : Vulnerable to shell injection ? | ||
| 38 | try: | ||
| 39 | subprocess.call('shred --remove %s' % filename, shell=True) | ||
| 40 | except: | ||
| 41 | print('Unable to remove %s' % filename) | ||
| 42 | |||
| 43 | |||
| 32 | def is_secure(filename): | 44 | def is_secure(filename): |
| 33 | ''' | 45 | ''' |
| 34 | Prevent shell injection | 46 | Prevent shell injection |
