summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2011-06-15 17:40:36 +0200
committerjvoisin2011-06-15 17:40:36 +0200
commitfe2b911cb1ce8969f0a0be65eead90d56710bb52 (patch)
tree095a2f48b008c96499ba60c1561d3e43626b2820
parent4b26e446220ef93bffa8c5099c724806120cd6e5 (diff)
Add a get_harmfull() function
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]mat.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/mat.py b/mat.py
index 8a3afcd..a80f45a 100644..100755
--- a/mat.py
+++ b/mat.py
@@ -1,3 +1,9 @@
1#!/usr/bin/python
2
3'''
4 Metadata anonymisation toolkit library
5'''
6
1import hachoir_core.error 7import hachoir_core.error
2import hachoir_core.cmd_line 8import hachoir_core.cmd_line
3import hachoir_parser 9import hachoir_parser
@@ -55,10 +61,10 @@ class file():
55 for key, field in self.meta.iteritems(): 61 for key, field in self.meta.iteritems():
56 if self._should_remove(key): 62 if self._should_remove(key):
57 print "BLEH" #DEBUG 63 print "BLEH" #DEBUG
58 #__remove(self, key) 64 #_remove(self, key)
59 #self.clean = True 65 #self.clean = True
60 66
61 def __remove(self, field): 67 def _remove(self, field):
62 ''' 68 '''
63 Remove the given file 69 Remove the given file
64 ''' 70 '''
@@ -71,7 +77,19 @@ class file():
71 ''' 77 '''
72 return self.meta 78 return self.meta
73 79
74 def _should_remove(self, field): 80 def get_harmful(self):
81 '''
82 return a dict with all the harmfull meta of the file
83 '''
84 harmful = {}
85 for key, value in self.meta.iteritems():
86 if self._should_remove(key):
87 harmful[key] = value
88 return harmful
89
90
91
92 def _should_remove(self, key):
75 ''' 93 '''
76 return True if the field is compromizing 94 return True if the field is compromizing
77 abstract method 95 abstract method
@@ -79,11 +97,16 @@ class file():
79 raise NotImplementedError() 97 raise NotImplementedError()
80 98
81class JpegStripper(file): 99class JpegStripper(file):
82 def _should_remove(self, field): 100 def _should_remove(self, key):
101 return False
102
103class PngStripper(file):
104 def _should_remove(self, key):
83 return False 105 return False
84 106
85strippers = { 107strippers = {
86 hachoir_parser.image.JpegFile: JpegStripper, 108 hachoir_parser.image.JpegFile: JpegStripper,
109 hachoir_parser.image.PngFile: PngStripper,
87} 110}
88 111
89def create_class_file(name): 112def create_class_file(name):
@@ -112,6 +135,7 @@ def create_class_file(name):
112 ''' 135 '''
113 stripper_class = strippers[editor.input.__class__] 136 stripper_class = strippers[editor.input.__class__]
114 except KeyError: 137 except KeyError:
138 #Place for another lib than hachoir
115 print("Don't have stripper for file type: %s" % editor.description) 139 print("Don't have stripper for file type: %s" % editor.description)
116 sys.exit(1) 140 sys.exit(1)
117 return stripper_class(realname, filename, parser, editor) 141 return stripper_class(realname, filename, parser, editor)